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. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. class YourUploadIE(InfoExtractor):
  5. _VALID_URL = r'''(?x)https?://(?:www\.)?
  6. (?:yourupload\.com/watch|
  7. embed\.yourupload\.com|
  8. embed\.yucache\.net
  9. )/(?P<id>[A-Za-z0-9]+)
  10. '''
  11. _TESTS = [
  12. {
  13. 'url': 'http://yourupload.com/watch/14i14h',
  14. 'md5': '5e2c63385454c557f97c4c4131a393cd',
  15. 'info_dict': {
  16. 'id': '14i14h',
  17. 'ext': 'mp4',
  18. 'title': 'BigBuckBunny_320x180.mp4',
  19. 'thumbnail': 're:^https?://.*\.jpe?g',
  20. }
  21. },
  22. {
  23. 'url': 'http://embed.yourupload.com/14i14h',
  24. 'only_matching': True,
  25. },
  26. {
  27. 'url': 'http://embed.yucache.net/14i14h?client_file_id=803349',
  28. 'only_matching': True,
  29. },
  30. ]
  31. def _real_extract(self, url):
  32. video_id = self._match_id(url)
  33. embed_url = 'http://embed.yucache.net/{0:}'.format(video_id)
  34. webpage = self._download_webpage(embed_url, video_id)
  35. title = self._og_search_title(webpage)
  36. video_url = self._og_search_video_url(webpage)
  37. thumbnail = self._og_search_thumbnail(webpage, default=None)
  38. return {
  39. 'id': video_id,
  40. 'title': title,
  41. 'url': video_url,
  42. 'thumbnail': thumbnail,
  43. 'http_headers': {
  44. 'Referer': embed_url,
  45. },
  46. }