mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2025-08-26 09:59:23 +00:00
audio_services should now be completely independent from the source code it's self. #273
This commit is contained in:
12
src/audio_services/youtube_utils.py
Normal file
12
src/audio_services/youtube_utils.py
Normal file
@@ -0,0 +1,12 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import youtube_dl
|
||||
|
||||
def get_video_url(url):
|
||||
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:
|
||||
video = result['entries'][0]
|
||||
else:
|
||||
video = result
|
||||
return video["url"]
|
Reference in New Issue
Block a user