]> jfr.im git - yt-dlp.git/blob - yt_dlp/extractor/la7.py
Completely change project name to yt-dlp (#85)
[yt-dlp.git] / yt_dlp / extractor / la7.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5 from ..utils import (
6 smuggle_url,
7 )
8
9
10 class LA7IE(InfoExtractor):
11 IE_NAME = 'la7.it'
12 _VALID_URL = r'''(?x)(https?://)?(?:
13 (?:www\.)?la7\.it/([^/]+)/(?:rivedila7|video)/|
14 tg\.la7\.it/repliche-tgla7\?id=
15 )(?P<id>.+)'''
16
17 _TESTS = [{
18 # 'src' is a plain URL
19 'url': 'http://www.la7.it/crozza/video/inccool8-02-10-2015-163722',
20 'md5': '8b613ffc0c4bf9b9e377169fc19c214c',
21 'info_dict': {
22 'id': '0_42j6wd36',
23 'ext': 'mp4',
24 'title': 'Inc.Cool8',
25 'description': 'Benvenuti nell\'incredibile mondo della INC. COOL. 8. dove “INC.” sta per “Incorporated” “COOL” sta per “fashion” ed Eight sta per il gesto atletico',
26 'thumbnail': 're:^https?://.*',
27 'uploader_id': 'kdla7pillole@iltrovatore.it',
28 'timestamp': 1443814869,
29 'upload_date': '20151002',
30 },
31 }, {
32 'url': 'http://www.la7.it/omnibus/rivedila7/omnibus-news-02-07-2016-189077',
33 'only_matching': True,
34 }]
35
36 def _real_extract(self, url):
37 video_id = self._match_id(url)
38
39 if not url.startswith('http'):
40 url = '%s//%s' % (self.http_scheme(), url)
41
42 webpage = self._download_webpage(url, video_id)
43
44 player_data = self._search_regex(
45 [r'(?s)videoParams\s*=\s*({.+?});', r'videoLa7\(({[^;]+})\);'],
46 webpage, 'player data')
47 vid = self._search_regex(r'vid\s*:\s*"(.+?)",', player_data, 'vid')
48
49 return {
50 '_type': 'url_transparent',
51 'url': smuggle_url('kaltura:103:%s' % vid, {
52 'service_url': 'http://nkdam.iltrovatore.it',
53 }),
54 'id': video_id,
55 'title': self._og_search_title(webpage, default=None),
56 'description': self._og_search_description(webpage, default=None),
57 'thumbnail': self._og_search_thumbnail(webpage, default=None),
58 'ie_key': 'Kaltura',
59 }