]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/la7.py
[tf1] Improve extraction and fix issues (closes #21372)
[yt-dlp.git] / youtube_dl / extractor / la7.py
CommitLineData
712b0b5b 1# coding: utf-8
a17d16d5
PH
2from __future__ import unicode_literals
3
a17d16d5
PH
4from .common import InfoExtractor
5from ..utils import (
712b0b5b 6 js_to_json,
dafafe7c 7 smuggle_url,
a17d16d5
PH
8)
9
10
11class LA7IE(InfoExtractor):
712b0b5b
YCH
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',
dafafe7c 21 'md5': '8b613ffc0c4bf9b9e377169fc19c214c',
712b0b5b
YCH
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?://.*',
dafafe7c
RA
28 'uploader_id': 'kdla7pillole@iltrovatore.it',
29 'timestamp': 1443814869,
30 'upload_date': '20151002',
712b0b5b
YCH
31 },
32 }, {
33 # 'src' is a dictionary
34 'url': 'http://tg.la7.it/repliche-tgla7?id=189080',
35 'md5': '6b0d8888d286e39870208dfeceaf456b',
a17d16d5 36 'info_dict': {
712b0b5b 37 'id': '189080',
228d30ed 38 'ext': 'mp4',
712b0b5b 39 'title': 'TG LA7',
075911d4 40 },
712b0b5b
YCH
41 }, {
42 'url': 'http://www.la7.it/omnibus/rivedila7/omnibus-news-02-07-2016-189077',
43 'only_matching': True,
44 }]
a17d16d5
PH
45
46 def _real_extract(self, url):
228d30ed 47 video_id = self._match_id(url)
712b0b5b
YCH
48
49 webpage = self._download_webpage(url, video_id)
50
51 player_data = self._parse_json(
96a0bbdd
V
52 self._search_regex(
53 [r'(?s)videoParams\s*=\s*({.+?});', r'videoLa7\(({[^;]+})\);'],
54 webpage, 'player data'),
712b0b5b
YCH
55 video_id, transform_source=js_to_json)
56
a17d16d5 57 return {
dafafe7c
RA
58 '_type': 'url_transparent',
59 'url': smuggle_url('kaltura:103:%s' % player_data['vid'], {
60 'service_url': 'http://kdam.iltrovatore.it',
61 }),
a17d16d5 62 'id': video_id,
712b0b5b
YCH
63 'title': player_data['title'],
64 'description': self._og_search_description(webpage, default=None),
65 'thumbnail': player_data.get('poster'),
dafafe7c 66 'ie_key': 'Kaltura',
a17d16d5 67 }