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.

58 lines
1.5 KiB

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