sya

split youtube audio tracks, with an optional pyqt gui
git clone git://src.gearsix.net/sya
Log | Files | Refs | Atom | README

commit b29abd63d54b2fdd99db0dbf545dec8b018707ca
parent 285548599273722dde89e7b69ce0285bdf997aae
Author: gearsix <gearsix@tuta.io>
Date:   Wed, 12 May 2021 18:31:50 +0100

futher work on gui; commented out youtubedl & ffmpeg; added icons

Diffstat:
Afolder.png | 0
Mgui.py | 160++++++++++++++++++++++++++++++++++++++++----------------------------------------
Aquestion.png | 0
3 files changed, 80 insertions(+), 80 deletions(-)

diff --git a/folder.png b/folder.png Binary files differ. diff --git a/gui.py b/gui.py @@ -1,6 +1,7 @@ import os -import PyQt5.QtWidgets as pyqt +import PyQt5.QtWidgets as pyqt_widgets +import PyQt5.QtGui as pyqt_gui class Args: def __init__(self, args): @@ -13,41 +14,42 @@ class Args: self.keep = args.keep self.output = args.output # static shared values - self._sizex_btn = 35 - self._sizey_btn = 35 - # widget - self._widget = pyqt.QWidget() + self._sizex_btn = 30 + self._sizey_btn = 30 + # container widget + self._widget = pyqt_widgets.QWidget() # INFO - self._info_label = pyqt.QLabel('INFO:', self._widget) - self._info_textedit = pyqt.QTextEdit(self._widget) + self._info_label = pyqt_widgets.QLabel('INFO:', self._widget) + self._info_textedit = pyqt_widgets.QTextEdit(self._widget) # Tracklist - self._tracklist_pbtn = pyqt.QPushButton(self._widget) - self._tracklist_label = pyqt.QLabel('Tracklist:', self._widget) - self._tracklist_edit = pyqt.QLineEdit(self._widget) + self._tracklist_pbtn = pyqt_widgets.QPushButton(self._widget) + self._tracklist_label = pyqt_widgets.QLabel('Tracklist:', self._widget) + self._tracklist_edit = pyqt_widgets.QLineEdit(self._widget) + self._tracklist_help = pyqt_widgets.QPushButton(self._widget) # youtube-dl - self._youtube_pbtn = pyqt.QPushButton(self._widget) - self._youtube_label = pyqt.QLabel('youtube-dl:', self._widget) - self._youtube_edit = pyqt.QLineEdit(self._widget) + #self._youtube_pbtn = pyqt_widgets.QPushButton(self._widget) + #self._youtube_label = pyqt_widgets.QLabel('youtube-dl:', self._widget) + #self._youtube_edit = pyqt_widgets.QLineEdit(self._widget) # ffmpeg - self._ffmpeg_pbtn = pyqt.QPushButton(self._widget) - self._ffmpeg_label = pyqt.QLabel('ffmpeg:', self._widget) - self._ffmpeg_edit = pyqt.QLineEdit(self._widget) + #self._ffmpeg_pbtn = pyqt_widgets.QPushButton(self._widget) + #self._ffmpeg_label = pyqt_widgets.QLabel('ffmpeg:', self._widget) + #self._ffmpeg_edit = pyqt_widgets.QLineEdit(self._widget) # misc. options - self._keep_checkbox = pyqt.QCheckBox('keep whole track', self._widget) - self._format_label = pyqt.QLabel('Format:', self._widget) - self._format_combobox = pyqt.QComboBox(self._widget) - self._quality_label = pyqt.QLabel('Quality:', self._widget) - self._quality_combobox = pyqt.QComboBox(self._widget) + self._keep_checkbox = pyqt_widgets.QCheckBox('keep whole track', self._widget) + self._format_label = pyqt_widgets.QLabel('Format:', self._widget) + self._format_combobox = pyqt_widgets.QComboBox(self._widget) + self._quality_label = pyqt_widgets.QLabel('Quality:', self._widget) + self._quality_combobox = pyqt_widgets.QComboBox(self._widget) # output path - self._output_pbtn = pyqt.QPushButton(self._widget) - self._output_label = pyqt.QLabel('Output directory:', self._widget) - self._output_edit = pyqt.QLineEdit(self._widget) + self._output_pbtn = pyqt_widgets.QPushButton(self._widget) + self._output_label = pyqt_widgets.QLabel('Output directory:', self._widget) + self._output_edit = pyqt_widgets.QLineEdit(self._widget) # init gui elements self._init_widget() self._init_readme() self._init_tracklist() - self._init_youtubedl() - self._init_ffmpeg() + #self._init_youtubedl() + #self._init_ffmpeg() self._init_keep() self._init_format() self._init_quality() @@ -56,10 +58,10 @@ class Args: self._widget.show() def _getx_btn(self, base): - return base + 2.5 + return base + 2 def _gety_btn(self, base): - return base + 5 + return base + 10 def _getx_label(self, base): return base + 45 @@ -71,31 +73,35 @@ class Args: return base + 45 def _gety_edit(self, base): - return base + 16 + return base + 20 def _filepicker_tracklist(self, signal): - file = pyqt.QFileDialog.getOpenFileName(self._widget, 'Select a tracklist', + file = pyqt_widgets.QFileDialog.getOpenFileName(self._widget, 'Select a tracklist', os.path.expanduser("~"), "Plain-Text file (*.txt)") - if file[1] == 'text file (*.txt)': - self.path_edit.setText(file[0]) + if len(file) > 0: + self.tracklist = file[0] + self._tracklist_edit.setText(file[0]) def _filepicker_youtubedl(self, signal): - file = pyqt.QFileDialog.getOpenFileName(self._widget, 'Select youtube-dl executable', + file = pyqt_widgets.QFileDialog.getOpenFileName(self._widget, 'Select youtube-dl executable', os.path.expanduser("~"), "Executable file (*)") - self.youtubedl = file[0] - self._youtube_edit.setText(file[0]) + if len(file) > 0: + self.youtubedl = file[0] + self._youtube_edit.setText(file[0]) def _filepicker_ffmpeg(self, signal): - file = pyqt.QFileDialog.getOpenFileName(self._widget, 'Select ffmpeg executable', + file = pyqt_widgets.QFileDialog.getOpenFileName(self._widget, 'Select ffmpeg executable', os.path.expanduser("~"), "Executable file (*)") - self.ffmpeg = file[0] - self._ffmpeg_edit.setText(file[0]) + if len(file) > 0: + self.ffmpeg = file[0] + self._ffmpeg_edit.setText(file[0]) - def _filepicker_output(sef, signal): - file = pyqt.QFileDialog.getOpenFileName(self._widget, 'Select output directory', - os.path.expanduser("~"), "Directory (*)") - self.output = file[0] - self._output_edit.setText(file[0]) + def _filepicker_output(self, signal): + file = pyqt_widgets.QFileDialog.getExistingDirectory(self._widget, 'Select directory', + os.path.expanduser('~')) + if len(file) > 0: + self.output = file + self._output_edit.setText(file) def _keep_toggle(self, signal): self.keep = not self.keep @@ -108,19 +114,27 @@ class Args: def _init_widget(self): self._widget.setWindowTitle('sya') - #self._widget.setWindowIcon(pyqt.QIcon('icon.png')) - self._widget.resize(500, 600) + #self._widget.setWindowIcon(pyqt_uwidgets.QIcon('icon.png')) + self._widget.setFixedSize(400, 470) + sg = pyqt_widgets.QDesktopWidget().screenGeometry() + wg = self._widget.geometry() + self._widget.move(sg.width() / 2 - wg.width() / 2, + sg.height() / 2 - wg.height() / 2) def _init_tracklist(self): - y = 375 + y = 220 x = 25 - #self.filepicker_btn.setIcon(QIcon('logo.png')) + self._tracklist_pbtn.setIcon(pyqt_gui.QIcon('folder.png')) self._tracklist_pbtn.move(self._getx_btn(x), self._gety_btn(y)) self._tracklist_pbtn.resize(self._sizex_btn, self._sizey_btn) self._tracklist_pbtn.clicked.connect(self._filepicker_tracklist) self._tracklist_label.move(self._getx_label(x), self._gety_label(y)) self._tracklist_edit.move(self._getx_edit(x), self._gety_edit(y)) - self._tracklist_edit.resize(400, 25) + self._tracklist_edit.resize(300, 25) + self._tracklist_help.setIcon(pyqt_gui.QIcon('question.png')) + self._tracklist_help.move(self._getx_label(x) + 280, self._gety_label(y) - 50) + + self._tracklist_help.resize(18, 20) def _init_youtubedl(self): y = 420 @@ -145,14 +159,14 @@ class Args: self._ffmpeg_edit.setText(self.ffmpeg) def _init_keep(self): - y = 480 - x = 320 + y = 315 + x = 30 self._keep_checkbox.move(x, y) self._keep_checkbox.toggled.connect(self._keep_toggle) def _init_format(self): - y = 480 - x = 25 + y = 275 + x = 30 self._format_label.move(x, y+3) self._format_combobox.move(x + 70, y) self._format_combobox.activated[str].connect(self._format_change) @@ -167,8 +181,8 @@ class Args: self._format_combobox.addItem('flv') def _init_quality(self): - y = 510 - x = 25 + y = 275 + x = 190 self._quality_label.move(x, y+3) self._quality_combobox.move(x + 70, y) self._quality_combobox.activated[str].connect(self._format_change) @@ -184,39 +198,25 @@ class Args: self._quality_combobox.addItem('9 (worse)') def _init_output(self): - y = 545 + y = 355 x = 25 + self._output_pbtn.setIcon(pyqt_gui.QIcon('folder.png')) self._output_pbtn.move(self._getx_btn(x), self._gety_btn(y)) self._output_pbtn.resize(self._sizex_btn, self._sizey_btn) self._output_pbtn.clicked.connect(self._filepicker_output) self._output_label.move(self._getx_label(x), self._gety_label(y)) self._output_edit.move(self._getx_edit(x), self._gety_edit(y)) - self._output_edit.resize(400, 25) + self._output_edit.resize(300, 25) self._output_edit.setText(self.output) def _init_readme(self): - self._info_label.move(25, 45) - self._info_textedit.resize(450, 300) - self._info_textedit.move(25, 65) + x = 25 + y = 60 + self._info_label.move(x, y) +# self._info_textedit.resize(450, 300) + self._info_textedit.resize(350, 115) + self._info_textedit.move(x, y + 20) self._info_textedit.setReadOnly(True) - self._info_textedit.setPlainText( -'''sya uses the tools "youtube-dl" and "ffmpeg" to download videos from youtube, extract & converts their audio them to an audio file, then splits that file based on set timestamps set in a "tracklist" text file (see below). - -Select a file to use as the "tracklist" and various options below. - -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''') + self._info_textedit.setPlainText('''sya is a simple python script that downloads youtube videos, extracts their audio and splits that audio into mutliple tracks using "youtube-dl" and "ffmpeg". + +Click "?" for help.''') diff --git a/question.png b/question.png Binary files differ.