]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/europa.py
2 from __future__
import unicode_literals
4 from .common
import InfoExtractor
5 from ..compat
import compat_urlparse
16 class EuropaIE(InfoExtractor
):
17 _VALID_URL
= r
'https?://ec\.europa\.eu/avservices/(?:video/player|audio/audioDetails)\.cfm\?.*?\bref=(?P<id>[A-Za-z0-9-]+)'
19 'url': 'http://ec.europa.eu/avservices/video/player.cfm?ref=I107758',
20 'md5': '574f080699ddd1e19a675b0ddf010371',
24 'title': 'TRADE - Wikileaks on TTIP',
25 'description': 'NEW LIVE EC Midday press briefing of 11/08/2015',
26 'thumbnail': r
're:^https?://.*\.jpg$',
27 'upload_date': '20150811',
30 'formats': 'mincount:3',
33 'url': 'http://ec.europa.eu/avservices/video/player.cfm?sitelang=en&ref=I107786',
34 'only_matching': True,
36 'url': 'http://ec.europa.eu/avservices/audio/audioDetails.cfm?ref=I-109295&sitelang=en',
37 'only_matching': True,
40 def _real_extract(self
, url
):
41 video_id
= self
._match
_id
(url
)
43 playlist
= self
._download
_xml
(
44 'http://ec.europa.eu/avservices/video/player/playlist.cfm?ID=%s' % video_id
, video_id
)
46 def get_item(type_
, preference
):
48 for item
in playlist
.findall('./info/%s/item' % type_
):
49 lang
, label
= xpath_text(item
, 'lg', default
=None), xpath_text(item
, 'label', default
=None)
51 items
[lang
] = label
.strip()
56 query
= compat_urlparse
.parse_qs(compat_urlparse
.urlparse(url
).query
)
57 preferred_lang
= query
.get('sitelang', ('en', ))[0]
59 preferred_langs
= orderedSet((preferred_lang
, 'en', 'int'))
61 title
= get_item('title', preferred_langs
) or video_id
62 description
= get_item('description', preferred_langs
)
63 thumbnmail
= xpath_text(playlist
, './info/thumburl', 'thumbnail')
64 upload_date
= unified_strdate(xpath_text(playlist
, './info/date', 'upload date'))
65 duration
= parse_duration(xpath_text(playlist
, './info/duration', 'duration'))
66 view_count
= int_or_none(xpath_text(playlist
, './info/views', 'views'))
68 language_preference
= qualities(preferred_langs
[::-1])
71 for file_
in playlist
.findall('./files/file'):
72 video_url
= xpath_text(file_
, './url')
75 lang
= xpath_text(file_
, './lg')
79 'format_note': xpath_text(file_
, './lglabel'),
80 'language_preference': language_preference(lang
)
82 self
._sort
_formats
(formats
)
87 'description': description
,
88 'thumbnail': thumbnmail
,
89 'upload_date': upload_date
,
91 'view_count': view_count
,