mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-12-22 08:47:41 +00:00
[la7.it] Fix the extractor
This commit is contained in:
parent
6a424391d9
commit
712b0b5b70
1 changed files with 50 additions and 36 deletions
|
@ -1,60 +1,74 @@
|
||||||
|
# coding: utf-8
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
parse_duration,
|
determine_ext,
|
||||||
|
js_to_json,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class LA7IE(InfoExtractor):
|
class LA7IE(InfoExtractor):
|
||||||
IE_NAME = 'la7.tv'
|
IE_NAME = 'la7.it'
|
||||||
_VALID_URL = r'''(?x)
|
_VALID_URL = r'''(?x)(https?://)?(?:
|
||||||
https?://(?:www\.)?la7\.tv/
|
(?:www\.)?la7\.it/([^/]+)/(?:rivedila7|video)/|
|
||||||
(?:
|
tg\.la7\.it/repliche-tgla7\?id=
|
||||||
richplayer/\?assetid=|
|
)(?P<id>.+)'''
|
||||||
\?contentId=
|
|
||||||
)
|
|
||||||
(?P<id>[0-9]+)'''
|
|
||||||
|
|
||||||
_TEST = {
|
_TESTS = [{
|
||||||
'url': 'http://www.la7.tv/richplayer/?assetid=50355319',
|
# 'src' is a plain URL
|
||||||
'md5': 'ec7d1f0224d20ba293ab56cf2259651f',
|
'url': 'http://www.la7.it/crozza/video/inccool8-02-10-2015-163722',
|
||||||
|
'md5': '6054674766e7988d3e02f2148ff92180',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': '50355319',
|
'id': 'inccool8-02-10-2015-163722',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': 'IL DIVO',
|
'title': 'Inc.Cool8',
|
||||||
'description': 'Un film di Paolo Sorrentino con Toni Servillo, Anna Bonaiuto, Giulio Bosetti e Flavio Bucci',
|
'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',
|
||||||
'duration': 6254,
|
'thumbnail': 're:^https?://.*',
|
||||||
},
|
},
|
||||||
'skip': 'Blocked in the US',
|
}, {
|
||||||
}
|
# 'src' is a dictionary
|
||||||
|
'url': 'http://tg.la7.it/repliche-tgla7?id=189080',
|
||||||
|
'md5': '6b0d8888d286e39870208dfeceaf456b',
|
||||||
|
'info_dict': {
|
||||||
|
'id': '189080',
|
||||||
|
'ext': 'mp4',
|
||||||
|
'title': 'TG LA7',
|
||||||
|
},
|
||||||
|
}, {
|
||||||
|
'url': 'http://www.la7.it/omnibus/rivedila7/omnibus-news-02-07-2016-189077',
|
||||||
|
'only_matching': True,
|
||||||
|
}]
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
xml_url = 'http://www.la7.tv/repliche/content/index.php?contentId=%s' % video_id
|
|
||||||
doc = self._download_xml(xml_url, video_id)
|
|
||||||
|
|
||||||
video_title = doc.find('title').text
|
webpage = self._download_webpage(url, video_id)
|
||||||
description = doc.find('description').text
|
|
||||||
duration = parse_duration(doc.find('duration').text)
|
|
||||||
thumbnail = doc.find('img').text
|
|
||||||
view_count = int(doc.find('views').text)
|
|
||||||
|
|
||||||
prefix = doc.find('.//fqdn').text.strip().replace('auto:', 'http:')
|
player_data = self._parse_json(
|
||||||
|
self._search_regex(r'videoLa7\(({[^;]+})\);', webpage, 'player data'),
|
||||||
|
video_id, transform_source=js_to_json)
|
||||||
|
|
||||||
formats = [{
|
source = player_data['src']
|
||||||
'format': vnode.find('quality').text,
|
source_urls = source.values() if isinstance(source, dict) else [source]
|
||||||
'tbr': int(vnode.find('quality').text),
|
|
||||||
'url': vnode.find('fms').text.strip().replace('mp4:', prefix),
|
formats = []
|
||||||
} for vnode in doc.findall('.//videos/video')]
|
for source_url in source_urls:
|
||||||
|
ext = determine_ext(source_url)
|
||||||
|
if ext == 'm3u8':
|
||||||
|
formats.extend(self._extract_m3u8_formats(
|
||||||
|
source_url, video_id, ext='mp4',
|
||||||
|
entry_protocol='m3u8_native', m3u8_id='hls'))
|
||||||
|
else:
|
||||||
|
formats.append({
|
||||||
|
'url': source_url,
|
||||||
|
})
|
||||||
self._sort_formats(formats)
|
self._sort_formats(formats)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'id': video_id,
|
'id': video_id,
|
||||||
'title': video_title,
|
'title': player_data['title'],
|
||||||
'description': description,
|
'description': self._og_search_description(webpage, default=None),
|
||||||
'thumbnail': thumbnail,
|
'thumbnail': player_data.get('poster'),
|
||||||
'duration': duration,
|
|
||||||
'formats': formats,
|
'formats': formats,
|
||||||
'view_count': view_count,
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue