diff --git a/test/test_utils.py b/test/test_utils.py index 2f8996d7bb..3fba8ae11c 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -246,6 +246,7 @@ def test_parse_duration(self): self.assertEqual(parse_duration('2.5 hours'), 9000) self.assertEqual(parse_duration('02:03:04'), 7384) self.assertEqual(parse_duration('01:02:03:04'), 93784) + self.assertEqual(parse_duration('1 hour 3 minutes'), 3780) def test_fix_xml_ampersands(self): self.assertEqual( diff --git a/youtube_dl/extractor/airmozilla.py b/youtube_dl/extractor/airmozilla.py index 44c20f8861..611ad1e9d4 100644 --- a/youtube_dl/extractor/airmozilla.py +++ b/youtube_dl/extractor/airmozilla.py @@ -4,7 +4,11 @@ import re from .common import InfoExtractor -from ..utils import parse_iso8601 +from ..utils import ( + int_or_none, + parse_duration, + parse_iso8601, +) class AirMozillaIE(InfoExtractor): @@ -27,13 +31,6 @@ class AirMozillaIE(InfoExtractor): } } - _QUALITY_MAP = { - '360p': 0, - '576p': 1, - '640p': 2, - '720p': 3, - } - def _real_extract(self, url): display_id = self._match_id(url) webpage = self._download_webpage(url, display_id) @@ -43,19 +40,23 @@ def _real_extract(self, url): jwconfig = self._search_regex(r'\svar jwconfig = (\{.*?\});\s', embed_script, 'metadata') metadata = self._parse_json(jwconfig, video_id) - formats = [] - for source in metadata['playlist'][0]['sources']: - fmt = { - 'url': source['file'], - 'ext': source['type'], - 'format_id': self._search_regex(r'&format=(.*)$', source['file'], 'video format'), - 'resolution': source['label'], - 'quality': self._QUALITY_MAP.get(source['label'], -1), - } - formats.append(fmt) + formats = [{ + 'url': source['file'], + 'ext': source['type'], + 'format_id': self._search_regex(r'&format=(.*)$', source['file'], 'video format'), + 'format': source['label'], + 'height': int(source['label'].rstrip('p')), + } for source in metadata['playlist'][0]['sources']] self._sort_formats(formats) - duration_match = re.search(r'Duration:(?: (?P\d+) hours?)?(?: (?P\d+) minutes?)?', webpage) + view_count = int_or_none(self._html_search_regex( + r'Views since archived: ([0-9]+)', + webpage, 'view count', fatal=False)) + timestamp = parse_iso8601(self._html_search_regex( + r'