3 from .common
import InfoExtractor
8 compat_urllib_parse_urlparse
,
14 class AddAnimeIE(InfoExtractor
):
16 _VALID_URL
= r
'^http://(?:\w+\.)?add-anime\.net/watch_video.php\?(?:.*?)v=(?P<video_id>[\w_]+)(?:.*)'
19 u
'url': u
'http://www.add-anime.net/watch_video.php?v=24MR3YO5SAS9',
20 u
'file': u
'24MR3YO5SAS9.flv',
21 u
'md5': u
'1036a0e0cd307b95bd8a8c3a5c8cfaf1',
23 u
"description": u
"One Piece 606",
24 u
"title": u
"One Piece 606"
28 def _real_extract(self
, url
):
30 mobj
= re
.match(self
._VALID
_URL
, url
)
31 video_id
= mobj
.group('video_id')
32 webpage
= self
._download
_webpage
(url
, video_id
)
33 except ExtractorError
as ee
:
34 if not isinstance(ee
.cause
, compat_HTTPError
):
37 redir_webpage
= ee
.cause
.read().decode('utf-8')
38 action
= self
._search
_regex
(
39 r
'<form id="challenge-form" action="([^"]+)"',
40 redir_webpage
, u
'Redirect form')
41 vc
= self
._search
_regex
(
42 r
'<input type="hidden" name="jschl_vc" value="([^"]+)"/>',
43 redir_webpage
, u
'redirect vc value')
45 r
'a\.value = ([0-9]+)[+]([0-9]+)[*]([0-9]+);',
48 raise ExtractorError(u
'Cannot find redirect math task')
49 av_res
= int(av
.group(1)) + int(av
.group(2)) * int(av
.group(3))
51 parsed_url
= compat_urllib_parse_urlparse(url
)
52 av_val
= av_res
+ len(parsed_url
.netloc
)
54 parsed_url
.scheme
+ u
'://' + parsed_url
.netloc
+
56 compat_urllib_parse
.urlencode({
57 'jschl_vc': vc
, 'jschl_answer': compat_str(av_val
)}))
58 self
._download
_webpage
(
59 confirm_url
, video_id
,
60 note
=u
'Confirming after redirect')
61 webpage
= self
._download
_webpage
(url
, video_id
)
63 video_url
= self
._search
_regex
(r
"var normal_video_file = '(.*?)';",
64 webpage
, u
'video file URL')
65 video_title
= self
._og
_search
_title
(webpage
)
66 video_description
= self
._og
_search
_description
(webpage
)
74 'description': video_description