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