yourupload.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. from .common import InfoExtractor
  2. from ..utils import urljoin
  3. class YourUploadIE(InfoExtractor):
  4. _VALID_URL = r'https?://(?:www\.)?(?:yourupload\.com/(?:watch|embed)|embed\.yourupload\.com)/(?P<id>[A-Za-z0-9]+)'
  5. _TESTS = [{
  6. 'url': 'http://yourupload.com/watch/14i14h',
  7. 'md5': '5e2c63385454c557f97c4c4131a393cd',
  8. 'info_dict': {
  9. 'id': '14i14h',
  10. 'ext': 'mp4',
  11. 'title': 'BigBuckBunny_320x180.mp4',
  12. 'thumbnail': r're:^https?://.*\.jpe?g',
  13. }
  14. }, {
  15. 'url': 'http://www.yourupload.com/embed/14i14h',
  16. 'only_matching': True,
  17. }, {
  18. 'url': 'http://embed.yourupload.com/14i14h',
  19. 'only_matching': True,
  20. }]
  21. def _real_extract(self, url):
  22. video_id = self._match_id(url)
  23. embed_url = 'http://www.yourupload.com/embed/%s' % video_id
  24. webpage = self._download_webpage(embed_url, video_id)
  25. title = self._og_search_title(webpage)
  26. video_url = urljoin(embed_url, self._og_search_video_url(webpage))
  27. thumbnail = self._og_search_thumbnail(webpage, default=None)
  28. return {
  29. 'id': video_id,
  30. 'title': title,
  31. 'url': video_url,
  32. 'thumbnail': thumbnail,
  33. 'http_headers': {
  34. 'Referer': embed_url,
  35. },
  36. }