]> git.bitcoin.ninja Git - youtube-dl/commitdiff
[mtv] Fix title for gametrailers (Fixes #2188)
authorPhilipp Hagemeister <phihag@phihag.de>
Tue, 21 Jan 2014 23:17:33 +0000 (00:17 +0100)
committerPhilipp Hagemeister <phihag@phihag.de>
Tue, 21 Jan 2014 23:17:33 +0000 (00:17 +0100)
We now prefer the title including the category, because that title is what is presented at the actual sites.

youtube_dl/extractor/gametrailers.py
youtube_dl/extractor/mtv.py

index d82a5d4b2a30578298080f03a8bba5f502e48f20..617578e72b1d852c5b2ea22f3a5bd417ea0bf449 100644 (file)
@@ -10,7 +10,7 @@ class GametrailersIE(MTVServicesInfoExtractor):
         u'file': u'70e9a5d7-cf25-4a10-9104-6f3e7342ae0d.mp4',
         u'md5': u'4c8e67681a0ea7ec241e8c09b3ea8cf7',
         u'info_dict': {
-            u'title': u'E3 2013: Debut Trailer',
+            u'title': u'Mirror\'s Edge 2|E3 2013: Debut Trailer',
             u'description': u'Faith is back!  Check out the World Premiere trailer for Mirror\'s Edge 2 straight from the EA Press Conference at E3 2013!',
         },
     }
index c4fa16fb6de697498f9025bee0afd35ff7e20a5d..8385929e02681a55260fbe4ccec368d57a10389b 100644 (file)
@@ -5,9 +5,11 @@ from .common import InfoExtractor
 from ..utils import (
     compat_urllib_parse,
     ExtractorError,
+    find_xpath_attr,
     fix_xml_ampersands,
 )
 
+
 def _media_xml_tag(tag):
     return '{http://search.yahoo.com/mrss/}%s' % tag
 
@@ -72,8 +74,21 @@ class MTVServicesInfoExtractor(InfoExtractor):
         else:
             description = None
 
+        title_el = None
+        if title_el is None:
+            title_el = find_xpath_attr(
+                itemdoc, './/{http://search.yahoo.com/mrss/}category',
+                'scheme', 'urn:mtvn:video_title')
+        if title_el is None:
+            title_el = itemdoc.find('.//{http://search.yahoo.com/mrss/}title')
+        if title_el is None:
+            title_el = itemdoc.find('.//title')
+        title = title_el.text
+        if title is None:
+            raise ExtractorError('Could not find video title')
+
         return {
-            'title': itemdoc.find('title').text,
+            'title': title,
             'formats': self._extract_video_formats(mediagen_page),
             'id': video_id,
             'thumbnail': self._get_thumbnail_url(uri, itemdoc),