]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/zdf.py
2 from __future__
import unicode_literals
6 from . common
import InfoExtractor
13 class ZDFIE ( InfoExtractor
):
14 _VALID_URL
= r
'^https?://www\.zdf\.de/ZDFmediathek(?P<hash>#)?/(.*beitrag/(?:video/)?)(?P<video_id>[0-9]+)(?:/[^/?]+)?(?:\?.*)?'
17 'url' : 'http://www.zdf.de/ZDFmediathek/beitrag/video/2037704/ZDFspezial---Ende-des-Machtpokers--?bc=sts;stt' ,
21 'title' : 'ZDFspezial - Ende des Machtpokers' ,
22 'description' : 'Union und SPD haben sich auf einen Koalitionsvertrag geeinigt. Aber was bedeutet das für die Bürger? Sehen Sie hierzu das ZDFspezial "Ende des Machtpokers - Große Koalition für Deutschland".' ,
24 'uploader' : 'spezial' ,
25 'uploader_id' : '225948' ,
26 'upload_date' : '20131127' ,
28 'skip' : 'Videos on ZDF.de are depublicised in short order' ,
31 def _real_extract ( self
, url
):
32 mobj
= re
. match ( self
._ VALID
_U RL
, url
)
33 video_id
= mobj
. group ( 'video_id' )
35 xml_url
= 'http://www.zdf.de/ZDFmediathek/xmlservice/web/beitragsDetails?ak=web&id= %s ' % video_id
36 doc
= self
._ download
_ xml
(
38 note
= 'Downloading video info' ,
39 errnote
= 'Failed to download video info' )
41 title
= doc
. find ( './/information/title' ). text
42 description
= doc
. find ( './/information/detail' ). text
43 duration
= int ( doc
. find ( './/details/lengthSec' ). text
)
44 uploader_node
= doc
. find ( './/details/originChannelTitle' )
45 uploader
= None if uploader_node
is None else uploader_node
. text
46 uploader_id_node
= doc
. find ( './/details/originChannelId' )
47 uploader_id
= None if uploader_id_node
is None else uploader_id_node
. text
48 upload_date
= unified_strdate ( doc
. find ( './/details/airtime' ). text
)
50 def xml_to_format ( fnode
):
51 video_url
= fnode
. find ( 'url' ). text
52 is_available
= 'http://www.metafilegenerator' not in video_url
54 format_id
= fnode
. attrib
[ 'basetype' ]
55 format_m
= re
. match ( r
'''(?x)
56 (?P<vcodec>[^_]+)_(?P<acodec>[^_]+)_(?P<container>[^_]+)_
57 (?P<proto>[^_]+)_(?P<index>[^_]+)_(?P<indexproto>[^_]+)
60 ext
= format_m
. group ( 'container' )
61 proto
= format_m
. group ( 'proto' ). lower ()
63 quality
= fnode
. find ( './quality' ). text
64 abr
= int ( fnode
. find ( './audioBitrate' ). text
) // 1000
65 vbr_node
= fnode
. find ( './videoBitrate' )
66 vbr
= None if vbr_node
is None else int ( vbr_node
. text
) // 1000
68 width_node
= fnode
. find ( './width' )
69 width
= None if width_node
is None else int_or_none ( width_node
. text
)
70 height_node
= fnode
. find ( './height' )
71 height
= None if height_node
is None else int_or_none ( height_node
. text
)
78 'format_id' : format_id
+ '-' + quality
,
81 'acodec' : format_m
. group ( 'acodec' ),
82 'vcodec' : format_m
. group ( 'vcodec' ),
87 'filesize' : int_or_none ( fnode
. find ( './filesize' ). text
),
88 'format_note' : format_note
,
90 '_available' : is_available
,
93 format_nodes
= doc
. findall ( './/formitaeten/formitaet' )
94 formats
= list ( filter (
95 lambda f
: f
[ '_available' ],
96 map ( xml_to_format
, format_nodes
)))
98 self
._ sort
_ formats
( formats
)
103 'description' : description
,
104 'duration' : duration
,
105 'uploader' : uploader
,
106 'uploader_id' : uploader_id
,
107 'upload_date' : upload_date
,