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.

59 lines
1.7 KiB

  1. from __future__ import unicode_literals
  2. import re
  3. from .common import InfoExtractor
  4. class AnitubeIE(InfoExtractor):
  5. IE_NAME = 'anitube.se'
  6. _VALID_URL = r'https?://(?:www\.)?anitube\.se/video/(?P<id>\d+)'
  7. _TEST = {
  8. 'url': 'http://www.anitube.se/video/36621',
  9. 'md5': '59d0eeae28ea0bc8c05e7af429998d43',
  10. 'info_dict': {
  11. 'id': '36621',
  12. 'ext': 'mp4',
  13. 'title': 'Recorder to Randoseru 01',
  14. 'duration': 180.19,
  15. },
  16. 'skip': 'Blocked in the US',
  17. }
  18. def _real_extract(self, url):
  19. mobj = re.match(self._VALID_URL, url)
  20. video_id = mobj.group('id')
  21. webpage = self._download_webpage(url, video_id)
  22. key = self._html_search_regex(
  23. r'http://www\.anitube\.se/embed/([A-Za-z0-9_-]*)', webpage, 'key')
  24. config_xml = self._download_xml(
  25. 'http://www.anitube.se/nuevo/econfig.php?key=%s' % key, key)
  26. video_title = config_xml.find('title').text
  27. thumbnail = config_xml.find('image').text
  28. duration = float(config_xml.find('duration').text)
  29. formats = []
  30. video_url = config_xml.find('file')
  31. if video_url is not None:
  32. formats.append({
  33. 'format_id': 'sd',
  34. 'url': video_url.text,
  35. })
  36. video_url = config_xml.find('filehd')
  37. if video_url is not None:
  38. formats.append({
  39. 'format_id': 'hd',
  40. 'url': video_url.text,
  41. })
  42. return {
  43. 'id': video_id,
  44. 'title': video_title,
  45. 'thumbnail': thumbnail,
  46. 'duration': duration,
  47. 'formats': formats
  48. }