Skip to content

Commit

Permalink
Allow option for dowblodinging audio only from youtube
Browse files Browse the repository at this point in the history
  • Loading branch information
heniotierra committed Dec 7, 2020
1 parent 184bc2e commit aa29134
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions tboplayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
6 changes: 3 additions & 3 deletions ytdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit aa29134

Please sign in to comment.