]>
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
21 class ABCIE ( InfoExtractor
):
22 IE_NAME
= 'abc.net.au'
23 _VALID_URL
= r
'https?://(?:www\.)?abc\.net\.au/news/(?:[^/]+/){1,2}(?P<id>\d+)'
26 'url' : 'http://www.abc.net.au/news/2014-11-05/australia-to-staff-ebola-treatment-centre-in-sierra-leone/5868334' ,
27 'md5' : 'cb3dd03b18455a661071ee1e28344d9f' ,
31 'title' : 'Australia to help staff Ebola treatment centre in Sierra Leone' ,
32 'description' : 'md5:809ad29c67a05f54eb41f2a105693a67' ,
34 'skip' : 'this video has expired' ,
36 'url' : 'http://www.abc.net.au/news/2015-08-17/warren-entsch-introduces-same-sex-marriage-bill/6702326' ,
37 'md5' : 'db2a5369238b51f9811ad815b69dc086' ,
41 'upload_date' : '20150816' ,
42 'uploader' : 'ABC News (Australia)' ,
43 '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' ,
44 'uploader_id' : 'NewsOnABC' ,
45 'title' : 'Marriage Equality: Warren Entsch introduces same sex marriage bill' ,
47 'add_ie' : [ 'Youtube' ],
48 'skip' : 'Not accessible from Travis CI server' ,
50 'url' : 'http://www.abc.net.au/news/2015-10-23/nab-lifts-interest-rates-following-westpac-and-cba/6880080' ,
51 'md5' : 'b96eee7c9edf4fc5a358a0252881cc1f' ,
55 'title' : 'NAB lifts interest rates, following Westpac and CBA' ,
56 'description' : 'md5:f13d8edc81e462fce4a0437c7dc04728' ,
59 'url' : 'http://www.abc.net.au/news/2015-10-19/6866214' ,
60 'only_matching' : True ,
63 def _real_extract ( self
, url
):
64 video_id
= self
._ match
_ id
( url
)
65 webpage
= self
._ download
_ webpage
( url
, video_id
)
68 r
'inline(?P<type>Video|Audio|YouTube)Data\.push\((?P<json_data>[^)]+)\);' ,
71 expired
= self
._ html
_ search
_ regex
( r
'(?s)class="expired-(?:video|audio)".+?<span>(.+?)</span>' , webpage
, 'expired' , None )
73 raise ExtractorError ( ' %s said: %s ' % ( self
. IE_NAME
, expired
), expected
= True )
74 raise ExtractorError ( 'Unable to extract video urls' )
76 urls_info
= self
._ parse
_ json
(
77 mobj
. group ( 'json_data' ), video_id
, transform_source
= js_to_json
)
79 if not isinstance ( urls_info
, list ):
80 urls_info
= [ urls_info
]
82 if mobj
. group ( 'type' ) == 'YouTube' :
83 return self
. playlist_result ([
84 self
. url_result ( url_info
[ 'url' ]) for url_info
in urls_info
])
87 'url' : url_info
[ 'url' ],
88 'vcodec' : url_info
. get ( 'codec' ) if mobj
. group ( 'type' ) == 'Video' else 'none' ,
89 'width' : int_or_none ( url_info
. get ( 'width' )),
90 'height' : int_or_none ( url_info
. get ( 'height' )),
91 'tbr' : int_or_none ( url_info
. get ( 'bitrate' )),
92 'filesize' : int_or_none ( url_info
. get ( 'filesize' )),
93 } for url_info
in urls_info
]
95 self
._ sort
_ formats
( formats
)
99 'title' : self
._ og
_ search
_ title
( webpage
),
101 'description' : self
._ og
_ search
_ description
( webpage
),
102 'thumbnail' : self
._ og
_ search
_ thumbnail
( webpage
),
106 class ABCIViewIE ( InfoExtractor
):
107 IE_NAME
= 'abc.net.au:iview'
108 _VALID_URL
= r
'https?://iview\.abc\.net\.au/programs/[^/]+/(?P<id>[^/?#]+)'
109 _GEO_COUNTRIES
= [ 'AU' ]
111 # ABC iview programs are normally available for 14 days only.
113 'url' : 'https://iview.abc.net.au/programs/ben-and-hollys-little-kingdom/ZY9247A021S00' ,
114 'md5' : 'cde42d728b3b7c2b32b1b94b4a548afc' ,
116 'id' : 'ZY9247A021S00' ,
118 'title' : "Gaston's Visit" ,
119 'series' : "Ben And Holly's Little Kingdom" ,
120 'description' : 'md5:18db170ad71cf161e006a4c688e33155' ,
121 'upload_date' : '20180318' ,
122 'uploader_id' : 'abc4kids' ,
123 'timestamp' : 1521400959 ,
126 'skip_download' : True ,
130 def _real_extract ( self
, url
):
131 video_id
= self
._ match
_ id
( url
)
132 webpage
= self
._ download
_ webpage
( url
, video_id
)
133 video_params
= self
._ parse
_ json
( self
._ search
_ regex
(
134 r
'videoParams\s*=\s*({.+?});' , webpage
, 'video params' ), video_id
)
135 title
= video_params
. get ( 'title' ) or video_params
[ 'seriesTitle' ]
136 stream
= next ( s
for s
in video_params
[ 'playlist' ] if s
. get ( 'type' ) == 'program' )
138 house_number
= video_params
. get ( 'episodeHouseNumber' )
139 path
= '/auth/hls/sign?ts= {0} &hn= {1} &d=android-mobile' . format (
140 int ( time
. time ()), house_number
)
142 'android.content.res.Resources' . encode ( 'utf-8' ),
143 path
. encode ( 'utf-8' ), hashlib
. sha256
). hexdigest ()
144 token
= self
._ download
_ webpage
(
145 'http://iview.abc.net.au {0} &sig= {1} ' . format ( path
, sig
), video_id
)
147 def tokenize_url ( url
, token
):
148 return update_url_query ( url
, {
152 for sd
in ( 'sd' , 'sd-low' ):
154 stream
, lambda x
: x
[ 'streams' ][ 'hls' ][ sd
], compat_str
)
157 formats
= self
._ extract
_ m
3u8_ formats
(
158 tokenize_url ( sd_url
, token
), video_id
, 'mp4' ,
159 entry_protocol
= 'm3u8_native' , m3u8_id
= 'hls' , fatal
= False )
162 self
._ sort
_ formats
( formats
)
165 src_vtt
= stream
. get ( 'captions' , {}). get ( 'src-vtt' )
174 'title' : unescapeHTML ( title
),
175 'description' : self
._ html
_ search
_ meta
([ 'og:description' , 'twitter:description' ], webpage
),
176 'thumbnail' : self
._ html
_ search
_ meta
([ 'og:image' , 'twitter:image:src' ], webpage
),
177 'duration' : int_or_none ( video_params
. get ( 'eventDuration' )),
178 'timestamp' : parse_iso8601 ( video_params
. get ( 'pubDate' ), ' ' ),
179 'series' : unescapeHTML ( video_params
. get ( 'seriesTitle' )),
180 'series_id' : video_params
. get ( 'seriesHouseNumber' ) or video_id
[: 7 ],
181 'episode_number' : int_or_none ( self
._ html
_ search
_ meta
( 'episodeNumber' , webpage
, default
= None )),
182 'episode' : self
._ html
_ search
_ meta
( 'episode_title' , webpage
, default
= None ),
183 'uploader_id' : video_params
. get ( 'channel' ),
185 'subtitles' : subtitles
,