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.

55 lines
1.7 KiB

  1. import re
  2. import xml.etree.ElementTree
  3. from .common import InfoExtractor
  4. class AnitubeIE(InfoExtractor):
  5. IE_NAME = u'anitube.se'
  6. _VALID_URL = r'https?://(?:www\.)?anitube\.se/video/(?P<id>\d+)'
  7. _TEST = {
  8. u'url': u'http://www.anitube.se/video/36621',
  9. u'md5': u'59d0eeae28ea0bc8c05e7af429998d43',
  10. u'file': u'36621.mp4',
  11. u'info_dict': {
  12. u'id': u'36621',
  13. u'ext': u'mp4',
  14. u'title': u'Recorder to Randoseru 01',
  15. },
  16. u'skip': u'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(r'http://www\.anitube\.se/embed/([A-Za-z0-9_-]*)',
  23. webpage, u'key')
  24. webpage_config = self._download_webpage('http://www.anitube.se/nuevo/econfig.php?key=%s' % key,
  25. key)
  26. config_xml = xml.etree.ElementTree.fromstring(webpage_config.encode('utf-8'))
  27. video_title = config_xml.find('title').text
  28. formats = []
  29. video_url = config_xml.find('file')
  30. if video_url is not None:
  31. formats.append({
  32. 'format_id': 'sd',
  33. 'url': video_url.text,
  34. })
  35. video_url = config_xml.find('filehd')
  36. if video_url is not None:
  37. formats.append({
  38. 'format_id': 'hd',
  39. 'url': video_url.text,
  40. })
  41. return {
  42. 'id': video_id,
  43. 'title': video_title,
  44. 'formats': formats
  45. }