[digg] Add extractor (closes #15214)
[youtube-dl] / youtube_dl / extractor / digg.py
1 from __future__ import unicode_literals
2
3 from .common import InfoExtractor
4
5
6 class DiggIE(InfoExtractor):
7     _VALID_URL = r'https?://(?:www\.)?digg\.com/video/(?P<id>[^/?#&]+)'
8     _TEST = {
9         'url': 'http://digg.com/video/sci-fi-short-jonah-daniel-kaluuya-get-out',
10         'info_dict': {
11             'id': 'LcqvmS0b',
12             'ext': 'mp4',
13             'title': "'Get Out' Star Daniel Kaluuya Goes On 'Moby Dick'-Like Journey In Sci-Fi Short 'Jonah'",
14             'description': 'md5:541bb847648b6ee3d6514bc84b82efda',
15             'upload_date': '20180109',
16             'timestamp': 1515530551,
17         },
18         'params': {
19             'skip_download': True,
20         },
21     }
22
23     def _real_extract(self, url):
24         display_id = self._match_id(url)
25
26         webpage = self._download_webpage(url, display_id)
27
28         jwplatform_id = self._search_regex(
29             r'video_id\s*:\s*["\']([a-zA-Z0-9]{8})', webpage, 'jwplatform id',
30             default=None)
31
32         if not jwplatform_id:
33             return self.url_result(url, 'Generic')
34
35         return {
36             '_type': 'url_transparent',
37             'ie_key': 'JWPlatform',
38             'url': 'jwplatform:%s' % jwplatform_id,
39             'id': jwplatform_id,
40             'display_id': display_id,
41         }