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.

50 lines
1.7 KiB

10 years ago
10 years ago
10 years ago
  1. from __future__ import unicode_literals
  2. from .common import InfoExtractor
  3. from ..utils import (
  4. find_xpath_attr,
  5. int_or_none,
  6. )
  7. class VideofyMeIE(InfoExtractor):
  8. _VALID_URL = r'https?://(?:www\.videofy\.me/.+?|p\.videofy\.me/v)/(?P<id>\d+)(&|#|$)'
  9. IE_NAME = 'videofy.me'
  10. _TEST = {
  11. 'url': 'http://www.videofy.me/thisisvideofyme/1100701',
  12. 'md5': 'c77d700bdc16ae2e9f3c26019bd96143',
  13. 'info_dict': {
  14. 'id': '1100701',
  15. 'ext': 'mp4',
  16. 'title': 'This is VideofyMe',
  17. 'description': None,
  18. 'uploader': 'VideofyMe',
  19. 'uploader_id': 'thisisvideofyme',
  20. 'view_count': int,
  21. },
  22. }
  23. def _real_extract(self, url):
  24. video_id = self._match_id(url)
  25. config = self._download_xml('http://sunshine.videofy.me/?videoId=%s' % video_id,
  26. video_id)
  27. video = config.find('video')
  28. sources = video.find('sources')
  29. url_node = next(node for node in [find_xpath_attr(sources, 'source', 'id', 'HQ %s' % key)
  30. for key in ['on', 'av', 'off']] if node is not None)
  31. video_url = url_node.find('url').text
  32. view_count = int_or_none(self._search_regex(
  33. r'([0-9]+)', video.find('views').text, 'view count', fatal=False))
  34. return {
  35. 'id': video_id,
  36. 'title': video.find('title').text,
  37. 'url': 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': view_count,
  43. }