]> git.bitcoin.ninja Git - youtube-dl/blob - youtube_dl/extractor/localnews8.py
[README.md] Make download URLs consistent
[youtube-dl] / youtube_dl / extractor / localnews8.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 import re
5
6 from .common import InfoExtractor
7
8
9 class LocalNews8IE(InfoExtractor):
10     _VALID_URL = r'https?://(?:www\.)?localnews8\.com/(?:[^/]+/)*(?P<display_id>[^/]+)/(?P<id>[0-9]+)'
11     _TEST = {
12         'url': 'http://www.localnews8.com/news/rexburg-business-turns-carbon-fiber-scraps-into-wedding-rings/35183304',
13         'md5': 'be4d48aea61aa2bde7be2ee47691ad20',
14         'info_dict': {
15             'id': '35183304',
16             'display_id': 'rexburg-business-turns-carbon-fiber-scraps-into-wedding-rings',
17             'ext': 'mp4',
18             'title': 'Rexburg business turns carbon fiber scraps into wedding ring',
19             'description': 'The process was first invented by Lamborghini and less than a dozen companies around the world use it.',
20             'duration': 153,
21             'timestamp': 1441844822,
22             'upload_date': '20150910',
23             'uploader_id': 'api',
24         }
25     }
26
27     def _real_extract(self, url):
28         mobj = re.match(self._VALID_URL, url)
29         video_id = mobj.group('id')
30         display_id = mobj.group('display_id')
31
32         webpage = self._download_webpage(url, display_id)
33
34         partner_id = self._search_regex(
35             r'partnerId\s*[:=]\s*(["\'])(?P<id>\d+)\1',
36             webpage, 'partner id', group='id')
37         kaltura_id = self._search_regex(
38             r'videoIdString\s*[:=]\s*(["\'])kaltura:(?P<id>[0-9a-z_]+)\1',
39             webpage, 'videl id', group='id')
40
41         return {
42             '_type': 'url_transparent',
43             'url': 'kaltura:%s:%s' % (partner_id, kaltura_id),
44             'ie_key': 'Kaltura',
45             'id': video_id,
46             'display_id': display_id,
47         }