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.

49 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'2046dd5758541d630bfa93e741e2fd79',
  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 = find_xpath_attr(sources, 'source', 'id', 'HQ on')
  31. if url_node is None:
  32. url_node = find_xpath_attr(sources, 'source', 'id', 'HQ off')
  33. video_url = url_node.find('url').text
  34. return {'id': video_id,
  35. 'title': video.find('title').text,
  36. 'url': video_url,
  37. 'ext': determine_ext(video_url),
  38. 'thumbnail': video.find('thumb').text,
  39. 'description': video.find('description').text,
  40. 'uploader': config.find('blog/name').text,
  41. 'uploader_id': video.find('identifier').text,
  42. 'view_count': re.search(r'\d+', video.find('views').text).group(),
  43. }