2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
14 class ATVAtIE(InfoExtractor
):
15 _VALID_URL
= r
'https?://(?:www\.)?atv\.at/tv/(?:[^/]+/){2,3}(?P<id>.*)'
18 'url': 'https://www.atv.at/tv/bauer-sucht-frau/staffel-18/bauer-sucht-frau/bauer-sucht-frau-staffel-18-folge-3-die-hofwochen',
19 'md5': '3c3b4aaca9f63e32b35e04a9c2515903',
21 'id': 'v-ce9cgn1e70n5-1',
23 'title': 'Bauer sucht Frau - Staffel 18 Folge 3 - Die Hofwochen',
26 'url': 'https://www.atv.at/tv/bauer-sucht-frau/staffel-18/episode-01/bauer-sucht-frau-staffel-18-vorstellungsfolge-1',
27 'only_matching': True,
30 # extracted from bootstrap.js function (search for e.encryption_key and use your browser's debugger)
32 _ENCRYPTION_KEY
= 'Hohnaekeishoogh2omaeghooquooshia'
34 def _extract_video_info(self
, url
, content
, video
):
35 clip_id
= content
.get('splitId', content
['id'])
37 clip_urls
= video
['urls']
38 for protocol
, variant
in clip_urls
.items():
39 source_url
= try_get(variant
, lambda x
: x
['clear']['url'])
42 if protocol
== 'dash':
43 formats
.extend(self
._extract
_mpd
_formats
(
44 source_url
, clip_id
, mpd_id
=protocol
, fatal
=False))
45 elif protocol
== 'hls':
46 formats
.extend(self
._extract
_m
3u8_formats
(
47 source_url
, clip_id
, 'mp4', 'm3u8_native',
48 m3u8_id
=protocol
, fatal
=False))
52 'format_id': protocol
,
54 self
._sort
_formats
(formats
)
58 'title': content
.get('title'),
59 'duration': float_or_none(content
.get('duration')),
60 'series': content
.get('tvShowTitle'),
64 def _real_extract(self
, url
):
65 video_id
= self
._match
_id
(url
)
66 webpage
= self
._download
_webpage
(url
, video_id
)
67 json_data
= self
._parse
_json
(
68 self
._search
_regex
(r
'<script id="state" type="text/plain">(.*)</script>', webpage
, 'json_data'),
71 video_title
= json_data
['views']['default']['page']['title']
72 contentResource
= json_data
['views']['default']['page']['contentResource']
73 content_id
= contentResource
[0]['id']
74 content_ids
= [{'id': id, 'subclip_start': content['start'], 'subclip_end': content['end']}
75 for id, content
in enumerate(contentResource
)]
77 time_of_request
= datetime
.datetime
.now()
78 not_before
= time_of_request
- datetime
.timedelta(minutes
=5)
79 expire
= time_of_request
+ datetime
.timedelta(minutes
=5)
82 content_id
: content_ids
,
84 'secure_delivery': True,
85 'iat': int(time_of_request
.timestamp()),
86 'nbf': int(not_before
.timestamp()),
87 'exp': int(expire
.timestamp()),
89 jwt_token
= jwt_encode_hs256(payload
, self
._ENCRYPTION
_KEY
, headers
={'kid': self._ACCESS_ID}
)
90 videos
= self
._download
_json
(
91 'https://vas-v4.p7s1video.net/4.0/getsources',
92 content_id
, 'Downloading videos JSON', query
={
93 'token': jwt_token
.decode('utf-8')
96 video_id
, videos_data
= list(videos
['data'].items())[0]
98 self
._extract
_video
_info
(url
, contentResource
[video
['id']], video
)
99 for video
in videos_data
]
102 '_type': 'multi_video',
104 'title': video_title
,