From cb6f90a027c9b2ccdfd1732f12fba48aff396673 Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Wed, 21 Feb 2018 16:21:20 -0600 Subject: [PATCH] Use best audio stream for youtube videos --- src/youtube_utils.py | 17 +---------------- 1 file changed, 1 insertion(+), 16 deletions(-) diff --git a/src/youtube_utils.py b/src/youtube_utils.py index cf9f6d73..af000fed 100644 --- a/src/youtube_utils.py +++ b/src/youtube_utils.py @@ -1,11 +1,10 @@ # -*- coding: utf-8 -*- -import subprocess import youtube_dl player = None # Let's control player from here def get_video_url(url): - ydl = youtube_dl.YoutubeDL({'quiet': True, 'format': '251', 'outtmpl': u'%(id)s%(ext)s'}) + ydl = youtube_dl.YoutubeDL({'quiet': True, 'format': 'bestaudio/best', 'outtmpl': u'%(id)s%(ext)s'}) with ydl: result = ydl.extract_info(url, download=False) if 'entries' in result: @@ -13,17 +12,3 @@ def get_video_url(url): else: video = result return video["url"] - -def play_video(url): - global player - if player != None: - player.kill() - player = None - player = subprocess.Popen(["ffplay.exe", "-i", url, "-nodisp", "-vn", "-hide_banner"], stderr=subprocess.PIPE, stdout=subprocess.PIPE, stdin=subprocess.PIPE) - return player - -def stop(): - global player - if player != None: - player.kill() - player = None