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.

80 lines
2.4 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. HEADRequest,
  6. urlhandle_detect_ext,
  7. )
  8. class SoulAnimeWatchingIE(InfoExtractor):
  9. IE_NAME = "soulanime:watching"
  10. IE_DESC = "SoulAnime video"
  11. _TEST = {
  12. 'url': 'http://www.soul-anime.net/watching/seirei-tsukai-no-blade-dance-episode-9/',
  13. 'md5': '05fae04abf72298098b528e98abf4298',
  14. 'info_dict': {
  15. 'id': 'seirei-tsukai-no-blade-dance-episode-9',
  16. 'ext': 'mp4',
  17. 'title': 'seirei-tsukai-no-blade-dance-episode-9',
  18. 'description': 'seirei-tsukai-no-blade-dance-episode-9'
  19. }
  20. }
  21. _VALID_URL = r'http://[w.]*soul-anime\.(?P<domain>[^/]+)/watch[^/]*/(?P<id>[^/]+)'
  22. def _real_extract(self, url):
  23. mobj = re.match(self._VALID_URL, url)
  24. video_id = mobj.group('id')
  25. domain = mobj.group('domain')
  26. page = self._download_webpage(url, video_id)
  27. video_url_encoded = self._html_search_regex(
  28. r'<div id="download">[^<]*<a href="(?P<url>[^"]+)"', page, 'url')
  29. video_url = "http://www.soul-anime." + domain + video_url_encoded
  30. ext_req = HEADRequest(video_url)
  31. ext_handle = self._request_webpage(
  32. ext_req, video_id, note='Determining extension')
  33. ext = urlhandle_detect_ext(ext_handle)
  34. return {
  35. 'id': video_id,
  36. 'url': video_url,
  37. 'ext': ext,
  38. 'title': video_id,
  39. 'description': video_id
  40. }
  41. class SoulAnimeSeriesIE(InfoExtractor):
  42. IE_NAME = "soulanime:series"
  43. IE_DESC = "SoulAnime Series"
  44. _VALID_URL = r'http://[w.]*soul-anime\.(?P<domain>[^/]+)/anime./(?P<id>[^/]+)'
  45. _EPISODE_REGEX = r'<option value="(/watch[^/]*/[^"]+)">[^<]*</option>'
  46. _TEST = {
  47. 'url': 'http://www.soul-anime.net/anime1/black-rock-shooter-tv/',
  48. 'info_dict': {
  49. 'id': 'black-rock-shooter-tv'
  50. },
  51. 'playlist_count': 8
  52. }
  53. def _real_extract(self, url):
  54. mobj = re.match(self._VALID_URL, url)
  55. series_id = mobj.group('id')
  56. domain = mobj.group('domain')
  57. pattern = re.compile(self._EPISODE_REGEX)
  58. page = self._download_webpage(url, series_id, "Downloading series page")
  59. mobj = pattern.findall(page)
  60. entries = [self.url_result("http://www.soul-anime." + domain + obj) for obj in mobj]
  61. return self.playlist_result(entries, series_id)