3 from .common
import InfoExtractor
4 from ..compat
import compat_str
13 class WWEBaseIE(InfoExtractor
):
19 def _extract_entry(self
, data
, url
, video_id
=None):
20 video_id
= compat_str(video_id
or data
['nid'])
23 formats
= self
._extract
_m
3u8_formats
(
24 data
['file'], video_id
, 'mp4', entry_protocol
='m3u8_native',
27 description
= data
.get('description')
28 thumbnail
= urljoin(url
, data
.get('image'))
29 series
= data
.get('show_name')
30 episode
= data
.get('episode_name')
33 tracks
= data
.get('tracks')
34 if isinstance(tracks
, list):
36 if not isinstance(track
, dict):
38 if track
.get('kind') != 'captions':
40 track_file
= url_or_none(track
.get('file'))
43 label
= track
.get('label')
44 lang
= self
._SUBTITLE
_LANGS
.get(label
, label
) or 'en'
45 subtitles
.setdefault(lang
, []).append({
52 'description': description
,
53 'thumbnail': thumbnail
,
57 'subtitles': subtitles
,
61 class WWEIE(WWEBaseIE
):
62 _VALID_URL
= r
'https?://(?:[^/]+\.)?wwe\.com/(?:[^/]+/)*videos/(?P<id>[^/?#&]+)'
64 'url': 'https://www.wwe.com/videos/daniel-bryan-vs-andrade-cien-almas-smackdown-live-sept-4-2018',
65 'md5': '92811c6a14bfc206f7a6a9c5d9140184',
69 'title': 'Daniel Bryan vs. Andrade "Cien" Almas: SmackDown LIVE, Sept. 4, 2018',
70 'description': 'md5:2d7424dbc6755c61a0e649d2a8677f67',
71 'thumbnail': r
're:^https?://.*\.jpg$',
74 'url': 'https://de.wwe.com/videos/gran-metalik-vs-tony-nese-wwe-205-live-sept-4-2018',
75 'only_matching': True,
78 def _real_extract(self
, url
):
79 display_id
= self
._match
_id
(url
)
80 webpage
= self
._download
_webpage
(url
, display_id
)
82 landing
= self
._parse
_json
(
83 self
._html
_search
_regex
(
84 r
'(?s)Drupal\.settings\s*,\s*({.+?})\s*\)\s*;',
85 webpage
, 'drupal settings'),
86 display_id
)['WWEVideoLanding']
88 data
= landing
['initialVideo']['playlist'][0]
89 video_id
= landing
.get('initialVideoId')
91 info
= self
._extract
_entry
(data
, url
, video_id
)
92 info
['display_id'] = display_id
96 class WWEPlaylistIE(WWEBaseIE
):
97 _VALID_URL
= r
'https?://(?:[^/]+\.)?wwe\.com/(?:[^/]+/)*(?P<id>[^/?#&]+)'
99 'url': 'https://www.wwe.com/shows/raw/2018-11-12',
103 'playlist_mincount': 11,
105 'url': 'http://www.wwe.com/article/walk-the-prank-wwe-edition',
106 'only_matching': True,
108 'url': 'https://www.wwe.com/shows/wwenxt/article/matt-riddle-interview',
109 'only_matching': True,
113 def suitable(cls
, url
):
114 return False if WWEIE
.suitable(url
) else super(WWEPlaylistIE
, cls
).suitable(url
)
116 def _real_extract(self
, url
):
117 display_id
= self
._match
_id
(url
)
118 webpage
= self
._download
_webpage
(url
, display_id
)
121 for mobj
in re
.finditer(
122 r
'data-video\s*=\s*(["\'])(?P
<data
>{.+?
})\
1', webpage):
123 video = self._parse_json(
124 mobj.group('data
'), display_id, transform_source=unescapeHTML,
128 data = try_get(video, lambda x: x['playlist
'][0], dict)
132 entry = self._extract_entry(data, url)
135 entry['extractor_key
'] = WWEIE.ie_key()
136 entries.append(entry)
138 return self.playlist_result(entries, display_id)