added tests (all run OK) and filled real_extract

This commit is contained in:
Felix Dollack 2016-02-07 16:29:01 +01:00
parent 33c9af1858
commit 7e1483ac8b

View File

@ -5,34 +5,49 @@ from .common import InfoExtractor
class AnimefullxIE(InfoExtractor): class AnimefullxIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?yourextractor\.com/watch/(?P<id>[0-9]+)' _VALID_URL = r'https?://(?:www\.)?animefullx\.com/watch/(?P<id>([a-zA-Z0-9-]+)?\d+)'
_TEST = { _TESTS = [{
'url': 'http://yourextractor.com/watch/42', 'url': 'http://www.animefullx.com/watch/chobits-episode-1/',
'md5': 'TODO: md5 sum of the first 10241 bytes of the video file (use --test)', 'md5': '48615cd86808a814d67f095c607c9435',
'info_dict': { 'info_dict': {
'id': '42', 'id': 'chobits-episode-1',
'ext': 'mp4', 'ext': 'mp4',
'title': 'Video title goes here', 'title': 'Watch Chobits Episode 1 English Subbed Online - Animefullx',
'thumbnail': 're:^https?://.*\.jpg$', },
# TODO more properties, either as: }, {
# * A value 'url': 'http://www.animefullx.com/watch/ao-no-exorcist-episode-1/',
# * MD5 checksum; start the string with md5: 'md5': '913b370e9568ab2c53733d6ebf9c2bcd',
# * A regular expression; start the string with re: 'info_dict': {
# * Any Python type (for example int or float) 'id': 'ao-no-exorcist-episode-1',
'ext': 'mp4',
'title': 'Watch Ao no Exorcist Episode 1 English Subbed Online - Animefullx',
} }
} }, {
'url': 'http://www.animefullx.com/watch/8-man-after-episode-1/',
'md5': 'b57f34b03cd37e7fb5530337802e9a4a',
'info_dict': {
'id': '8-man-after-episode-1',
'ext': 'mp4',
'title': 'Watch 8 Man After Episode 1 English Subbed Online - Animefullx',
},
}]
def _real_extract(self, url): def _real_extract(self, url):
video_id = self._match_id(url) video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id) webpage = self._download_webpage(url, video_id)
scripturl = self._html_search_regex(r'<iframe src="([^"]+)"', webpage, u'script URL')
# TODO more code goes here, for example ... if ( scripturl[ 0 ] == '/' ):
title = self._html_search_regex(r'<h1>(.+?)</h1>', webpage, 'title') script = self._download_webpage( 'http://www.animefullx.com/'+scripturl[1:], '' )
if ( 'http' in scripturl ):
script = self._download_webpage( scripturl, '' )
video_url = self._html_search_regex(r'file:\ ?"([^"]+)"', script, u'video URL')
return { return {
'_type': 'video',
'id': video_id, 'id': video_id,
'title': title, 'url': video_url,
'description': self._og_search_description(webpage), 'title': self._og_search_title( webpage ),
'uploader': self._search_regex(r'<div[^>]+id="uploader"[^>]*>([^<]+)<', webpage, 'uploader', fatal=False), 'ext': 'mp4',
# TODO more properties (see youtube_dl/extractor/common.py)
} }