mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-30 12:01:28 +00:00
[TV2Hu] Fix TV2HuIE
and add TV2HuSeriesIE
(#804)
Closes #799 Authored by: Ashish0804
This commit is contained in:
parent
abafce59a1
commit
58f68fe703
|
@ -1440,7 +1440,10 @@
|
|||
TV2DKIE,
|
||||
TV2DKBornholmPlayIE,
|
||||
)
|
||||
from .tv2hu import TV2HuIE
|
||||
from .tv2hu import (
|
||||
TV2HuIE,
|
||||
TV2HuSeriesIE,
|
||||
)
|
||||
from .tv4 import TV4IE
|
||||
from .tv5mondeplus import TV5MondePlusIE
|
||||
from .tv5unis import (
|
||||
|
|
|
@ -2,61 +2,109 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
from .common import InfoExtractor
|
||||
from ..utils import int_or_none
|
||||
from ..utils import (
|
||||
traverse_obj,
|
||||
UnsupportedError,
|
||||
)
|
||||
|
||||
|
||||
class TV2HuIE(InfoExtractor):
|
||||
IE_NAME = 'tv2.hu'
|
||||
_VALID_URL = r'https?://(?:www\.)?tv2\.hu/(?:[^/]+/)+(?P<id>\d+)_[^/?#]+?\.html'
|
||||
IE_NAME = 'tv2play.hu'
|
||||
_VALID_URL = r'https?://(?:www\.)?tv2play\.hu/(?!szalag/)(?P<id>[^#&?]+)'
|
||||
_TESTS = [{
|
||||
'url': 'http://tv2.hu/ezek_megorultek/217679_ezek-megorultek---1.-adas-1.-resz.html',
|
||||
'url': 'https://tv2play.hu/mintaapak/mintaapak_213_epizod_resz',
|
||||
'info_dict': {
|
||||
'id': '249240',
|
||||
'ext': 'mp4',
|
||||
'title': 'Mintaapák - 213. epizód',
|
||||
'series': 'Mintaapák',
|
||||
'duration': 2164,
|
||||
'description': 'md5:7350147e75485a59598e806c47967b07',
|
||||
'thumbnail': r're:^https?://.*\.jpg$',
|
||||
'release_date': '20210825',
|
||||
'season_number': None,
|
||||
'episode_number': 213,
|
||||
},
|
||||
'params': {
|
||||
'skip_download': True,
|
||||
},
|
||||
}, {
|
||||
'url': 'https://tv2play.hu/taxi_2',
|
||||
'md5': '585e58e2e090f34603804bb2c48e98d8',
|
||||
'info_dict': {
|
||||
'id': '217679',
|
||||
'id': '199363',
|
||||
'ext': 'mp4',
|
||||
'title': 'Ezek megőrültek! - 1. adás 1. rész',
|
||||
'upload_date': '20160826',
|
||||
'thumbnail': r're:^https?://.*\.jpg$'
|
||||
}
|
||||
}, {
|
||||
'url': 'http://tv2.hu/ezek_megorultek/teljes_adasok/217677_ezek-megorultek---1.-adas-2.-resz.html',
|
||||
'only_matching': True
|
||||
}, {
|
||||
'url': 'http://tv2.hu/musoraink/aktiv/aktiv_teljes_adas/217963_aktiv-teljes-adas---2016.08.30..html',
|
||||
'only_matching': True
|
||||
'title': 'Taxi 2',
|
||||
'series': 'Taxi 2',
|
||||
'duration': 5087,
|
||||
'description': 'md5:47762155dc9a50241797ded101b1b08c',
|
||||
'thumbnail': r're:^https?://.*\.jpg$',
|
||||
'release_date': '20210118',
|
||||
'season_number': None,
|
||||
'episode_number': None,
|
||||
},
|
||||
'params': {
|
||||
'skip_download': True,
|
||||
},
|
||||
}]
|
||||
|
||||
def _real_extract(self, url):
|
||||
video_id = self._match_id(url)
|
||||
webpage = self._download_webpage(url, video_id)
|
||||
json_url = self._search_regex(
|
||||
r'jsonUrl\s*=\s*"([^"]+)"', webpage, 'json url')
|
||||
json_data = self._download_json(json_url, video_id)
|
||||
id = self._match_id(url)
|
||||
json_data = self._download_json(f'https://tv2play.hu/api/search/{id}', id)
|
||||
|
||||
formats = []
|
||||
for b in ('bitrates', 'backupBitrates'):
|
||||
bitrates = json_data.get(b, {})
|
||||
m3u8_url = bitrates.get('hls')
|
||||
if m3u8_url:
|
||||
formats.extend(self._extract_wowza_formats(
|
||||
m3u8_url, video_id, skip_protocols=['rtmp', 'rtsp']))
|
||||
if json_data['contentType'] == 'showpage':
|
||||
ribbon_ids = traverse_obj(json_data, ('pages', ..., 'tabs', ..., 'ribbonIds'), get_all=False, expected_type=list)
|
||||
entries = [self.url_result(f'https://tv2play.hu/szalag/{ribbon_id}',
|
||||
ie=TV2HuSeriesIE.ie_key(), video_id=ribbon_id) for ribbon_id in ribbon_ids]
|
||||
return self.playlist_result(entries, playlist_id=id)
|
||||
elif json_data['contentType'] != 'video':
|
||||
raise UnsupportedError(url)
|
||||
|
||||
for mp4_url in bitrates.get('mp4', []):
|
||||
height = int_or_none(self._search_regex(
|
||||
r'\.(\d+)p\.mp4', mp4_url, 'height', default=None))
|
||||
formats.append({
|
||||
'format_id': 'http' + ('-%d' % height if height else ''),
|
||||
'url': mp4_url,
|
||||
'height': height,
|
||||
'width': int_or_none(height / 9.0 * 16.0 if height else None),
|
||||
})
|
||||
video_id = str(json_data['id'])
|
||||
player_id = json_data.get('playerId')
|
||||
series_json = json_data.get('seriesInfo', {})
|
||||
|
||||
video_json_url = self._download_json(f'https://tv2play.hu/api/streaming-url?playerId={player_id}', video_id)['url']
|
||||
video_json = self._download_json(video_json_url, video_id)
|
||||
m3u8_url = self._proto_relative_url(traverse_obj(video_json, ('bitrates', 'hls')))
|
||||
formats, subtitles = self._extract_m3u8_formats_and_subtitles(m3u8_url, video_id)
|
||||
self._sort_formats(formats)
|
||||
|
||||
return {
|
||||
'id': video_id,
|
||||
'title': self._og_search_title(webpage).strip(),
|
||||
'thumbnail': self._og_search_thumbnail(webpage),
|
||||
'upload_date': self._search_regex(
|
||||
r'/vod/(\d{8})/', json_url, 'upload_date', default=None),
|
||||
'title': json_data['title'],
|
||||
'series': json_data.get('seriesTitle'),
|
||||
'duration': json_data.get('length'),
|
||||
'description': json_data.get('description'),
|
||||
'thumbnail': 'https://tv2play.hu' + json_data.get('thumbnailUrl'),
|
||||
'release_date': json_data.get('uploadedAt').replace('.', ''),
|
||||
'season_number': series_json.get('seasonNr'),
|
||||
'episode_number': series_json.get('episodeNr'),
|
||||
'formats': formats,
|
||||
'subtitles': subtitles,
|
||||
}
|
||||
|
||||
|
||||
class TV2HuSeriesIE(InfoExtractor):
|
||||
IE_NAME = 'tv2playseries.hu'
|
||||
_VALID_URL = r'https?://(?:www\.)?tv2play\.hu/szalag/(?P<id>[^#&?]+)'
|
||||
|
||||
_TESTS = [{
|
||||
'url': 'https://tv2play.hu/szalag/59?rendezes=nepszeruseg',
|
||||
'playlist_mincount': 284,
|
||||
'info_dict': {
|
||||
'id': '59',
|
||||
}
|
||||
}]
|
||||
|
||||
def _real_extract(self, url):
|
||||
id = self._match_id(url)
|
||||
json_data = self._download_json(f'https://tv2play.hu/api/ribbons/{id}/0?size=100000', id)
|
||||
entries = []
|
||||
for card in json_data.get('cards', []):
|
||||
video_id = card.get('slug')
|
||||
if video_id:
|
||||
entries.append(self.url_result(f'https://tv2play.hu/{video_id}',
|
||||
ie=TV2HuIE.ie_key(), video_id=video_id))
|
||||
|
||||
return self.playlist_result(entries, playlist_id=id)
|
||||
|
|
Loading…
Reference in a new issue