]> jfr.im git - yt-dlp.git/blobdiff - yt_dlp/extractor/ccma.py
[cleanup] Add more ruff rules (#10149)
[yt-dlp.git] / yt_dlp / extractor / ccma.py
index ea98f8688ea7216260f779bada1417e4a99999b2..ffe4b49c15d95cfbd22130e87fcd055e2b1684ae 100644 (file)
@@ -1,17 +1,12 @@
-# coding: utf-8
-from __future__ import unicode_literals
-
-import calendar
-import datetime
-
 from .common import InfoExtractor
 from ..utils import (
     clean_html,
-    extract_timezone,
+    determine_ext,
     int_or_none,
     parse_duration,
     parse_resolution,
     try_get,
+    unified_timestamp,
     url_or_none,
 )
 
@@ -29,7 +24,7 @@ class CCMAIE(InfoExtractor):
             'timestamp': 1478608140,
             'upload_date': '20161108',
             'age_limit': 0,
-        }
+        },
     }, {
         'url': 'http://www.ccma.cat/catradio/alacarta/programa/el-consell-de-savis-analitza-el-derbi/audio/943685/',
         'md5': 'fa3e38f269329a278271276330261425',
@@ -42,7 +37,7 @@ class CCMAIE(InfoExtractor):
             'timestamp': 1494622500,
             'vcodec': 'none',
             'categories': ['Esports'],
-        }
+        },
     }, {
         'url': 'http://www.ccma.cat/tv3/alacarta/crims/crims-josep-tallada-lespereu-me-capitol-1/video/6031387/',
         'md5': 'b43c3d3486f430f3032b5b160d80cbc3',
@@ -56,7 +51,7 @@ class CCMAIE(InfoExtractor):
             'subtitles': 'mincount:4',
             'age_limit': 16,
             'series': 'Crims',
-        }
+        },
     }]
 
     def _real_extract(self, url):
@@ -66,6 +61,7 @@ def _real_extract(self, url):
             'http://dinamics.ccma.cat/pvideo/media.jsp', media_id, query={
                 'media': media_type,
                 'idint': media_id,
+                'format': 'dm',
             })
 
         formats = []
@@ -75,6 +71,10 @@ def _real_extract(self, url):
                 format_url = url_or_none(format_.get('file'))
                 if not format_url:
                     continue
+                if determine_ext(format_url) == 'mpd':
+                    formats.extend(self._extract_mpd_formats(
+                        format_url, media_id, mpd_id='dash', fatal=False))
+                    continue
                 label = format_.get('label')
                 f = parse_resolution(label)
                 f.update({
@@ -87,7 +87,6 @@ def _real_extract(self, url):
                 'url': media_url,
                 'vcodec': 'none' if media_type == 'audio' else None,
             })
-        self._sort_formats(formats)
 
         informacio = media['informacio']
         title = informacio['titol']
@@ -95,14 +94,8 @@ def _real_extract(self, url):
         duration = int_or_none(durada.get('milisegons'), 1000) or parse_duration(durada.get('text'))
         tematica = try_get(informacio, lambda x: x['tematica']['text'])
 
-        timestamp = None
         data_utc = try_get(informacio, lambda x: x['data_emissio']['utc'])
-        try:
-            timezone, data_utc = extract_timezone(data_utc)
-            timestamp = calendar.timegm((datetime.datetime.strptime(
-                data_utc, '%Y-%d-%mT%H:%M:%S') - timezone).timetuple())
-        except TypeError:
-            pass
+        timestamp = unified_timestamp(data_utc)
 
         subtitles = {}
         subtitols = media.get('subtitols') or []