]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/la7.py
debian/copyright: Fix lintian's dep5-copyright-license-name-not-unique.
[youtubedl] / youtube_dl / extractor / la7.py
1 from __future__ import unicode_literals
2
3 from .common import InfoExtractor
4 from ..utils import (
5 parse_duration,
6 )
7
8
9 class LA7IE(InfoExtractor):
10 IE_NAME = 'la7.tv'
11 _VALID_URL = r'''(?x)
12 https?://(?:www\.)?la7\.tv/
13 (?:
14 richplayer/\?assetid=|
15 \?contentId=
16 )
17 (?P<id>[0-9]+)'''
18
19 _TEST = {
20 'url': 'http://www.la7.tv/richplayer/?assetid=50355319',
21 'md5': 'ec7d1f0224d20ba293ab56cf2259651f',
22 'info_dict': {
23 'id': '50355319',
24 'ext': 'mp4',
25 'title': 'IL DIVO',
26 'description': 'Un film di Paolo Sorrentino con Toni Servillo, Anna Bonaiuto, Giulio Bosetti e Flavio Bucci',
27 'duration': 6254,
28 },
29 'skip': 'Blocked in the US',
30 }
31
32 def _real_extract(self, url):
33 video_id = self._match_id(url)
34 xml_url = 'http://www.la7.tv/repliche/content/index.php?contentId=%s' % video_id
35 doc = self._download_xml(xml_url, video_id)
36
37 video_title = doc.find('title').text
38 description = doc.find('description').text
39 duration = parse_duration(doc.find('duration').text)
40 thumbnail = doc.find('img').text
41 view_count = int(doc.find('views').text)
42
43 prefix = doc.find('.//fqdn').text.strip().replace('auto:', 'http:')
44
45 formats = [{
46 'format': vnode.find('quality').text,
47 'tbr': int(vnode.find('quality').text),
48 'url': vnode.find('fms').text.strip().replace('mp4:', prefix),
49 } for vnode in doc.findall('.//videos/video')]
50 self._sort_formats(formats)
51
52 return {
53 'id': video_id,
54 'title': video_title,
55 'description': description,
56 'thumbnail': thumbnail,
57 'duration': duration,
58 'formats': formats,
59 'view_count': view_count,
60 }