You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
1.4 KiB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
  1. import re
  2. from .common import InfoExtractor
  3. class AddAnimeIE(InfoExtractor):
  4. _VALID_URL = r'^(?:http?://)?(?:\w+\.)?add-anime\.net/watch_video.php\?(?:.*?)v=(?P<video_id>[\w_]+)(?:.*)'
  5. IE_NAME = u'AddAnime'
  6. _TEST = {
  7. u'url': u'http://www.add-anime.net/watch_video.php?v=24MR3YO5SAS9',
  8. u'file': u'137499050692ced.flv',
  9. u'md5': u'0813c2430bea7a46bf13acf3406992f4',
  10. u'info_dict': {
  11. u"description": u"One Piece 606",
  12. u"title": u"One Piece 606"
  13. }
  14. }
  15. def _real_extract(self, url):
  16. mobj = re.match(self._VALID_URL, url)
  17. if mobj is None:
  18. raise ExtractorError(u'Invalid URL: %s' % url)
  19. video_id = mobj.group('video_id')
  20. webpage = self._download_webpage(url, video_id)
  21. def find_between( webpage, first, last ):
  22. try:
  23. start = webpage.index( first ) + len( first )
  24. end = webpage.index( last, start )
  25. return webpage[start:end]
  26. except ValueError:
  27. return ""
  28. video_url = find_between( webpage, "var normal_video_file = '", "';" )
  29. video_title = self._og_search_title(webpage)
  30. video_description = self._og_search_description(webpage)
  31. info = {
  32. 'id': video_id,
  33. 'url': video_url,
  34. 'ext': 'flv',
  35. 'title': video_title,
  36. 'description': video_description
  37. }
  38. return [info]