1 from __future__
import unicode_literals
5 from .common
import InfoExtractor
10 compat_urllib_parse_urlparse
,
18 class AddAnimeIE(InfoExtractor
):
19 _VALID_URL
= r
'http://(?:\w+\.)?add-anime\.net/(?:watch_video\.php\?(?:.*?)v=|video/)(?P<id>[\w_]+)'
21 'url': 'http://www.add-anime.net/watch_video.php?v=24MR3YO5SAS9',
22 'md5': '72954ea10bc979ab5e2eb288b21425a0',
26 'description': 'One Piece 606',
27 'title': 'One Piece 606',
30 'url': 'http://add-anime.net/video/MDUGWYKNGBD8/One-Piece-687',
31 'only_matching': True,
34 def _real_extract(self
, url
):
35 video_id
= self
._match
_id
(url
)
38 webpage
= self
._download
_webpage
(url
, video_id
)
39 except ExtractorError
as ee
:
40 if not isinstance(ee
.cause
, compat_HTTPError
) or \
44 redir_webpage
= ee
.cause
.read().decode('utf-8')
45 action
= self
._search
_regex
(
46 r
'<form id="challenge-form" action="([^"]+)"',
47 redir_webpage
, 'Redirect form')
48 vc
= self
._search
_regex
(
49 r
'<input type="hidden" name="jschl_vc" value="([^"]+)"/>',
50 redir_webpage
, 'redirect vc value')
52 r
'a\.value = ([0-9]+)[+]([0-9]+)[*]([0-9]+);',
55 raise ExtractorError('Cannot find redirect math task')
56 av_res
= int(av
.group(1)) + int(av
.group(2)) * int(av
.group(3))
58 parsed_url
= compat_urllib_parse_urlparse(url
)
59 av_val
= av_res
+ len(parsed_url
.netloc
)
61 parsed_url
.scheme
+ '://' + parsed_url
.netloc
+
63 compat_urllib_parse
.urlencode({
64 'jschl_vc': vc
, 'jschl_answer': compat_str(av_val
)}))
65 self
._download
_webpage
(
66 confirm_url
, video_id
,
67 note
='Confirming after redirect')
68 webpage
= self
._download
_webpage
(url
, video_id
)
70 FORMATS
= ('normal', 'hq')
71 quality
= qualities(FORMATS
)
73 for format_id
in FORMATS
:
74 rex
= r
"var %s_video_file = '(.*?)';" % re
.escape(format_id
)
75 video_url
= self
._search
_regex
(rex
, webpage
, 'video file URLx',
80 'format_id': format_id
,
82 'quality': quality(format_id
),
84 self
._sort
_formats
(formats
)
85 video_title
= self
._og
_search
_title
(webpage
)
86 video_description
= self
._og
_search
_description
(webpage
)
93 'description': video_description