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.

56 lines
1.8 KiB

  1. from __future__ import unicode_literals
  2. from .common import InfoExtractor
  3. from ..utils import js_to_json
  4. class DiggIE(InfoExtractor):
  5. _VALID_URL = r'https?://(?:www\.)?digg\.com/video/(?P<id>[^/?#&]+)'
  6. _TESTS = [{
  7. # JWPlatform via provider
  8. 'url': 'http://digg.com/video/sci-fi-short-jonah-daniel-kaluuya-get-out',
  9. 'info_dict': {
  10. 'id': 'LcqvmS0b',
  11. 'ext': 'mp4',
  12. 'title': "'Get Out' Star Daniel Kaluuya Goes On 'Moby Dick'-Like Journey In Sci-Fi Short 'Jonah'",
  13. 'description': 'md5:541bb847648b6ee3d6514bc84b82efda',
  14. 'upload_date': '20180109',
  15. 'timestamp': 1515530551,
  16. },
  17. 'params': {
  18. 'skip_download': True,
  19. },
  20. }, {
  21. # Youtube via provider
  22. 'url': 'http://digg.com/video/dog-boat-seal-play',
  23. 'only_matching': True,
  24. }, {
  25. # vimeo as regular embed
  26. 'url': 'http://digg.com/video/dream-girl-short-film',
  27. 'only_matching': True,
  28. }]
  29. def _real_extract(self, url):
  30. display_id = self._match_id(url)
  31. webpage = self._download_webpage(url, display_id)
  32. info = self._parse_json(
  33. self._search_regex(
  34. r'(?s)video_info\s*=\s*({.+?});\n', webpage, 'video info',
  35. default='{}'), display_id, transform_source=js_to_json,
  36. fatal=False)
  37. video_id = info.get('video_id')
  38. if video_id:
  39. provider = info.get('provider_name')
  40. if provider == 'youtube':
  41. return self.url_result(
  42. video_id, ie='Youtube', video_id=video_id)
  43. elif provider == 'jwplayer':
  44. return self.url_result(
  45. 'jwplatform:%s' % video_id, ie='JWPlatform',
  46. video_id=video_id)
  47. return self.url_result(url, 'Generic')