]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/njpwworld.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
7 from ..compat
import compat_urlparse
15 class NJPWWorldIE(InfoExtractor
):
16 _VALID_URL
= r
'https?://njpwworld\.com/p/(?P<id>[a-z0-9_]+)'
17 IE_DESC
= '新日本プロレスワールド'
18 _NETRC_MACHINE
= 'njpwworld'
21 'url': 'http://njpwworld.com/p/s_series_00155_1_9/',
23 'id': 's_series_00155_1_9',
25 'title': '第9試合 ランディ・サベージ vs リック・スタイナー',
29 'skip_download': True, # AES-encrypted m3u8
31 'skip': 'Requires login',
34 def _real_initialize(self
):
38 username
, password
= self
._get
_login
_info
()
39 # No authentication to be performed
43 webpage
, urlh
= self
._download
_webpage
_handle
(
44 'https://njpwworld.com/auth/login', None,
45 note
='Logging in', errnote
='Unable to login',
46 data
=urlencode_postdata({'login_id': username
, 'pw': password
}))
47 # /auth/login will return 302 for successful logins
48 if urlh
.geturl() == 'https://njpwworld.com/auth/login':
49 self
.report_warning('unable to login')
54 def _real_extract(self
, url
):
55 video_id
= self
._match
_id
(url
)
57 webpage
= self
._download
_webpage
(url
, video_id
)
60 for mobj
in re
.finditer(r
'<a[^>]+\bhref=(["\'])/player
.+?
[^
>]*>', webpage):
61 player = extract_attributes(mobj.group(0))
62 player_path = player.get('href
')
65 kind = self._search_regex(
66 r'(low|high
)$
', player.get('class') or '', 'kind
',
68 player_url = compat_urlparse.urljoin(url, player_path)
69 player_page = self._download_webpage(
70 player_url, video_id, note='Downloading player page
')
71 entries = self._parse_html5_media_entries(
72 player_url, player_page, video_id, m3u8_id='hls
-%s' % kind,
73 m3u8_entry_protocol='m3u8_native
')
74 kind_formats = entries[0]['formats
']
75 for f in kind_formats:
76 f['quality
'] = 2 if kind == 'high
' else 1
77 formats.extend(kind_formats)
79 self._sort_formats(formats)
81 post_content = get_element_by_class('post
-content
', webpage)
83 r'<li
[^
>]+class="tag-[^"]+"><a[^>]*>([^<]+)</a></li>', post_content
84 ) if post_content else None
88 'title': self._og_search_title(webpage),