1
0
Fork 0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-11-14 05:15:37 +00:00
youtube-dl/youtube_dl/extractor/la7.py

61 lines
1.8 KiB
Python
Raw Normal View History

2014-01-27 06:05:28 +00:00
from __future__ import unicode_literals
from .common import InfoExtractor
from ..utils import (
parse_duration,
)
class LA7IE(InfoExtractor):
IE_NAME = 'la7.tv'
2014-01-27 06:08:01 +00:00
_VALID_URL = r'''(?x)
https?://(?:www\.)?la7\.tv/
(?:
richplayer/\?assetid=|
\?contentId=
)
(?P<id>[0-9]+)'''
2014-01-27 06:05:28 +00:00
_TEST = {
'url': 'http://www.la7.tv/richplayer/?assetid=50355319',
'md5': 'ec7d1f0224d20ba293ab56cf2259651f',
'info_dict': {
2015-02-01 14:03:03 +00:00
'id': '50355319',
'ext': 'mp4',
2014-01-27 06:05:28 +00:00
'title': 'IL DIVO',
'description': 'Un film di Paolo Sorrentino con Toni Servillo, Anna Bonaiuto, Giulio Bosetti e Flavio Bucci',
'duration': 6254,
2014-01-27 22:47:22 +00:00
},
'skip': 'Blocked in the US',
2014-01-27 06:05:28 +00:00
}
def _real_extract(self, url):
2015-02-01 14:03:03 +00:00
video_id = self._match_id(url)
2014-01-27 06:05:28 +00:00
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
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:')
formats = [{
'format': vnode.find('quality').text,
'tbr': int(vnode.find('quality').text),
'url': vnode.find('fms').text.strip().replace('mp4:', prefix),
} for vnode in doc.findall('.//videos/video')]
self._sort_formats(formats)
return {
'id': video_id,
'title': video_title,
'description': description,
'thumbnail': thumbnail,
'duration': duration,
'formats': formats,
'view_count': view_count,
}