From aa291342e7bc2ac2bc03170dd5144af20d1aad61 Mon Sep 17 00:00:00 2001 From: heniotierra Date: Mon, 7 Dec 2020 01:48:31 -0300 Subject: [PATCH] Allow option for dowblodinging audio only from youtube --- tboplayer.py | 7 ++++--- ytdl.py | 6 +++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/tboplayer.py b/tboplayer.py index fff52d8..d267895 100644 --- a/tboplayer.py +++ b/tboplayer.py @@ -466,11 +466,12 @@ def go_ytdl(self, url, playlist=False): if self.ytdl_state in (self._YTDL_CLOSED, self._YTDL_ENDING): self.ytdl_state=self._YTDL_STARTING self.ytdl.start_signal=True - + + youtube_media_format = self.options.youtube_media_format if not playlist: - self.ytdl.retrieve_media_url(url, self.options.youtube_media_format) + self.ytdl.retrieve_media_url(url, youtube_media_format) else: - self.ytdl.retrieve_youtube_playlist(url) + self.ytdl.retrieve_youtube_playlist(url, youtube_media_format) if self.ytdl_state==self._YTDL_STARTING: self.ytdl_state_machine() diff --git a/ytdl.py b/ytdl.py index d743e28..9c30312 100644 --- a/ytdl.py +++ b/ytdl.py @@ -26,7 +26,7 @@ class Ytdl: _YTLAUNCH_CMD = '' _YTLAUNCH_ARGS_FORMAT = ' -j -f %s --youtube-skip-dash-manifest "%s"' _YTLAUNCH_PLST_CMD = '' - _YTLAUNCH_PLST_ARGS_FORMAT = ' -J -f mp4 --youtube-skip-dash-manifest "%s"' + _YTLAUNCH_PLST_ARGS_FORMAT = ' -J -f %s --youtube-skip-dash-manifest "%s"' _YTLAUNCH_SUB_DIR = '/dev/shm/tbopsubs' _YTLAUNCH_SUBT_ARGS_FORMAT = ' --write-sub --sub-lang %s --skip-download "%s" --output %s/subtitle' _YTLAUNCH_AUTOSUBT_ARGS_FORMAT = ' --write-auto-sub --sub-lang %s --skip-download "%s" --output %s/subtitle' @@ -151,9 +151,9 @@ def retrieve_media_url(self, url, f): self._running_processes[url] = [process, ''] # process, result self._spawn_thread(url) - def retrieve_youtube_playlist(self, url): + def retrieve_youtube_playlist(self, url, f): if self.is_running(url): return - ytcmd = self._YTLAUNCH_PLST_CMD % (url) + ytcmd = self._YTLAUNCH_PLST_CMD % (f, url) process = pexpect.spawn(ytcmd, timeout=180, maxread=50000, searchwindowsize=50000) self._running_processes[url] = [process, ''] self._spawn_thread(url)