]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/watchbox.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
7 from ..compat
import compat_str
17 class WatchBoxIE(InfoExtractor
):
18 _VALID_URL
= r
'https?://(?:www\.)?watchbox\.de/(?P<kind>serien|filme)/(?:[^/]+/)*[^/]+-(?P<id>\d+)'
21 'url': 'https://www.watchbox.de/filme/free-jimmy-12325.html',
25 'title': 'Free Jimmy',
26 'description': 'md5:bcd8bafbbf9dc0ef98063d344d7cc5f6',
27 'thumbnail': r
're:^https?://.*\.jpg$',
33 'format': 'bestvideo',
34 'skip_download': True,
36 'expected_warnings': ['Failed to download m3u8 information'],
39 'url': 'https://www.watchbox.de/serien/ugly-americans-12231/staffel-1/date-in-der-hoelle-328286.html',
43 'title': 'S01 E01 - Date in der Hölle',
44 'description': 'md5:2f31c74a8186899f33cb5114491dae2b',
45 'thumbnail': r
're:^https?://.*\.jpg$',
49 'series': 'Ugly Americans',
51 'episode': 'Date in der Hölle',
55 'format': 'bestvideo',
56 'skip_download': True,
58 'expected_warnings': ['Failed to download m3u8 information'],
60 'url': 'https://www.watchbox.de/serien/ugly-americans-12231/staffel-2/der-ring-des-powers-328270',
61 'only_matching': True,
64 def _real_extract(self
, url
):
65 mobj
= re
.match(self
._VALID
_URL
, url
)
66 kind
, video_id
= mobj
.group('kind', 'id')
68 webpage
= self
._download
_webpage
(url
, video_id
)
70 source
= self
._parse
_json
(
72 r
'(?s)source\s*:\s*({.+?})\s*,\s*\n', webpage
, 'source',
74 video_id
, transform_source
=js_to_json
, fatal
=False) or {}
76 video_id
= compat_str(source
.get('videoId') or video_id
)
78 devapi
= self
._download
_json
(
79 'http://api.watchbox.de/devapi/id/%s' % video_id
, video_id
, query
={
84 item
= try_get(devapi
, lambda x
: x
['items'][0], dict) or {}
86 title
= item
.get('title') or try_get(
87 item
, lambda x
: x
['movie']['headline_movie'],
88 compat_str
) or source
['title']
91 hls_url
= item
.get('media_videourl_hls') or source
.get('hls')
93 formats
.extend(self
._extract
_m
3u8_formats
(
94 hls_url
, video_id
, 'mp4', entry_protocol
='m3u8_native',
95 m3u8_id
='hls', fatal
=False))
96 dash_url
= item
.get('media_videourl_wv') or source
.get('dash')
98 formats
.extend(self
._extract
_mpd
_formats
(
99 dash_url
, video_id
, mpd_id
='dash', fatal
=False))
100 mp4_url
= item
.get('media_videourl')
105 'width': int_or_none(item
.get('width')),
106 'height': int_or_none(item
.get('height')),
107 'tbr': int_or_none(item
.get('bitrate')),
109 self
._sort
_formats
(formats
)
111 description
= strip_or_none(item
.get('descr'))
112 thumbnail
= item
.get('media_content_thumbnail_large') or source
.get('poster') or item
.get('media_thumbnail')
113 duration
= int_or_none(item
.get('media_length') or source
.get('length'))
114 timestamp
= unified_timestamp(item
.get('pubDate'))
115 view_count
= int_or_none(item
.get('media_views'))
116 age_limit
= int_or_none(try_get(item
, lambda x
: x
['movie']['fsk']))
117 release_year
= int_or_none(try_get(item
, lambda x
: x
['movie']['rel_year']))
122 'description': description
,
123 'thumbnail': thumbnail
,
124 'duration': duration
,
125 'timestamp': timestamp
,
126 'view_count': view_count
,
127 'age_limit': age_limit
,
128 'release_year': release_year
,
132 if kind
.lower() == 'serien':
134 item
, lambda x
: x
['special']['title'],
135 compat_str
) or source
.get('format')
136 season_number
= int_or_none(self
._search
_regex
(
137 r
'^S(\d{1,2})\s*E\d{1,2}', title
, 'season number',
138 default
=None) or self
._search
_regex
(
139 r
'/staffel-(\d+)/', url
, 'season number', default
=None))
140 episode
= source
.get('title')
141 episode_number
= int_or_none(self
._search
_regex
(
142 r
'^S\d{1,2}\s*E(\d{1,2})', title
, 'episode number',
146 'season_number': season_number
,
148 'episode_number': episode_number
,