2 from __future__ import unicode_literals
4 from .common import InfoExtractor
5 from ..utils import int_or_none
8 class TV2HuIE(InfoExtractor):
10 _VALID_URL = r'https?://(?:www\.)?tv2\.hu/(?:[^/]+/)+(?P<id>\d+)_[^/?#]+?\.html'
12 'url': 'http://tv2.hu/ezek_megorultek/217679_ezek-megorultek---1.-adas-1.-resz.html',
13 'md5': '585e58e2e090f34603804bb2c48e98d8',
17 'title': 'Ezek megőrültek! - 1. adás 1. rész',
18 'upload_date': '20160826',
19 'thumbnail': r're:^https?://.*\.jpg$'
22 'url': 'http://tv2.hu/ezek_megorultek/teljes_adasok/217677_ezek-megorultek---1.-adas-2.-resz.html',
25 'url': 'http://tv2.hu/musoraink/aktiv/aktiv_teljes_adas/217963_aktiv-teljes-adas---2016.08.30..html',
29 def _real_extract(self, url):
30 video_id = self._match_id(url)
31 webpage = self._download_webpage(url, video_id)
32 json_url = self._search_regex(
33 r'jsonUrl\s*=\s*"([^"]+)"', webpage, 'json url')
34 json_data = self._download_json(json_url, video_id)
37 for b in ('bitrates', 'backupBitrates'):
38 bitrates = json_data.get(b, {})
39 m3u8_url = bitrates.get('hls')
41 formats.extend(self._extract_wowza_formats(
42 m3u8_url, video_id, skip_protocols=['rtmp', 'rtsp']))
44 for mp4_url in bitrates.get('mp4', []):
45 height = int_or_none(self._search_regex(
46 r'\.(\d+)p\.mp4', mp4_url, 'height', default=None))
48 'format_id': 'http' + ('-%d' % height if height else ''),
51 'width': int_or_none(height / 9.0 * 16.0 if height else None),
53 self._sort_formats(formats)
57 'title': self._og_search_title(webpage).strip(),
58 'thumbnail': self._og_search_thumbnail(webpage),
59 'upload_date': self._search_regex(
60 r'/vod/(\d{8})/', json_url, 'upload_date', default=None),