[addanime] Modernize
This commit is contained in:
parent
510243ba58
commit
f847ca02d3
1 changed files with 16 additions and 15 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
|
@ -14,14 +16,14 @@ from ..utils import (
|
||||||
class AddAnimeIE(InfoExtractor):
|
class AddAnimeIE(InfoExtractor):
|
||||||
|
|
||||||
_VALID_URL = r'^http://(?:\w+\.)?add-anime\.net/watch_video\.php\?(?:.*?)v=(?P<video_id>[\w_]+)(?:.*)'
|
_VALID_URL = r'^http://(?:\w+\.)?add-anime\.net/watch_video\.php\?(?:.*?)v=(?P<video_id>[\w_]+)(?:.*)'
|
||||||
IE_NAME = u'AddAnime'
|
|
||||||
_TEST = {
|
_TEST = {
|
||||||
u'url': u'http://www.add-anime.net/watch_video.php?v=24MR3YO5SAS9',
|
'url': 'http://www.add-anime.net/watch_video.php?v=24MR3YO5SAS9',
|
||||||
u'file': u'24MR3YO5SAS9.mp4',
|
'md5': '72954ea10bc979ab5e2eb288b21425a0',
|
||||||
u'md5': u'72954ea10bc979ab5e2eb288b21425a0',
|
'info_dict': {
|
||||||
u'info_dict': {
|
'id': '24MR3YO5SAS9',
|
||||||
u"description": u"One Piece 606",
|
'ext': 'mp4',
|
||||||
u"title": u"One Piece 606"
|
'description': 'One Piece 606',
|
||||||
|
'title': 'One Piece 606',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,10 +40,10 @@ class AddAnimeIE(InfoExtractor):
|
||||||
redir_webpage = ee.cause.read().decode('utf-8')
|
redir_webpage = ee.cause.read().decode('utf-8')
|
||||||
action = self._search_regex(
|
action = self._search_regex(
|
||||||
r'<form id="challenge-form" action="([^"]+)"',
|
r'<form id="challenge-form" action="([^"]+)"',
|
||||||
redir_webpage, u'Redirect form')
|
redir_webpage, 'Redirect form')
|
||||||
vc = self._search_regex(
|
vc = self._search_regex(
|
||||||
r'<input type="hidden" name="jschl_vc" value="([^"]+)"/>',
|
r'<input type="hidden" name="jschl_vc" value="([^"]+)"/>',
|
||||||
redir_webpage, u'redirect vc value')
|
redir_webpage, 'redirect vc value')
|
||||||
av = re.search(
|
av = re.search(
|
||||||
r'a\.value = ([0-9]+)[+]([0-9]+)[*]([0-9]+);',
|
r'a\.value = ([0-9]+)[+]([0-9]+)[*]([0-9]+);',
|
||||||
redir_webpage)
|
redir_webpage)
|
||||||
|
@ -52,19 +54,19 @@ class AddAnimeIE(InfoExtractor):
|
||||||
parsed_url = compat_urllib_parse_urlparse(url)
|
parsed_url = compat_urllib_parse_urlparse(url)
|
||||||
av_val = av_res + len(parsed_url.netloc)
|
av_val = av_res + len(parsed_url.netloc)
|
||||||
confirm_url = (
|
confirm_url = (
|
||||||
parsed_url.scheme + u'://' + parsed_url.netloc +
|
parsed_url.scheme + '://' + parsed_url.netloc +
|
||||||
action + '?' +
|
action + '?' +
|
||||||
compat_urllib_parse.urlencode({
|
compat_urllib_parse.urlencode({
|
||||||
'jschl_vc': vc, 'jschl_answer': compat_str(av_val)}))
|
'jschl_vc': vc, 'jschl_answer': compat_str(av_val)}))
|
||||||
self._download_webpage(
|
self._download_webpage(
|
||||||
confirm_url, video_id,
|
confirm_url, video_id,
|
||||||
note=u'Confirming after redirect')
|
note='Confirming after redirect')
|
||||||
webpage = self._download_webpage(url, video_id)
|
webpage = self._download_webpage(url, video_id)
|
||||||
|
|
||||||
formats = []
|
formats = []
|
||||||
for format_id in ('normal', 'hq'):
|
for format_id in ('normal', 'hq'):
|
||||||
rex = r"var %s_video_file = '(.*?)';" % re.escape(format_id)
|
rex = r"var %s_video_file = '(.*?)';" % re.escape(format_id)
|
||||||
video_url = self._search_regex(rex, webpage, u'video file URLx',
|
video_url = self._search_regex(rex, webpage, 'video file URLx',
|
||||||
fatal=False)
|
fatal=False)
|
||||||
if not video_url:
|
if not video_url:
|
||||||
continue
|
continue
|
||||||
|
@ -72,8 +74,7 @@ class AddAnimeIE(InfoExtractor):
|
||||||
'format_id': format_id,
|
'format_id': format_id,
|
||||||
'url': video_url,
|
'url': video_url,
|
||||||
})
|
})
|
||||||
if not formats:
|
self._sort_formats(formats)
|
||||||
raise ExtractorError(u'Cannot find any video format!')
|
|
||||||
video_title = self._og_search_title(webpage)
|
video_title = self._og_search_title(webpage)
|
||||||
video_description = self._og_search_description(webpage)
|
video_description = self._og_search_description(webpage)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue