]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/la7.py
Update upstream source from tag 'upstream/2019.09.28'
[youtubedl] / youtube_dl / extractor / la7.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5 from ..utils import (
6 js_to_json,
7 smuggle_url,
8 )
9
10
11 class LA7IE(InfoExtractor):
12 IE_NAME = 'la7.it'
13 _VALID_URL = r'''(?x)(https?://)?(?:
14 (?:www\.)?la7\.it/([^/]+)/(?:rivedila7|video)/|
15 tg\.la7\.it/repliche-tgla7\?id=
16 )(?P<id>.+)'''
17
18 _TESTS = [{
19 # 'src' is a plain URL
20 'url': 'http://www.la7.it/crozza/video/inccool8-02-10-2015-163722',
21 'md5': '8b613ffc0c4bf9b9e377169fc19c214c',
22 'info_dict': {
23 'id': 'inccool8-02-10-2015-163722',
24 'ext': 'mp4',
25 'title': 'Inc.Cool8',
26 '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',
27 'thumbnail': 're:^https?://.*',
28 'uploader_id': 'kdla7pillole@iltrovatore.it',
29 'timestamp': 1443814869,
30 'upload_date': '20151002',
31 },
32 }, {
33 # 'src' is a dictionary
34 'url': 'http://tg.la7.it/repliche-tgla7?id=189080',
35 'md5': '6b0d8888d286e39870208dfeceaf456b',
36 'info_dict': {
37 'id': '189080',
38 'ext': 'mp4',
39 'title': 'TG LA7',
40 },
41 }, {
42 'url': 'http://www.la7.it/omnibus/rivedila7/omnibus-news-02-07-2016-189077',
43 'only_matching': True,
44 }]
45
46 def _real_extract(self, url):
47 video_id = self._match_id(url)
48
49 webpage = self._download_webpage(url, video_id)
50
51 player_data = self._parse_json(
52 self._search_regex(
53 [r'(?s)videoParams\s*=\s*({.+?});', r'videoLa7\(({[^;]+})\);'],
54 webpage, 'player data'),
55 video_id, transform_source=js_to_json)
56
57 return {
58 '_type': 'url_transparent',
59 'url': smuggle_url('kaltura:103:%s' % player_data['vid'], {
60 'service_url': 'http://kdam.iltrovatore.it',
61 }),
62 'id': video_id,
63 'title': player_data['title'],
64 'description': self._og_search_description(webpage, default=None),
65 'thumbnail': player_data.get('poster'),
66 'ie_key': 'Kaltura',
67 }