Merge pull request #5985 from zx8/master
[youtube-dl] / youtube_dl / extractor / francetv.py
index 0d92ef9c4533ee87a392d3db34ed801d2140da25..db0bbec1ec1338e3aeaaa26af19cc0612372995f 100644 (file)
@@ -16,6 +16,7 @@ from ..utils import (
     int_or_none,
     float_or_none,
     parse_duration,
+    determine_ext,
 )
 
 
@@ -51,22 +52,20 @@ class FranceTVBaseInfoExtractor(InfoExtractor):
             if not video_url:
                 continue
             format_id = video['format']
-            if video_url.endswith('.f4m'):
+            ext = determine_ext(video_url)
+            if ext == 'f4m':
                 if georestricted:
                     # See https://github.com/rg3/youtube-dl/issues/3963
                     # m3u8 urls work fine
                     continue
                 video_url_parsed = compat_urllib_parse_urlparse(video_url)
                 f4m_url = self._download_webpage(
-                    'http://hdfauth.francetv.fr/esi/urltokengen2.html?url=%s' % video_url_parsed.path,
+                    'http://hdfauth.francetv.fr/esi/TA?url=%s' % video_url_parsed.path,
                     video_id, 'Downloading f4m manifest token', fatal=False)
                 if f4m_url:
-                    f4m_formats = self._extract_f4m_formats(f4m_url, video_id)
-                    for f4m_format in f4m_formats:
-                        f4m_format['preference'] = 1
-                    formats.extend(f4m_formats)
-            elif video_url.endswith('.m3u8'):
-                formats.extend(self._extract_m3u8_formats(video_url, video_id, 'mp4'))
+                    formats.extend(self._extract_f4m_formats(f4m_url, video_id, 1, format_id))
+            elif ext == 'm3u8':
+                formats.extend(self._extract_m3u8_formats(video_url, video_id, 'mp4', m3u8_id=format_id))
             elif video_url.startswith('rtmp'):
                 formats.append({
                     'url': video_url,
@@ -262,18 +261,16 @@ class CultureboxIE(FranceTVBaseInfoExtractor):
 
     _TEST = {
         'url': 'http://culturebox.francetvinfo.fr/live/musique/musique-classique/le-livre-vermeil-de-montserrat-a-la-cathedrale-delne-214511',
+        'md5': '9b88dc156781c4dbebd4c3e066e0b1d6',
         'info_dict': {
             'id': 'EV_50111',
-            'ext': 'mp4',
+            'ext': 'flv',
             'title': "Le Livre Vermeil de Montserrat à la Cathédrale d'Elne",
             'description': 'md5:f8a4ad202e8fe533e2c493cc12e739d9',
             'upload_date': '20150320',
             'timestamp': 1426892400,
             'duration': 2760.9,
         },
-        'params': {
-            'skip_download': True,
-        },
     }
 
     def _real_extract(self, url):