]>
jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/fc2.py
2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
17 class FC2IE(InfoExtractor
):
18 _VALID_URL
= r
'^(?:https?://video\.fc2\.com/(?:[^/]+/)*content/|fc2:)(?P<id>[^/]+)'
20 _NETRC_MACHINE
= 'fc2'
22 'url': 'http://video.fc2.com/en/content/20121103kUan1KHs',
23 'md5': 'a6ebe8ebe0396518689d963774a54eb7',
25 'id': '20121103kUan1KHs',
27 'title': 'Boxing again with Puff',
30 'url': 'http://video.fc2.com/en/content/20150125cEva0hDn/',
32 'id': '20150125cEva0hDn',
36 'username': 'ytdl@yt-dl.org',
39 'skip': 'requires actual password',
41 'url': 'http://video.fc2.com/en/a/content/20130926eZpARwsF',
42 'only_matching': True,
46 username
, password
= self
._get
_login
_info
()
47 if username
is None or password
is None:
58 login_data
= urlencode_postdata(login_form_strs
)
59 request
= sanitized_Request(
60 'https://secure.id.fc2.com/index.php?mode=login&switch_language=en', login_data
)
62 login_results
= self
._download
_webpage
(request
, None, note
='Logging in', errnote
='Unable to log in')
63 if 'mode=redirect&login=done' not in login_results
:
64 self
.report_warning('unable to log in: bad username or password')
68 login_redir
= sanitized_Request('http://id.fc2.com/?mode=redirect&login=done')
69 self
._download
_webpage
(
70 login_redir
, None, note
='Login redirect', errnote
='Login redirect failed')
74 def _real_extract(self
, url
):
75 video_id
= self
._match
_id
(url
)
78 if not url
.startswith('fc2:'):
79 webpage
= self
._download
_webpage
(url
, video_id
)
80 self
._downloader
.cookiejar
.clear_session_cookies() # must clear
83 title
, thumbnail
, description
= None, None, None
84 if webpage
is not None:
85 title
= self
._html
_search
_regex
(
86 (r
'<h2\s+class="videoCnt_title">([^<]+?)</h2>',
87 r
'\s+href="[^"]+"\s*title="([^"]+?)"\s*rel="nofollow">\s*<img',
88 # there's two matches in the webpage
89 r
'\s+href="[^"]+"\s*title="([^"]+?)"\s*rel="nofollow">\s*\1'),
92 thumbnail
= self
._og
_search
_thumbnail
(webpage
)
93 description
= self
._og
_search
_description
(webpage
, default
=None)
95 vidplaylist
= self
._download
_json
(
96 'https://video.fc2.com/api/v3/videoplaylist/%s?sh=1&fs=0' % video_id
, video_id
,
97 note
='Downloading info page')
98 vid_url
= traverse_obj(vidplaylist
, ('playlist', 'nq'))
100 raise ExtractorError('Unable to extract video URL')
101 vid_url
= urljoin('https://video.fc2.com/', vid_url
)
108 'protocol': 'm3u8_native',
109 'description': description
,
110 'thumbnail': thumbnail
,
114 class FC2EmbedIE(InfoExtractor
):
115 _VALID_URL
= r
'https?://video\.fc2\.com/flv2\.swf\?(?P<query>.+)'
116 IE_NAME
= 'fc2:embed'
119 'url': 'http://video.fc2.com/flv2.swf?t=201404182936758512407645&i=20130316kwishtfitaknmcgd76kjd864hso93htfjcnaogz629mcgfs6rbfk0hsycma7shkf85937cbchfygd74&i=201403223kCqB3Ez&d=2625&sj=11&lang=ja&rel=1&from=11&cmt=1&tk=TlRBM09EQTNNekU9&tl=プリズン・ブレイク%20S1-01%20マイケル%20【吹替】',
120 'md5': 'b8aae5334cb691bdb1193a88a6ab5d5a',
122 'id': '201403223kCqB3Ez',
124 'title': 'プリズン・ブレイク S1-01 マイケル 【吹替】',
125 'thumbnail': r
're:^https?://.*\.jpg$',
129 def _real_extract(self
, url
):
130 mobj
= self
._match
_valid
_url
(url
)
131 query
= compat_parse_qs(mobj
.group('query'))
133 video_id
= query
['i'][-1]
134 title
= query
.get('tl', ['FC2 video %s' % video_id
])[0]
136 sj
= query
.get('sj', [None])[0]
139 # See thumbnailImagePath() in ServerConst.as of flv2.swf
140 thumbnail
= 'http://video%s-thumbnail.fc2.com/up/pic/%s.jpg' % (
141 sj
, '/'.join((video_id
[:6], video_id
[6:8], video_id
[-2], video_id
[-1], video_id
)))
144 '_type': 'url_transparent',
145 'ie_key': FC2IE
.ie_key(),
146 'url': 'fc2:%s' % video_id
,
148 'thumbnail': thumbnail
,