Skip to content

Commit

Permalink
MVP (hooray 😄🎉) (yet more is to be done)
Browse files Browse the repository at this point in the history
  • Loading branch information
sentenzo committed Aug 26, 2022
1 parent 638ead4 commit bac0e94
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 29 deletions.
20 changes: 16 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,28 @@ else
endif
endif

ENTRY_POINT = ./src/app.py
# APP_FILE = app
APP_FILE = app_gui

APP_NAME = yt-dpl-qt6

ENTRY_POINT = ./src/$(APP_FILE).py

all:

pyui:
pyuic6 -o ./src/qt/py_ui/main_window.py -x ./src/qt/ui/main_window.ui
pyuic6 -o ./src/qt/py_ui/main_window.py \
-x ./src/qt/ui/main_window.ui

build:
pyinstaller --workpath ./.pyinstaller/build --distpath ./bin --specpath ./.pyinstaller --onefile $(ENTRY_POINT)
pyinstaller --workpath ./.pyinstaller/build \
--distpath ./bin --specpath ./.pyinstaller \
--noconsole --onefile \
--name $(APP_NAME) \
$(ENTRY_POINT)

run:
./bin/app
./bin/$(APP_NAME)

runpy:
$(PYTHON) $(ENTRY_POINT)
Expand Down
18 changes: 2 additions & 16 deletions src/app.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,6 @@
import sys
from yt_dlp import YoutubeDL


def download_videos(urls):
# if not urls or not isinstance(urls, list):
# # Rick Astley - Never Gonna Give You Up (Official Music Video)
urls = ["https://www.youtube.com/watch?v=dQw4w9WgXcQ"]
with YoutubeDL() as ydl:
ydl.download(urls)


def main():
if len(sys.argv) > 1:
download_videos(sys.argv[1:])
print(sys.argv)
from ytdpl_wrapper import download_videos


if __name__ == "__main__":
main()
download_videos(sys.argv[1:])
24 changes: 19 additions & 5 deletions src/app_gui.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
import sys
from PyQt6.QtWidgets import QApplication, QWidget, QMainWindow
import PyQt6.QtWidgets as qtw

# from PyQt6.QtWidgets import QApplication, QWidget, QMainWindow, QPushButton, QTextEdit

from qt.py_ui.main_window import Ui_MainWindow
from ytdpl_wrapper import download_videos

app = qtw.QApplication(sys.argv)
window = qtw.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(window)


def do__download_all():
te_youtube_links = window.findChild(qtw.QTextEdit, "te_youtube_links")
youtube_links = te_youtube_links.toPlainText().split()
download_videos(youtube_links)


window.findChild(qtw.QPushButton, "pb_download_all").clicked.connect(do__download_all)

if __name__ == "__main__":
app = QApplication(sys.argv)
window = QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(window)

window.show()
app.exec()
11 changes: 8 additions & 3 deletions src/qt/py_ui/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ def setupUi(self, MainWindow):
self.verticalLayout = QtWidgets.QVBoxLayout()
self.verticalLayout.setSizeConstraint(QtWidgets.QLayout.SizeConstraint.SetDefaultConstraint)
self.verticalLayout.setObjectName("verticalLayout")
self.textEdit = QtWidgets.QTextEdit(self.centralwidget)
self.textEdit.setObjectName("textEdit")
self.verticalLayout.addWidget(self.textEdit)
self.te_youtube_links = QtWidgets.QTextEdit(self.centralwidget)
self.te_youtube_links.setObjectName("te_youtube_links")
self.verticalLayout.addWidget(self.te_youtube_links)
self.pb_download_all = QtWidgets.QPushButton(self.centralwidget)
self.pb_download_all.setObjectName("pb_download_all")
self.verticalLayout.addWidget(self.pb_download_all)
Expand All @@ -45,6 +45,11 @@ def setupUi(self, MainWindow):
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
self.te_youtube_links.setHtml(_translate("MainWindow", "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
"p, li { white-space: pre-wrap; }\n"
"</style></head><body style=\" font-family:\'MS Shell Dlg 2\'; font-size:8.25pt; font-weight:400; font-style:normal;\">\n"
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">https://www.youtube.com/watch?v=cmb6pTj67Nk</p></body></html>"))
self.pb_download_all.setText(_translate("MainWindow", "Download All"))


Expand Down
10 changes: 9 additions & 1 deletion src/qt/ui/main_window.ui
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,15 @@
<enum>QLayout::SetDefaultConstraint</enum>
</property>
<item>
<widget class="QTextEdit" name="textEdit"/>
<widget class="QTextEdit" name="te_youtube_links">
<property name="html">
<string>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;https://www.youtube.com/watch?v=cmb6pTj67Nk&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pb_download_all">
Expand Down
9 changes: 9 additions & 0 deletions src/ytdpl_wrapper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from yt_dlp import YoutubeDL


def download_videos(urls=None):
if not urls or not isinstance(urls, list):
# Rick Astley - Never Gonna Give You Up (Official Music Video)
urls = ["https://www.youtube.com/watch?v=dQw4w9WgXcQ"]
with YoutubeDL() as ydl:
ydl.download(urls)

0 comments on commit bac0e94

Please sign in to comment.