De-clutter metadata search

This commit is contained in:
Ritiek Malhotra
2020-05-07 19:36:38 +05:30
parent ec5704e050
commit c9bf0bc020
8 changed files with 410 additions and 166 deletions

View File

@@ -108,10 +108,6 @@ class YouTubeSearch:
logger.debug('Fetching YouTube results for "{}".'.format(search_url))
html = self._fetch_response_html(search_url)
videos = self._fetch_search_results(html)
# print(html)
# print("")
# print(videos)
# exit()
return YouTubeVideos(videos)
@@ -198,7 +194,7 @@ class YouTubeStreams(StreamsBase):
class ProviderYouTube(ProviderBase):
def from_query(self, query):
watch_urls = YouTubeSearch().search(query)
watch_urls = self.search(query)
if not watch_urls:
raise YouTubeMetadataNotFoundError(
'YouTube returned nothing for the given search '
@@ -214,6 +210,9 @@ class ProviderYouTube(ProviderBase):
def from_pytube_object(self, content):
return self.metadata_to_standard_form(content)
def search(self, query):
return YouTubeSearch().search(query)
def _fetch_publish_date(self, content):
# FIXME: This needs to be supported in PyTube itself
# See https://github.com/nficano/pytube/issues/595