summary refs log tree commit diff
diff options
context:
space:
mode:
authorRemita Amine <remitamine@gmail.com>2019-07-30 00:13:33 +0100
committerRemita Amine <remitamine@gmail.com>2019-07-30 00:13:33 +0100
commit8dbf751aa241475dd8a7a6d3040713b5874fd057 (patch)
tree029cbe3c07e88831bdf23923d4fd300d7610ba78
parent90634acfcf9b106c9f5ac12bae5d92307cd577b0 (diff)
downloadyoutube-dl-8dbf751aa241475dd8a7a6d3040713b5874fd057.tar.gz
youtube-dl-8dbf751aa241475dd8a7a6d3040713b5874fd057.tar.xz
youtube-dl-8dbf751aa241475dd8a7a6d3040713b5874fd057.zip
[youtube] improve title and description extraction(closes #21934)
-rw-r--r--youtube_dl/extractor/youtube.py15
1 files changed, 3 insertions, 12 deletions
diff --git a/youtube_dl/extractor/youtube.py b/youtube_dl/extractor/youtube.py
index b2c714505..9a182fcf6 100644
--- a/youtube_dl/extractor/youtube.py
+++ b/youtube_dl/extractor/youtube.py
@@ -1820,16 +1820,11 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
         video_details = try_get(
             player_response, lambda x: x['videoDetails'], dict) or {}
 
-        # title
-        if 'title' in video_info:
-            video_title = video_info['title'][0]
-        elif 'title' in player_response:
-            video_title = video_details['title']
-        else:
+        video_title = video_info.get('title', [None])[0] or video_details.get('title')
+        if not video_title:
             self._downloader.report_warning('Unable to extract video title')
             video_title = '_'
 
-        # description
         description_original = video_description = get_element_by_id("eow-description", video_webpage)
         if video_description:
 
@@ -1854,11 +1849,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
             ''', replace_url, video_description)
             video_description = clean_html(video_description)
         else:
-            fd_mobj = re.search(r'<meta name="description" content="([^"]+)"', video_webpage)
-            if fd_mobj:
-                video_description = unescapeHTML(fd_mobj.group(1))
-            else:
-                video_description = ''
+            video_description = self._html_search_meta('description', video_webpage) or video_details.get('shortDescription')
 
         if not smuggled_data.get('force_singlefeed', False):
             if not self._downloader.params.get('noplaylist'):