]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/abc.py
1 from __future__
import unicode_literals
8 from . common
import InfoExtractor
9 from .. compat
import compat_str
20 class ABCIE ( InfoExtractor
):
21 IE_NAME
= 'abc.net.au'
22 _VALID_URL
= r
'https?://(?:www\.)?abc\.net\.au/news/(?:[^/]+/){1,2}(?P<id>\d+)'
25 'url' : 'http://www.abc.net.au/news/2014-11-05/australia-to-staff-ebola-treatment-centre-in-sierra-leone/5868334' ,
26 'md5' : 'cb3dd03b18455a661071ee1e28344d9f' ,
30 'title' : 'Australia to help staff Ebola treatment centre in Sierra Leone' ,
31 'description' : 'md5:809ad29c67a05f54eb41f2a105693a67' ,
33 'skip' : 'this video has expired' ,
35 'url' : 'http://www.abc.net.au/news/2015-08-17/warren-entsch-introduces-same-sex-marriage-bill/6702326' ,
36 'md5' : 'db2a5369238b51f9811ad815b69dc086' ,
40 'upload_date' : '20150816' ,
41 'uploader' : 'ABC News (Australia)' ,
42 'description' : 'Government backbencher Warren Entsch introduces a cross-party sponsored bill to legalise same-sex marriage, saying the bill is designed to promote "an inclusive Australia, not a divided one.". Read more here: http://ab.co/1Mwc6ef' ,
43 'uploader_id' : 'NewsOnABC' ,
44 'title' : 'Marriage Equality: Warren Entsch introduces same sex marriage bill' ,
46 'add_ie' : [ 'Youtube' ],
47 'skip' : 'Not accessible from Travis CI server' ,
49 'url' : 'http://www.abc.net.au/news/2015-10-23/nab-lifts-interest-rates-following-westpac-and-cba/6880080' ,
50 'md5' : 'b96eee7c9edf4fc5a358a0252881cc1f' ,
54 'title' : 'NAB lifts interest rates, following Westpac and CBA' ,
55 'description' : 'md5:f13d8edc81e462fce4a0437c7dc04728' ,
58 'url' : 'http://www.abc.net.au/news/2015-10-19/6866214' ,
59 'only_matching' : True ,
62 def _real_extract ( self
, url
):
63 video_id
= self
._ match
_ id
( url
)
64 webpage
= self
._ download
_ webpage
( url
, video_id
)
67 r
'inline(?P<type>Video|Audio|YouTube)Data\.push\((?P<json_data>[^)]+)\);' ,
70 expired
= self
._ html
_ search
_ regex
( r
'(?s)class="expired-(?:video|audio)".+?<span>(.+?)</span>' , webpage
, 'expired' , None )
72 raise ExtractorError ( ' %s said: %s ' % ( self
. IE_NAME
, expired
), expected
= True )
73 raise ExtractorError ( 'Unable to extract video urls' )
75 urls_info
= self
._ parse
_ json
(
76 mobj
. group ( 'json_data' ), video_id
, transform_source
= js_to_json
)
78 if not isinstance ( urls_info
, list ):
79 urls_info
= [ urls_info
]
81 if mobj
. group ( 'type' ) == 'YouTube' :
82 return self
. playlist_result ([
83 self
. url_result ( url_info
[ 'url' ]) for url_info
in urls_info
])
86 'url' : url_info
[ 'url' ],
87 'vcodec' : url_info
. get ( 'codec' ) if mobj
. group ( 'type' ) == 'Video' else 'none' ,
88 'width' : int_or_none ( url_info
. get ( 'width' )),
89 'height' : int_or_none ( url_info
. get ( 'height' )),
90 'tbr' : int_or_none ( url_info
. get ( 'bitrate' )),
91 'filesize' : int_or_none ( url_info
. get ( 'filesize' )),
92 } for url_info
in urls_info
]
94 self
._ sort
_ formats
( formats
)
98 'title' : self
._ og
_ search
_ title
( webpage
),
100 'description' : self
._ og
_ search
_ description
( webpage
),
101 'thumbnail' : self
._ og
_ search
_ thumbnail
( webpage
),
105 class ABCIViewIE ( InfoExtractor
):
106 IE_NAME
= 'abc.net.au:iview'
107 _VALID_URL
= r
'https?://iview\.abc\.net\.au/programs/[^/]+/(?P<id>[^/?#]+)'
108 _GEO_COUNTRIES
= [ 'AU' ]
110 # ABC iview programs are normally available for 14 days only.
112 'url' : 'http://iview.abc.net.au/programs/call-the-midwife/ZW0898A003S00' ,
113 'md5' : 'cde42d728b3b7c2b32b1b94b4a548afc' ,
115 'id' : 'ZW0898A003S00' ,
117 'title' : 'Series 5 Ep 3' ,
118 'description' : 'md5:e0ef7d4f92055b86c4f33611f180ed79' ,
119 'upload_date' : '20171228' ,
120 'uploader_id' : 'abc1' ,
121 'timestamp' : 1514499187 ,
124 'skip_download' : True ,
128 def _real_extract ( self
, url
):
129 video_id
= self
._ match
_ id
( url
)
130 webpage
= self
._ download
_ webpage
( url
, video_id
)
131 video_params
= self
._ parse
_ json
( self
._ search
_ regex
(
132 r
'videoParams\s*=\s*({.+?});' , webpage
, 'video params' ), video_id
)
133 title
= video_params
. get ( 'title' ) or video_params
[ 'seriesTitle' ]
134 stream
= next ( s
for s
in video_params
[ 'playlist' ] if s
. get ( 'type' ) == 'program' )
136 house_number
= video_params
. get ( 'episodeHouseNumber' )
137 path
= '/auth/hls/sign?ts= {0} &hn= {1} &d=android-mobile' . format (
138 int ( time
. time ()), house_number
)
140 'android.content.res.Resources' . encode ( 'utf-8' ),
141 path
. encode ( 'utf-8' ), hashlib
. sha256
). hexdigest ()
142 token
= self
._ download
_ webpage
(
143 'http://iview.abc.net.au {0} &sig= {1} ' . format ( path
, sig
), video_id
)
145 def tokenize_url ( url
, token
):
146 return update_url_query ( url
, {
150 for sd
in ( 'sd' , 'sd-low' ):
152 stream
, lambda x
: x
[ 'streams' ][ 'hls' ][ sd
], compat_str
)
155 formats
= self
._ extract
_ m
3u8_ formats
(
156 tokenize_url ( sd_url
, token
), video_id
, 'mp4' ,
157 entry_protocol
= 'm3u8_native' , m3u8_id
= 'hls' , fatal
= False )
160 self
._ sort
_ formats
( formats
)
163 src_vtt
= stream
. get ( 'captions' , {}). get ( 'src-vtt' )
173 'description' : self
._ html
_ search
_ meta
([ 'og:description' , 'twitter:description' ], webpage
),
174 'thumbnail' : self
._ html
_ search
_ meta
([ 'og:image' , 'twitter:image:src' ], webpage
),
175 'duration' : int_or_none ( video_params
. get ( 'eventDuration' )),
176 'timestamp' : parse_iso8601 ( video_params
. get ( 'pubDate' ), ' ' ),
177 'series' : video_params
. get ( 'seriesTitle' ),
178 'series_id' : video_params
. get ( 'seriesHouseNumber' ) or video_id
[: 7 ],
179 'episode_number' : int_or_none ( self
._ html
_ search
_ meta
( 'episodeNumber' , webpage
, default
= None )),
180 'episode' : self
._ html
_ search
_ meta
( 'episode_title' , webpage
, default
= None ),
181 'uploader_id' : video_params
. get ( 'channel' ),
183 'subtitles' : subtitles
,