Ask Youtube to retrieve json results
This commit is contained in:
parent
b286e526cc
commit
2613803031
@ -23,7 +23,7 @@ class interface(base.baseInterface):
|
|||||||
type = "video"
|
type = "video"
|
||||||
max_results = config.app["services"]["youtube"]["max_results"]
|
max_results = config.app["services"]["youtube"]["max_results"]
|
||||||
log.debug("Retrieving data from Youtube...")
|
log.debug("Retrieving data from Youtube...")
|
||||||
ydl = youtube_dl.YoutubeDL({'quiet': True, 'ignore_errors': True, 'no_warnings': True, 'logger': log, 'format': 'bestaudio/best', 'outtmpl': u'%(id)s%(ext)s'})
|
ydl = youtube_dl.YoutubeDL({'dump_single_json': True, 'quiet': True, 'ignore_errors': True, 'no_warnings': True, 'logger': log, 'format': 'bestaudio/best', 'outtmpl': u'%(id)s%(ext)s'})
|
||||||
with ydl:
|
with ydl:
|
||||||
search_param = "ytsearch{}:{}".format(max_results, text)
|
search_param = "ytsearch{}:{}".format(max_results, text)
|
||||||
result = ydl.extract_info(search_param, download=False)
|
result = ydl.extract_info(search_param, download=False)
|
||||||
@ -46,7 +46,7 @@ class interface(base.baseInterface):
|
|||||||
log.debug("Getting download URL for {0}".format(url,))
|
log.debug("Getting download URL for {0}".format(url,))
|
||||||
if "playlist?list=" in url:
|
if "playlist?list=" in url:
|
||||||
return self.search_from_playlist(url)
|
return self.search_from_playlist(url)
|
||||||
ydl = youtube_dl.YoutubeDL({'quiet': True, 'ignore_errors': True, 'no_warnings': True, 'logger': log, 'prefer-free-formats': True, 'format': 'bestaudio', 'outtmpl': u'%(id)s%(ext)s'})
|
ydl = youtube_dl.YoutubeDL({'quiet': True, 'dump_single_json': True, 'ignore_errors': True, 'no_warnings': True, 'logger': log, 'prefer-free-formats': True, 'format': 'bestaudio', 'outtmpl': u'%(id)s%(ext)s'})
|
||||||
with ydl:
|
with ydl:
|
||||||
result = ydl.extract_info(url, download=False)
|
result = ydl.extract_info(url, download=False)
|
||||||
if 'entries' in result:
|
if 'entries' in result:
|
||||||
@ -65,7 +65,7 @@ class interface(base.baseInterface):
|
|||||||
id = url.split("=")[1]
|
id = url.split("=")[1]
|
||||||
max_results = 50
|
max_results = 50
|
||||||
log.debug("Retrieving data from Youtube...")
|
log.debug("Retrieving data from Youtube...")
|
||||||
ydl = youtube_dl.YoutubeDL({'quiet': True, 'ignore_errors': True, 'no_warnings': True, 'logger': log, 'format': 'bestaudio/best', 'outtmpl': u'%(id)s%(ext)s'})
|
ydl = youtube_dl.YoutubeDL({'quiet': True, 'dump_single_json': True, 'ignore_errors': True, 'no_warnings': True, 'logger': log, 'format': 'bestaudio/best', 'outtmpl': u'%(id)s%(ext)s'})
|
||||||
with ydl:
|
with ydl:
|
||||||
result = ydl.extract_info(url, download=False)
|
result = ydl.extract_info(url, download=False)
|
||||||
self.results = []
|
self.results = []
|
||||||
@ -85,7 +85,7 @@ class interface(base.baseInterface):
|
|||||||
|
|
||||||
def get_download_url(self, url):
|
def get_download_url(self, url):
|
||||||
log.debug("Getting download URL for {0}".format(url,))
|
log.debug("Getting download URL for {0}".format(url,))
|
||||||
ydl = youtube_dl.YoutubeDL({'quiet': True, 'no_warnings': True, 'logger': log, 'prefer_insecure': True, 'format': 'bestaudio/best', 'outtmpl': u'%(id)s%(ext)s'})
|
ydl = youtube_dl.YoutubeDL({'quiet': True, 'dump_single_json': True, 'no_warnings': True, 'logger': log, 'prefer_insecure': True, 'format': 'bestaudio/best', 'outtmpl': u'%(id)s%(ext)s'})
|
||||||
with ydl:
|
with ydl:
|
||||||
result = ydl.extract_info(url, download=False)
|
result = ydl.extract_info(url, download=False)
|
||||||
if 'entries' in result:
|
if 'entries' in result:
|
||||||
|
Loading…
Reference in New Issue
Block a user