]>
jfr.im git - yt-dlp.git/blob - youtube_dl/extractor/adultswim.py
2 from __future__
import unicode_literals
6 from . turner
import TurnerBaseIE
13 class AdultSwimIE ( TurnerBaseIE
):
14 _VALID_URL
= r
'https?://(?:www\.)?adultswim\.com/videos/(?P<is_playlist>playlists/)?(?P<show_path>[^/]+)/(?P<episode_path>[^/?#]+)/?'
17 'url' : 'http://adultswim.com/videos/rick-and-morty/pilot' ,
20 'md5' : '247572debc75c7652f253c8daa51a14d' ,
22 'id' : 'rQxZvXQ4ROaSOqq-or2Mow-0' ,
24 'title' : 'Rick and Morty - Pilot Part 1' ,
25 'description' : "Rick moves in with his daughter's family and establishes himself as a bad influence on his grandson, Morty. "
29 'md5' : '77b0e037a4b20ec6b98671c4c379f48d' ,
31 'id' : 'rQxZvXQ4ROaSOqq-or2Mow-3' ,
33 'title' : 'Rick and Morty - Pilot Part 4' ,
34 'description' : "Rick moves in with his daughter's family and establishes himself as a bad influence on his grandson, Morty. "
39 'id' : 'rQxZvXQ4ROaSOqq-or2Mow' ,
40 'title' : 'Rick and Morty - Pilot' ,
41 'description' : "Rick moves in with his daughter's family and establishes himself as a bad influence on his grandson, Morty. "
43 'skip' : 'This video is only available for registered users' ,
45 'url' : 'http://www.adultswim.com/videos/playlists/american-parenting/putting-francine-out-of-business/' ,
48 'md5' : '2eb5c06d0f9a1539da3718d897f13ec5' ,
50 'id' : '-t8CamQlQ2aYZ49ItZCFog-0' ,
52 'title' : 'American Dad - Putting Francine Out of Business' ,
53 'description' : 'Stan hatches a plan to get Francine out of the real estate business.Watch more American Dad on [adult swim].'
58 'id' : '-t8CamQlQ2aYZ49ItZCFog' ,
59 'title' : 'American Dad - Putting Francine Out of Business' ,
60 'description' : 'Stan hatches a plan to get Francine out of the real estate business.Watch more American Dad on [adult swim].'
63 'url' : 'http://www.adultswim.com/videos/tim-and-eric-awesome-show-great-job/dr-steve-brule-for-your-wine/' ,
66 'md5' : '3e346a2ab0087d687a05e1e7f3b3e529' ,
68 'id' : 'sY3cMUR_TbuE4YmdjzbIcQ-0' ,
70 'title' : 'Tim and Eric Awesome Show Great Job! - Dr. Steve Brule, For Your Wine' ,
71 'description' : 'Dr. Brule reports live from Wine Country with a special report on wines. \r\n Watch Tim and Eric Awesome Show Great Job! episode #20, "Embarrassed" on Adult Swim. \r\n\r\n ' ,
76 'id' : 'sY3cMUR_TbuE4YmdjzbIcQ' ,
77 'title' : 'Tim and Eric Awesome Show Great Job! - Dr. Steve Brule, For Your Wine' ,
78 'description' : 'Dr. Brule reports live from Wine Country with a special report on wines. \r\n Watch Tim and Eric Awesome Show Great Job! episode #20, "Embarrassed" on Adult Swim. \r\n\r\n ' ,
82 'skip_download' : True ,
85 # heroMetadata.trailer
86 'url' : 'http://www.adultswim.com/videos/decker/inside-decker-a-new-hero/' ,
88 'id' : 'I0LQFQkaSUaFp8PnAWHhoQ' ,
90 'title' : 'Decker - Inside Decker: A New Hero' ,
91 'description' : 'md5:c916df071d425d62d70c86d4399d3ee0' ,
96 'skip_download' : True ,
98 'expected_warnings' : [ 'Unable to download f4m manifest' ],
102 def find_video_info ( collection
, slug
):
103 for video
in collection
. get ( 'videos' ):
104 if video
. get ( 'slug' ) == slug
:
108 def find_collection_by_linkURL ( collections
, linkURL
):
109 for collection
in collections
:
110 if collection
. get ( 'linkURL' ) == linkURL
:
114 def find_collection_containing_video ( collections
, slug
):
115 for collection
in collections
:
116 for video
in collection
. get ( 'videos' ):
117 if video
. get ( 'slug' ) == slug
:
118 return collection
, video
121 def _real_extract ( self
, url
):
122 mobj
= re
. match ( self
._ VALID
_U RL
, url
)
123 show_path
= mobj
. group ( 'show_path' )
124 episode_path
= mobj
. group ( 'episode_path' )
125 is_playlist
= True if mobj
. group ( 'is_playlist' ) else False
127 webpage
= self
._ download
_ webpage
( url
, episode_path
)
129 # Extract the value of `bootstrappedData` from the Javascript in the page.
130 bootstrapped_data
= self
._ parse
_ json
( self
._ search
_ regex
(
131 r
'var bootstrappedData = ( {.*} );' , webpage
, 'bootstraped data' ), episode_path
)
133 # Downloading videos from a /videos/playlist/ URL needs to be handled differently.
134 # NOTE: We are only downloading one video (the current one) not the playlist
136 collections
= bootstrapped_data
[ 'playlists' ][ 'collections' ]
137 collection
= self
. find_collection_by_linkURL ( collections
, show_path
)
138 video_info
= self
. find_video_info ( collection
, episode_path
)
140 show_title
= video_info
[ 'showTitle' ]
141 segment_ids
= [ video_info
[ 'videoPlaybackID' ]]
143 collections
= bootstrapped_data
[ 'show' ][ 'collections' ]
144 collection
, video_info
= self
. find_collection_containing_video ( collections
, episode_path
)
145 # Video wasn't found in the collections, let's try `slugged_video`.
146 if video_info
is None :
147 if bootstrapped_data
. get ( 'slugged_video' , {}). get ( 'slug' ) == episode_path
:
148 video_info
= bootstrapped_data
[ 'slugged_video' ]
150 video_info
= bootstrapped_data
. get (
151 'heroMetadata' , {}).get('trailer', {}
). get ( 'video' )
153 video_info
= bootstrapped_data
. get ( 'onlineOriginals' , [ None ])[ 0 ]
155 raise ExtractorError ( 'Unable to find video info' )
157 show
= bootstrapped_data
[ 'show' ]
158 show_title
= show
[ 'title' ]
159 stream
= video_info
. get ( 'stream' )
160 if stream
and stream
. get ( 'videoPlaybackID' ):
161 segment_ids
= [ stream
[ 'videoPlaybackID' ]]
162 elif video_info
. get ( 'clips' ):
163 segment_ids
= [ clip
[ 'videoPlaybackID' ] for clip
in video_info
[ 'clips' ]]
164 elif video_info
. get ( 'videoPlaybackID' ):
165 segment_ids
= [ video_info
[ 'videoPlaybackID' ]]
167 if video_info
. get ( 'auth' ) is True :
168 raise ExtractorError (
169 'This video is only available via cable service provider subscription that'
170 ' is not currently supported. You may want to use --cookies.' , expected
= True )
172 raise ExtractorError ( 'Unable to find stream or clips' )
174 episode_id
= video_info
[ 'id' ]
175 episode_title
= video_info
[ 'title' ]
176 episode_description
= video_info
. get ( 'description' )
177 episode_duration
= int_or_none ( video_info
. get ( 'duration' ))
178 view_count
= int_or_none ( video_info
. get ( 'views' ))
181 for part_num
, segment_id
in enumerate ( segment_ids
):
182 segement_info
= self
._ extract
_ cvp
_ info
(
183 'http://www.adultswim.com/videos/api/v0/assets?id= %s &platform=desktop' % segment_id
,
186 'media_src' : 'http://androidhls-secure.cdn.turner.com/adultswim/big' ,
187 'tokenizer_src' : 'http://www.adultswim.com/astv/mvpd/processors/services/token_ipadAdobe.do' ,
190 segment_title
= ' %s - %s ' % ( show_title
, episode_title
)
191 if len ( segment_ids
) > 1 :
192 segment_title
+= ' Part %d ' % ( part_num
+ 1 )
193 segement_info
. update ({
195 'title' : segment_title
,
196 'description' : episode_description
,
198 entries
. append ( segement_info
)
203 'display_id' : episode_path
,
205 'title' : ' %s - %s ' % ( show_title
, episode_title
),
206 'description' : episode_description
,
207 'duration' : episode_duration
,
208 'view_count' : view_count
,