]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/dreisat.py
4 import xml
. etree
. ElementTree
6 from . common
import InfoExtractor
13 class DreiSatIE ( InfoExtractor
):
15 _VALID_URL
= r
'(?:http://)?(?:www\.)?3sat.de/mediathek/index.php\?(?:(?:mode|display)=[^&]+&)*obj=(?P<id>[0-9]+)$'
17 u
"url" : u
"http://www.3sat.de/mediathek/index.php?obj=36983" ,
18 u
'file' : u
'36983.webm' ,
19 u
'md5' : u
'57c97d0469d71cf874f6815aa2b7c944' ,
21 u
"title" : u
"Kaffeeland Schweiz" ,
22 u
"description" : u
"Über 80 Kaffeeröstereien liefern in der Schweiz das Getränk, in das das Land so vernarrt ist: Mehr als 1000 Tassen trinkt ein Schweizer pro Jahr. SCHWEIZWEIT nimmt die Kaffeekultur unter die..." ,
24 u
"upload_date" : u
"20130622"
29 def _real_extract ( self
, url
):
30 mobj
= re
. match ( self
._ VALID
_U RL
, url
)
31 video_id
= mobj
. group ( 'id' )
32 details_url
= 'http://www.3sat.de/mediathek/xmlservice/web/beitragsDetails?ak=web&id= %s ' % video_id
33 details_xml
= self
._ download
_ webpage
( details_url
, video_id
, note
= u
'Downloading video details' )
34 details_doc
= xml
. etree
. ElementTree
. fromstring ( details_xml
. encode ( 'utf-8' ))
36 thumbnail_els
= details_doc
. findall ( './/teaserimage' )
38 'width' : te
. attrib
[ 'key' ]. partition ( 'x' )[ 0 ],
39 'height' : te
. attrib
[ 'key' ]. partition ( 'x' )[ 2 ],
41 } for te
in thumbnail_els
]
43 information_el
= details_doc
. find ( './/information' )
44 video_title
= information_el
. find ( './title' ). text
45 video_description
= information_el
. find ( './detail' ). text
47 details_el
= details_doc
. find ( './/details' )
48 video_uploader
= details_el
. find ( './channel' ). text
49 upload_date
= unified_strdate ( details_el
. find ( './airtime' ). text
)
51 format_els
= details_doc
. findall ( './/formitaet' )
53 'format_id' : fe
. attrib
[ 'basetype' ],
54 'width' : int ( fe
. find ( './width' ). text
),
55 'height' : int ( fe
. find ( './height' ). text
),
56 'url' : fe
. find ( './url' ). text
,
57 'filesize' : int ( fe
. find ( './filesize' ). text
),
58 'video_bitrate' : int ( fe
. find ( './videoBitrate' ). text
),
59 '3sat_qualityname' : fe
. find ( './quality' ). text
,
60 } for fe
in format_els
61 if not fe
. find ( './url' ). text
. startswith ( 'http://www.metafilegenerator.de/' )]
64 qidx
= [ 'low' , 'med' , 'high' , 'veryhigh' ]. index ( format
[ '3sat_qualityname' ])
65 prefer_http
= 1 if 'rtmp' in format
[ 'url' ] else 0
66 return ( qidx
, prefer_http
, format
[ 'video_bitrate' ])
67 formats
. sort ( key
= _sortkey
)
74 'description' : video_description
,
75 'thumbnails' : thumbnails
,
76 'thumbnail' : thumbnails
[- 1 ][ 'url' ],
77 'uploader' : video_uploader
,
78 'upload_date' : upload_date
,
81 # TODO: Remove when #980 has been merged
82 info
[ 'url' ] = formats
[- 1 ][ 'url' ]
83 info
[ 'ext' ] = determine_ext ( formats
[- 1 ][ 'url' ])