Skip to content

Commit

Permalink
Split code, proper ffmpeg path setup on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
casualsnek committed Oct 12, 2022
1 parent 264136a commit 42132f0
Show file tree
Hide file tree
Showing 22 changed files with 924 additions and 833 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ __pycache__/
*.so

# Distribution / packaging
ffbin_*/
.Python
build/
develop-eggs/
Expand Down Expand Up @@ -105,7 +106,7 @@ celerybeat.pid
.env
.venv
env/
venv/
venv*/
ENV/
env.bak/
venv.bak/
Expand Down
Empty file modified LICENSE
100755 → 100644
Empty file.
15 changes: 14 additions & 1 deletion __init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@

import sys
from PyQt5.QtWidgets import QApplication
from gui.mainui import MainWindow
from gui.minidialog import MiniDialog
from runtimedata import get_logger

if __name__ == '__main__':
logger = get_logger('__init__')
logger.info('Starting application in \n3\n2\n1')
app = QApplication(sys.argv)
_dialog = MiniDialog()
window = MainWindow(_dialog)
app.exec_()
logger.info('Good bye ..')
9 changes: 4 additions & 5 deletions build_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ if [ -f "./dist/onthespot_linux" ]; then
rm ./dist/onthespot_linux
fi
rm -rf ./build
rm -rf ./dist
rm -rf ./venv
echo " => Creating virtual env."
python3 -m venv venv
Expand All @@ -19,18 +18,18 @@ pip install -r requirements.txt
if [ -f "ffbin_nix/ffmpeg" ]; then
echo " => Found 'ffbin_win' directory and ffmpeg binary.. Using ffmpeg binary append mode "
pyinstaller --onefile \
--add-data="ui/*.ui:ui" \
--add-data="gui/qtui/*.ui:qui/qtui" \
--add-binary="ffbin_nix/*:bin/ffmpeg" \
--paths="." \
--name="onthespot_linux" \
onthespot.py
__init__.py
else
echo " => Building to use ffmpeg binary from system... "
pyinstaller --onefile \
--add-data="ui/*.ui:ui" \
--add-data="gui/qtui/*.ui:gui/qtui" \
--paths="." \
--name="onthespot_linux" \
onthespot.py
__init__.py
fi
echo " => Setting permissions.. "
chmod +x ./dist/onthespot_linux
Expand Down
12 changes: 6 additions & 6 deletions build_winC1.bat
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
@echo off
echo "========= OnTheSpot Windows Build Script ==========="
echo " => Cleaning up !"
echo ========= OnTheSpot Windows Build Script ===========
echo =^> Cleaning up !"
rmdir build /s /q
rmdir dist /s /q
rmdir __pycache__ /s /q
rmdir venvwin /s /q
if exist dist\onthespot_win.exe (
del /F /Q /A dist\onthespot_win.exe
)
echo " => Creating virtual env."
echo =^> Creating virtual env.
python.exe -m venv venvwin
echo " => Switching to virtual env."
echo " => Now run phase 2 script 'build_winC2.bat' "
echo =^> Switching to virtual env.
echo =^> Now run phase 2 script 'build_winC2.bat'
venvwin\Scripts\activate.bat
16 changes: 8 additions & 8 deletions build_winC2.bat
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
@echo off
echo => Installing 'pyinstaller' via pip...
echo =^> Installing 'pyinstaller' via pip...
pip install --upgrade pip
pip install wheel
pip install pyinstaller
echo => Installing dependencies pip...
echo =^> Installing dependencies pip...
pip install winsdk
pip install simpleaudio
pip install -r requirements.txt
if exist ffbin_win\ffmpeg.exe (
echo " => Found 'ffbin_win' directory and ffmpeg binary.. Using ffmpeg binary append mode "
pyinstaller --onefile --noconfirm --hidden-import simpleaudio --add-binary="ffbin_win/*.exe;bin/ffmpeg" --add-data="ui/*.ui;ui" --paths="." --name="onthespot_win" onthespot.py
echo =^> Found 'ffbin_win' directory and ffmpeg binary.. Using ffmpeg binary append mode
pyinstaller --onefile --noconfirm --hidden-import simpleaudio --add-binary="ffbin_win/*.exe;bin/ffmpeg" --add-data="gui/qtui/*.ui;gui/qtui" --paths="." --name="onthespot_win" __init__.py
) else (
echo => Building to use ffmpeg binary from system...
pyinstaller --onefile --noconfirm --hidden-import simpleaudio --add-data="ui/*.ui;ui" --paths="." --name="onthespot_win" onthespot.py
echo =^> Building to use ffmpeg binary from system...
pyinstaller --onefile --noconfirm --hidden-import simpleaudio --add-data="gui/qtui/*.ui;gui/qtui" --paths="." --name="onthespot_win" __init__.py
)
echo => Cleaning..
echo =^> Cleaning..
del /F /Q /A onthespot_win.spec
rmdir build /s /q
rmdir __pycache__ /s /q
echo => Done
echo =^> Done
Empty file added gui/__init__.py
Empty file.
40 changes: 40 additions & 0 deletions gui/dl_progressbtn.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import os
from PyQt5.QtWidgets import QHBoxLayout, QWidget
from runtimedata import downloaded_data, cancel_list, failed_downloads, downloads_status, download_queue
from showinfm import show_in_file_manager


class DownloadActionsButtons(QWidget):
def __init__(self, dl_id, pbar, cancel_btn, remove_btn, locate_btn, parent=None):
super(DownloadActionsButtons, self).__init__(parent)
self.__id = dl_id
self.cancel_btn = cancel_btn
self.remove_btn = remove_btn
self.locate_btn = locate_btn
layout = QHBoxLayout()
layout.setContentsMargins(0, 0, 0, 0)
layout.setSpacing(0)
cancel_btn.clicked.connect(self.cancel_item)
remove_btn.clicked.connect(self.retry_item)
locate_btn.clicked.connect(self.locate_file)
layout.addWidget(pbar)
layout.addWidget(cancel_btn)
layout.addWidget(remove_btn)
layout.addWidget(locate_btn)
self.setLayout(layout)

def locate_file(self):
if self.__id in downloaded_data:
if downloaded_data[self.__id].get('media_path', None):
show_in_file_manager(os.path.abspath(downloaded_data[self.__id]['media_path']))

def cancel_item(self):
cancel_list[self.__id] = {}
self.cancel_btn.hide()

def retry_item(self):
if self.__id in failed_downloads:
downloads_status[self.__id]["status_label"].setText("Waiting")
self.remove_btn.hide()
download_queue.put(failed_downloads[self.__id])
self.cancel_btn.show()
Loading

0 comments on commit 42132f0

Please sign in to comment.