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.

54 lines
1.6 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. }
  17. def _real_extract(self, url):
  18. mobj = re.match(self._VALID_URL, url)
  19. video_id = mobj.group('id')
  20. webpage = self._download_webpage(url, video_id)
  21. key = self._html_search_regex(r'http://www\.anitube\.se/embed/([A-Za-z0-9_-]*)',
  22. webpage, u'key')
  23. webpage_config = self._download_webpage('http://www.anitube.se/nuevo/econfig.php?key=%s' % key,
  24. key)
  25. config_xml = xml.etree.ElementTree.fromstring(webpage_config.encode('utf-8'))
  26. video_title = config_xml.find('title').text
  27. formats = []
  28. video_url = config_xml.find('file')
  29. if video_url is not None:
  30. formats.append({
  31. 'format_id': 'sd',
  32. 'url': video_url.text,
  33. })
  34. video_url = config_xml.find('filehd')
  35. if video_url is not None:
  36. formats.append({
  37. 'format_id': 'hd',
  38. 'url': video_url.text,
  39. })
  40. return {
  41. 'id': video_id,
  42. 'title': video_title,
  43. 'formats': formats
  44. }