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.

53 lines
1.5 KiB

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