3 from .common
import InfoExtractor
12 class WWEBaseIE(InfoExtractor
):
18 def _extract_entry(self
, data
, url
, video_id
=None):
19 video_id
= str(video_id
or data
['nid'])
22 formats
= self
._extract
_m
3u8_formats
(
23 data
['file'], video_id
, 'mp4', entry_protocol
='m3u8_native',
26 description
= data
.get('description')
27 thumbnail
= urljoin(url
, data
.get('image'))
28 series
= data
.get('show_name')
29 episode
= data
.get('episode_name')
32 tracks
= data
.get('tracks')
33 if isinstance(tracks
, list):
35 if not isinstance(track
, dict):
37 if track
.get('kind') != 'captions':
39 track_file
= url_or_none(track
.get('file'))
42 label
= track
.get('label')
43 lang
= self
._SUBTITLE
_LANGS
.get(label
, label
) or 'en'
44 subtitles
.setdefault(lang
, []).append({
51 'description': description
,
52 'thumbnail': thumbnail
,
56 'subtitles': subtitles
,
60 class WWEIE(WWEBaseIE
):
61 _VALID_URL
= r
'https?://(?:[^/]+\.)?wwe\.com/(?:[^/]+/)*videos/(?P<id>[^/?#&]+)'
63 'url': 'https://www.wwe.com/videos/daniel-bryan-vs-andrade-cien-almas-smackdown-live-sept-4-2018',
64 'md5': '92811c6a14bfc206f7a6a9c5d9140184',
68 'title': 'Daniel Bryan vs. Andrade "Cien" Almas: SmackDown LIVE, Sept. 4, 2018',
69 'description': 'md5:2d7424dbc6755c61a0e649d2a8677f67',
70 'thumbnail': r
're:^https?://.*\.jpg$',
73 'url': 'https://de.wwe.com/videos/gran-metalik-vs-tony-nese-wwe-205-live-sept-4-2018',
74 'only_matching': True,
77 def _real_extract(self
, url
):
78 display_id
= self
._match
_id
(url
)
79 webpage
= self
._download
_webpage
(url
, display_id
)
81 landing
= self
._parse
_json
(
82 self
._html
_search
_regex
(
83 r
'(?s)Drupal\.settings\s*,\s*({.+?})\s*\)\s*;',
84 webpage
, 'drupal settings'),
85 display_id
)['WWEVideoLanding']
87 data
= landing
['initialVideo']['playlist'][0]
88 video_id
= landing
.get('initialVideoId')
90 info
= self
._extract
_entry
(data
, url
, video_id
)
91 info
['display_id'] = display_id
95 class WWEPlaylistIE(WWEBaseIE
):
96 _VALID_URL
= r
'https?://(?:[^/]+\.)?wwe\.com/(?:[^/]+/)*(?P<id>[^/?#&]+)'
98 'url': 'https://www.wwe.com/shows/raw/2018-11-12',
102 'playlist_mincount': 11,
104 'url': 'http://www.wwe.com/article/walk-the-prank-wwe-edition',
105 'only_matching': True,
107 'url': 'https://www.wwe.com/shows/wwenxt/article/matt-riddle-interview',
108 'only_matching': True,
112 def suitable(cls
, url
):
113 return False if WWEIE
.suitable(url
) else super().suitable(url
)
115 def _real_extract(self
, url
):
116 display_id
= self
._match
_id
(url
)
117 webpage
= self
._download
_webpage
(url
, display_id
)
120 for mobj
in re
.finditer(
121 r
'data-video\s*=\s*(["\'])(?P
<data
>{.+?
})\
1', webpage):
122 video = self._parse_json(
123 mobj.group('data
'), display_id, transform_source=unescapeHTML,
127 data = try_get(video, lambda x: x['playlist
'][0], dict)
131 entry = self._extract_entry(data, url)
134 entry['extractor_key
'] = WWEIE.ie_key()
135 entries.append(entry)
137 return self.playlist_result(entries, display_id)