[ie/dropbox] Fix password-protected video extraction (#11636)
[yt-dlp3.git] / yt_dlp / extractor / folketinget.py
blob95095701bc64d7284cb516882a300d4de4637b2f
1 import urllib.parse
3 from .common import InfoExtractor
4 from ..utils import (
5 int_or_none,
6 parse_duration,
7 parse_iso8601,
8 xpath_text,
12 class FolketingetIE(InfoExtractor):
13 IE_DESC = 'Folketinget (ft.dk; Danish parliament)'
14 _VALID_URL = r'https?://(?:www\.)?ft\.dk/webtv/video/[^?#]*?\.(?P<id>[0-9]+)\.aspx'
15 _TEST = {
16 'url': 'http://www.ft.dk/webtv/video/20141/eru/td.1165642.aspx?as=1#player',
17 'md5': '6269e8626fa1a891bf5369b386ae996a',
18 'info_dict': {
19 'id': '1165642',
20 'ext': 'mp4',
21 'title': 'Åbent samråd i Erhvervsudvalget',
22 'description': 'Åbent samråd med erhvervs- og vækstministeren om regeringens politik på teleområdet',
23 'view_count': int,
24 'width': 768,
25 'height': 432,
26 'tbr': 928000,
27 'timestamp': 1416493800,
28 'upload_date': '20141120',
29 'duration': 3960,
31 'params': {
32 # rtmp download
33 'skip_download': True,
37 def _real_extract(self, url):
38 video_id = self._match_id(url)
39 webpage = self._download_webpage(url, video_id)
41 title = self._og_search_title(webpage)
42 description = self._html_search_regex(
43 r'(?s)<div class="video-item-agenda"[^>]*>(.*?)<',
44 webpage, 'description', fatal=False)
46 player_params = urllib.parse.parse_qs(self._search_regex(
47 r'<embed src="http://ft\.arkena\.tv/flash/ftplayer\.swf\?([^"]+)"',
48 webpage, 'player params'))
49 xml_url = player_params['xml'][0]
50 doc = self._download_xml(xml_url, video_id)
52 timestamp = parse_iso8601(xpath_text(doc, './/date'))
53 duration = parse_duration(xpath_text(doc, './/duration'))
54 width = int_or_none(xpath_text(doc, './/width'))
55 height = int_or_none(xpath_text(doc, './/height'))
56 view_count = int_or_none(xpath_text(doc, './/views'))
58 formats = [{
59 'format_id': n.attrib['bitrate'],
60 'url': xpath_text(n, './url', fatal=True),
61 'tbr': int_or_none(n.attrib['bitrate']),
62 } for n in doc.findall('.//streams/stream')]
64 return {
65 'id': video_id,
66 'title': title,
67 'formats': formats,
68 'description': description,
69 'timestamp': timestamp,
70 'width': width,
71 'height': height,
72 'duration': duration,
73 'view_count': view_count,