[youtube] Video categories added to metadata
authorDario Guarascio <dario@pink.esync.lan>
Thu, 15 May 2014 06:59:27 +0000 (13:59 +0700)
committerDario Guarascio <dario@pink.esync.lan>
Thu, 15 May 2014 06:59:27 +0000 (13:59 +0700)
youtube_dl/extractor/youtube.py

index 1f3aa4322c274e226b6e5945874e8627724a79cf..f0a92d18224eebbd69fb9dad6a1a211a7d70fed3 100644 (file)
@@ -1141,6 +1141,14 @@ class YoutubeIE(YoutubeBaseInfoExtractor, SubtitlesInfoExtractor):
             upload_date = ' '.join(re.sub(r'[/,-]', r' ', mobj.group(1)).split())
             upload_date = unified_strdate(upload_date)
 
+
+        video_categories = []
+        # categories
+        m_cat_container = get_element_by_id("eow-category", video_webpage)
+        if m_cat_container:
+            video_categories = re.findall(r'<a[^<]+>(.*?)</a>',
+                                m_cat_container, re.DOTALL)
+
         # description
         video_description = get_element_by_id("eow-description", video_webpage)
         if video_description:
@@ -1347,6 +1355,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor, SubtitlesInfoExtractor):
             'title':        video_title,
             'thumbnail':    video_thumbnail,
             'description':  video_description,
+            'categories':   video_categories,
             'subtitles':    video_subtitles,
             'duration':     video_duration,
             'age_limit':    18 if age_gate else 0,