1
1
mirror of https://github.com/ytdl-org/youtube-dl synced 2024-12-25 19:25:50 +01:00
youtube-dl/youtube_dl/extractor/digg.py

57 lines
1.8 KiB
Python
Raw Normal View History

2018-01-10 15:24:22 +01:00
from __future__ import unicode_literals
from .common import InfoExtractor
2018-01-10 16:19:51 +01:00
from ..utils import js_to_json
2018-01-10 15:24:22 +01:00
class DiggIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?digg\.com/video/(?P<id>[^/?#&]+)'
2018-01-10 16:19:51 +01:00
_TESTS = [{
# JWPlatform via provider
2018-01-10 15:24:22 +01:00
'url': 'http://digg.com/video/sci-fi-short-jonah-daniel-kaluuya-get-out',
'info_dict': {
'id': 'LcqvmS0b',
'ext': 'mp4',
'title': "'Get Out' Star Daniel Kaluuya Goes On 'Moby Dick'-Like Journey In Sci-Fi Short 'Jonah'",
'description': 'md5:541bb847648b6ee3d6514bc84b82efda',
'upload_date': '20180109',
'timestamp': 1515530551,
},
'params': {
'skip_download': True,
},
2018-01-10 16:19:51 +01:00
}, {
# Youtube via provider
'url': 'http://digg.com/video/dog-boat-seal-play',
'only_matching': True,
}, {
# vimeo as regular embed
'url': 'http://digg.com/video/dream-girl-short-film',
'only_matching': True,
}]
2018-01-10 15:24:22 +01:00
def _real_extract(self, url):
display_id = self._match_id(url)
webpage = self._download_webpage(url, display_id)
2018-01-10 16:19:51 +01:00
info = self._parse_json(
self._search_regex(
r'(?s)video_info\s*=\s*({.+?});\n', webpage, 'video info',
default='{}'), display_id, transform_source=js_to_json,
fatal=False)
video_id = info.get('video_id')
if video_id:
provider = info.get('provider_name')
if provider == 'youtube':
return self.url_result(
video_id, ie='Youtube', video_id=video_id)
elif provider == 'jwplayer':
return self.url_result(
'jwplatform:%s' % video_id, ie='JWPlatform',
video_id=video_id)
return self.url_result(url, 'Generic')