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.

48 lines
1.8 KiB

  1. import re
  2. import xml.etree.ElementTree
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. find_xpath_attr,
  6. determine_ext,
  7. )
  8. class VideofyMeIE(InfoExtractor):
  9. _VALID_URL = r'https?://(www.videofy.me/.+?|p.videofy.me/v)/(?P<id>\d+)(&|#|$)'
  10. IE_NAME = u'videofy.me'
  11. _TEST = {
  12. u'url': u'http://www.videofy.me/thisisvideofyme/1100701',
  13. u'file': u'1100701.mp4',
  14. u'md5': u'c77d700bdc16ae2e9f3c26019bd96143',
  15. u'info_dict': {
  16. u'title': u'This is VideofyMe',
  17. u'description': None,
  18. u'uploader': u'VideofyMe',
  19. u'uploader_id': u'thisisvideofyme',
  20. },
  21. }
  22. def _real_extract(self, url):
  23. mobj = re.match(self._VALID_URL, url)
  24. video_id = mobj.group('id')
  25. config_xml = self._download_webpage('http://sunshine.videofy.me/?videoId=%s' % video_id,
  26. video_id)
  27. config = xml.etree.ElementTree.fromstring(config_xml.encode('utf-8'))
  28. video = config.find('video')
  29. sources = video.find('sources')
  30. url_node = next(node for node in [find_xpath_attr(sources, 'source', 'id', 'HQ %s' % key)
  31. for key in ['on', 'av', 'off']] if node is not None)
  32. video_url = url_node.find('url').text
  33. return {'id': video_id,
  34. 'title': video.find('title').text,
  35. 'url': video_url,
  36. 'ext': determine_ext(video_url),
  37. 'thumbnail': video.find('thumb').text,
  38. 'description': video.find('description').text,
  39. 'uploader': config.find('blog/name').text,
  40. 'uploader_id': video.find('identifier').text,
  41. 'view_count': re.search(r'\d+', video.find('views').text).group(),
  42. }