commit a9c294e3ea334986627b04c3863c96211910450a
parent 12f1027241fbba1d483e225a754fd82186f0c877
Author: gearsix <gearsix@tuta.io>
Date: Sat, 8 May 2021 02:11:43 +0100
started adding pyqt5 gui when no args are set
Diffstat:
M | sya.py | | | 71 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- |
1 file changed, 70 insertions(+), 1 deletion(-)
diff --git a/sya.py b/sya.py
@@ -4,6 +4,8 @@ import argparse
import subprocess
import re
import os
+import sys
+import PyQt5.QtWidgets as pyqt
Timestamp = re.compile('[\[,\(]?(:?\d{1,2}){3}[\],\)]?')
@@ -12,6 +14,67 @@ class TracklistItem:
self.timestamp = timestamp
self.title = title
+class GUI:
+ def __init__(self, widget):
+ self.widget = widget
+ self.init_widget()
+ self.filepickerbtn = pyqt.QPushButton(widget)
+ self.pathlabel = pyqt.QLabel('Tracklist:', widget)
+ self.textbox = pyqt.QTextEdit(widget)
+ self.init_tracklist()
+ self.init_readme()
+
+ def filepicker(self, signal):
+ file = pyqt.QFileDialog.getOpenFileName(self.widget, 'Select a tracklist', os.path.expanduser("~"), "text file (*.txt)")
+ if file[1] == 'text file (*.txt)':
+ self.pathlineditor.setText(file[0])
+
+ def init_widget(self):
+ widget.setWindowTitle('sya')
+ widget.resize(500, 500)
+ #widget.setWindowIcon(pyqt.QIcon('icon.png'))
+
+ def init_tracklist(self):
+ #self.filepickerbtn.setIcon(QIcon('logo.png'))
+ self.filepickerbtn.move(25, 25)
+ self.filepickerbtn.resize(40, 40)
+ self.filepickerbtn.clicked.connect(self.filepicker)
+
+ self.pathlabel.move(75, 23)
+
+ self.pathlineditor = pyqt.QLineEdit(widget)
+ self.pathlineditor.move(75, 38)
+ self.pathlineditor.resize(400, 25)
+
+ def init_readme(self):
+ self.textbox.resize(450, 330)
+ self.textbox.move(25, 120)
+ self.textbox.setReadOnly(True)
+ self.textbox.setPlainText('''
+ DESCRIPTION
+ sya downloads, converts and splits youtube videos using `youtube-dl` and `ffmpeg`.
+ while intended for long audio mixtapes, the tools it uses are quite flexible so
+ you could use it to download & split long videos as well.
+
+ TRACKLIST
+ TRACKLIST files should be text file that has the URL/v=code of the youtube video to
+ download on the first line and the starting timestamp of each section to split, followed
+ by the title of that section section.
+ Here is an example:
+
+ https://www.youtube.com/watch?v=ors0wpcVDcc
+ Los Natas - Brisa Del Desierto [00:00]
+ Sleeping Pandora - Through The Maze [02:05]
+ Fluidage - Feel Like I Do [12:43]
+ My Sleeping Karma - Psilocybe [18:11]
+ Daisy Pusher - While Wailing (Only a Part) [26:01]
+ The Whirlings - Worries on a Shelf [30:49]
+ Arenna - Move Through Figurehead Lights [36:28]
+ Ten East - Skyline Pressure [43:32]
+ Wooden Shjips - These Shadows [49:24]
+ ...etc
+ ''')
+
def log(msg):
print('sya:', msg)
@@ -23,7 +86,7 @@ def parse_args():
parser = argparse.ArgumentParser(
description='download & split audio tracks long youtube videos')
# arguments
- parser.add_argument('tracklist', metavar='TRACKLIST',
+ parser.add_argument('tracklist', metavar='TRACKLIST', nargs='?',
help='tracklist to split audio by')
# options
parser.add_argument('-o', '--output', metavar='PATH', type=str, nargs='?',
@@ -118,6 +181,12 @@ def split_tracks(ffmpeg, audio_fpath, tracks, outpath):
if __name__ == '__main__':
args = parse_args()
+ if len(sys.argv) == 1:
+ app = pyqt.QApplication([])
+ widget = pyqt.QWidget()
+ gui = GUI(widget)
+ widget.show()
+ sys.exit(app.exec_())
if check_bin(args.youtubedl, args.ffmpeg) == False:
error_exit('required binaries are missing')
tracklist = load_tracklist(args.tracklist)