[zattoo] Add support for ondemand.

This commit is contained in:
Alexander Seiler 2019-01-03 16:48:27 +01:00
parent 751e051557
commit 8c4c6efafe
2 changed files with 46 additions and 4 deletions

View File

@ -1491,6 +1491,7 @@ from .zattoo import (
WalyTVIE,
ZattooIE,
ZattooLiveIE,
ZattooOndemandIE
)
from .zdf import ZDFIE, ZDFChannelIE
from .zingmp3 import ZingMp3IE

View File

@ -121,7 +121,28 @@ class ZattooPlatformBaseIE(InfoExtractor):
return cid, info_dict
def _extract_formats(self, cid, video_id, record_id=None, is_live=False):
def _extract_vod_video_info(self, vod_id):
data = self._download_json(
'%s/zapi/avod/videos/%s' % (self._host_url(), vod_id),
vod_id,
'Downloading video information',
)
info_dict = {
'id': vod_id,
'title': data['title'],
'alt_title': data.get('subtitle'),
'description': data.get('description'),
'duration': int_or_none(data.get('duration')),
'episode_number': int_or_none(data.get('episode_number')),
'season_number': int_or_none(data.get('season_number')),
'release_year': int_or_none(data.get('year')),
'categories': try_get(data, lambda x: x['categories'], list),
'tags': try_get(data, lambda x: x['genres'], list),
}
return info_dict
def _extract_formats(self, cid, video_id, record_id=None, vod_id=None, is_live=False):
postdata_common = {
'https_watch_urls': True,
}
@ -131,6 +152,8 @@ class ZattooPlatformBaseIE(InfoExtractor):
url = '%s/zapi/watch/live/%s' % (self._host_url(), cid)
elif record_id:
url = '%s/zapi/watch/recording/%s' % (self._host_url(), record_id)
elif vod_id:
url = '%s/zapi/avod/videos/%s/watch' % (self._host_url(), vod_id)
else:
url = '%s/zapi/watch/recall/%s/%s' % (self._host_url(), cid, video_id)
@ -187,7 +210,7 @@ class ZattooPlatformBaseIE(InfoExtractor):
self._sort_formats(formats)
return formats
def _extract_video(self, channel_name, video_id, record_id=None, is_live=False):
def _extract_video(self, channel_name, video_id, record_id=None, vod_id=None, is_live=False):
if is_live:
cid = self._extract_cid(video_id, channel_name)
info_dict = {
@ -195,10 +218,14 @@ class ZattooPlatformBaseIE(InfoExtractor):
'title': self._live_title(channel_name),
'is_live': True,
}
else:
if vod_id:
info_dict = self._extract_vod_video_info(vod_id)
cid = None
else:
cid, info_dict = self._extract_cid_and_video_info(video_id)
formats = self._extract_formats(
cid, video_id, record_id=record_id, is_live=is_live)
cid, video_id, record_id=record_id, vod_id=vod_id, is_live=is_live)
info_dict['formats'] = formats
return info_dict
@ -266,6 +293,20 @@ class ZattooIE(ZattooBaseIE):
return self._extract_video(channel_name, video_id, record_id)
class ZattooOndemandIE(ZattooBaseIE):
_VALID_URL_TEMPLATE = r'https?://(?:www\.)?%s/ondemand/watch/(?P<id>[a-zA-Z0-9]+)[^/]+'
_VALID_URL = _make_valid_url(_VALID_URL_TEMPLATE, ZattooBaseIE._HOST)
_TEST = {
'url': 'https://zattoo.com/ondemand/watch/Xd2TtUBjYDj1F6tF8Nmkhpq4-galileo',
'only_matching': True,
}
def _real_extract(self, url):
vod_id = self._match_id(url)
return self._extract_video(None, vod_id, vod_id=vod_id)
class ZattooLiveIE(ZattooBaseIE):
_VALID_URL = r'https?://(?:www\.)?zattoo\.com/watch/(?P<id>[^/]+)'