2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
7 from ..compat
import compat_str
18 class WatchBoxIE(InfoExtractor
):
19 _VALID_URL
= r
'https?://(?:www\.)?watchbox\.de/(?P<kind>serien|filme)/(?:[^/]+/)*[^/]+-(?P<id>\d+)'
22 'url': 'https://www.watchbox.de/filme/free-jimmy-12325.html',
26 'title': 'Free Jimmy',
27 'description': 'md5:bcd8bafbbf9dc0ef98063d344d7cc5f6',
28 'thumbnail': r
're:^https?://.*\.jpg$',
34 'format': 'bestvideo',
35 'skip_download': True,
37 'expected_warnings': ['Failed to download m3u8 information'],
40 'url': 'https://www.watchbox.de/serien/ugly-americans-12231/staffel-1/date-in-der-hoelle-328286.html',
44 'title': 'S01 E01 - Date in der Hölle',
45 'description': 'md5:2f31c74a8186899f33cb5114491dae2b',
46 'thumbnail': r
're:^https?://.*\.jpg$',
50 'series': 'Ugly Americans',
52 'episode': 'Date in der Hölle',
56 'format': 'bestvideo',
57 'skip_download': True,
59 'expected_warnings': ['Failed to download m3u8 information'],
61 'url': 'https://www.watchbox.de/serien/ugly-americans-12231/staffel-2/der-ring-des-powers-328270',
62 'only_matching': True,
65 def _real_extract(self
, url
):
66 mobj
= re
.match(self
._VALID
_URL
, url
)
67 kind
, video_id
= mobj
.group('kind', 'id')
69 webpage
= self
._download
_webpage
(url
, video_id
)
71 player_config
= self
._parse
_json
(
73 r
'data-player-conf=(["\'])(?P
<data
>{.+?
})\
1', webpage,
74 'player config
', default='{}', group='data
'),
75 video_id, transform_source=unescapeHTML, fatal=False)
78 player_config = self._parse_json(
80 r'playerConf\s
*=\s
*({.+?
})\s
*;', webpage, 'player config
',
82 video_id, transform_source=js_to_json, fatal=False) or {}
84 source = player_config.get('source
') or {}
86 video_id = compat_str(source.get('videoId
') or video_id)
88 devapi = self._download_json(
89 'http
://api
.watchbox
.de
/devapi
/id/%s' % video_id, video_id, query={
94 item = try_get(devapi, lambda x: x['items
'][0], dict) or {}
96 title = item.get('title
') or try_get(
97 item, lambda x: x['movie
']['headline_movie
'],
98 compat_str) or source['title
']
101 hls_url = item.get('media_videourl_hls
') or source.get('hls
')
103 formats.extend(self._extract_m3u8_formats(
104 hls_url, video_id, 'mp4
', entry_protocol='m3u8_native
',
105 m3u8_id='hls
', fatal=False))
106 dash_url = item.get('media_videourl_wv
') or source.get('dash
')
108 formats.extend(self._extract_mpd_formats(
109 dash_url, video_id, mpd_id='dash
', fatal=False))
110 mp4_url = item.get('media_videourl
')
115 'width
': int_or_none(item.get('width
')),
116 'height
': int_or_none(item.get('height
')),
117 'tbr
': int_or_none(item.get('bitrate
')),
119 self._sort_formats(formats)
121 description = strip_or_none(item.get('descr
'))
122 thumbnail = item.get('media_content_thumbnail_large
') or source.get('poster
') or item.get('media_thumbnail
')
123 duration = int_or_none(item.get('media_length
') or source.get('length
'))
124 timestamp = unified_timestamp(item.get('pubDate
'))
125 view_count = int_or_none(item.get('media_views
'))
126 age_limit = int_or_none(try_get(item, lambda x: x['movie
']['fsk
']))
127 release_year = int_or_none(try_get(item, lambda x: x['movie
']['rel_year
']))
132 'description
': description,
133 'thumbnail
': thumbnail,
134 'duration
': duration,
135 'timestamp
': timestamp,
136 'view_count
': view_count,
137 'age_limit
': age_limit,
138 'release_year
': release_year,
142 if kind.lower() == 'serien
':
144 item, lambda x: x['special
']['title
'],
145 compat_str) or source.get('format
')
146 season_number = int_or_none(self._search_regex(
147 r'^
S(\d
{1,2})\s
*E\d
{1,2}', title, 'season number
',
148 default=None) or self._search_regex(
149 r'/staffel
-(\d
+)/', url, 'season number
', default=None))
150 episode = source.get('title
')
151 episode_number = int_or_none(self._search_regex(
152 r'^S\d
{1,2}\s
*E(\d
{1,2})', title, 'episode number
',
156 'season_number
': season_number,
158 'episode_number
': episode_number,