2016-01-15 11:45:51 -05:00
from . common import InfoExtractor
from . . utils import (
2018-10-17 01:22:07 -04:00
ExtractorError ,
2016-01-15 11:45:51 -05:00
int_or_none ,
2018-08-17 06:59:22 -04:00
parse_age_limit ,
2016-01-15 11:45:51 -05:00
parse_iso8601 ,
2018-08-17 06:59:22 -04:00
smuggle_url ,
str_or_none ,
2016-01-15 11:45:51 -05:00
)
class CWTVIE ( InfoExtractor ) :
2016-08-01 11:51:01 -04:00
_VALID_URL = r ' https?://(?:www \ .)?cw(?:tv(?:pr)?|seed) \ .com/(?:shows/)?(?:[^/]+/)+[^?]* \ ?.* \ b(?:play|watch)=(?P<id>[a-z0-9] {8} -[a-z0-9] {4} -[a-z0-9] {4} -[a-z0-9] {4} -[a-z0-9] {12} ) '
2016-01-15 11:45:51 -05:00
_TESTS = [ {
' url ' : ' http://cwtv.com/shows/arrow/legends-of-yesterday/?play=6b15e985-9345-4f60-baf8-56e96be57c63 ' ,
' info_dict ' : {
' id ' : ' 6b15e985-9345-4f60-baf8-56e96be57c63 ' ,
' ext ' : ' mp4 ' ,
' title ' : ' Legends of Yesterday ' ,
' description ' : ' Oliver and Barry Allen take Kendra Saunders and Carter Hall to a remote location to keep them hidden from Vandal Savage while they figure out how to defeat him. ' ,
' duration ' : 2665 ,
' series ' : ' Arrow ' ,
' season_number ' : 4 ,
' season ' : ' 4 ' ,
' episode_number ' : 8 ,
' upload_date ' : ' 20151203 ' ,
' timestamp ' : 1449122100 ,
} ,
' params ' : {
# m3u8 download
' skip_download ' : True ,
2016-08-07 17:56:04 -04:00
} ,
' skip ' : ' redirect to http://cwtv.com/shows/arrow/ ' ,
2016-01-15 11:45:51 -05:00
} , {
' url ' : ' http://www.cwseed.com/shows/whose-line-is-it-anyway/jeff-davis-4/?play=24282b12-ead2-42f2-95ad-26770c2c6088 ' ,
' info_dict ' : {
' id ' : ' 24282b12-ead2-42f2-95ad-26770c2c6088 ' ,
' ext ' : ' mp4 ' ,
' title ' : ' Jeff Davis 4 ' ,
' description ' : ' Jeff Davis is back to make you laugh. ' ,
' duration ' : 1263 ,
' series ' : ' Whose Line Is It Anyway? ' ,
' season_number ' : 11 ,
' episode_number ' : 20 ,
' upload_date ' : ' 20151006 ' ,
' timestamp ' : 1444107300 ,
2018-08-17 06:59:22 -04:00
' age_limit ' : 14 ,
' uploader ' : ' CWTV ' ,
2023-12-11 19:00:35 -05:00
' thumbnail ' : r ' re:^https?://.* \ .jpe?g$ ' ,
' chapters ' : ' count:4 ' ,
' episode ' : ' Episode 20 ' ,
' season ' : ' Season 11 ' ,
2018-08-17 06:59:22 -04:00
} ,
' params ' : {
# m3u8 download
' skip_download ' : True ,
2016-01-15 11:45:51 -05:00
} ,
2016-04-27 18:01:21 -04:00
} , {
' url ' : ' http://cwtv.com/thecw/chroniclesofcisco/?play=8adebe35-f447-465f-ab52-e863506ff6d6 ' ,
' only_matching ' : True ,
2016-08-01 11:51:01 -04:00
} , {
' url ' : ' http://cwtvpr.com/the-cw/video?watch=9eee3f60-ef4e-440b-b3b2-49428ac9c54e ' ,
' only_matching ' : True ,
} , {
' url ' : ' http://cwtv.com/shows/arrow/legends-of-yesterday/?watch=6b15e985-9345-4f60-baf8-56e96be57c63 ' ,
' only_matching ' : True ,
2016-01-15 11:45:51 -05:00
} ]
def _real_extract ( self , url ) :
video_id = self . _match_id ( url )
2018-10-17 01:22:07 -04:00
data = self . _download_json (
2018-08-17 06:59:22 -04:00
' http://images.cwtv.com/feed/mobileapp/video-meta/apiversion_8/guid_ ' + video_id ,
2018-10-17 01:22:07 -04:00
video_id )
if data . get ( ' result ' ) != ' ok ' :
raise ExtractorError ( data [ ' msg ' ] , expected = True )
video_data = data [ ' video ' ]
2018-08-17 06:59:22 -04:00
title = video_data [ ' title ' ]
2024-06-11 19:09:58 -04:00
mpx_url = video_data . get ( ' mpx_url ' ) or f ' http://link.theplatform.com/s/cwtv/media/guid/2703454149/ { video_id } ?formats=M3U '
2016-01-15 11:45:51 -05:00
2018-08-17 06:59:22 -04:00
season = str_or_none ( video_data . get ( ' season ' ) )
episode = str_or_none ( video_data . get ( ' episode ' ) )
if episode and season :
2019-03-27 13:01:51 -04:00
episode = episode [ len ( season ) : ]
2016-01-15 11:45:51 -05:00
return {
2018-08-17 06:59:22 -04:00
' _type ' : ' url_transparent ' ,
2016-01-15 11:45:51 -05:00
' id ' : video_id ,
2018-08-17 06:59:22 -04:00
' title ' : title ,
' url ' : smuggle_url ( mpx_url , { ' force_smil_url ' : True } ) ,
' description ' : video_data . get ( ' description_long ' ) ,
' duration ' : int_or_none ( video_data . get ( ' duration_secs ' ) ) ,
' series ' : video_data . get ( ' series_name ' ) ,
' season_number ' : int_or_none ( season ) ,
' episode_number ' : int_or_none ( episode ) ,
' timestamp ' : parse_iso8601 ( video_data . get ( ' start_time ' ) ) ,
' age_limit ' : parse_age_limit ( video_data . get ( ' rating ' ) ) ,
' ie_key ' : ' ThePlatform ' ,
2024-06-11 19:09:58 -04:00
' thumbnail ' : video_data . get ( ' large_thumbnail ' ) ,
2016-01-15 11:45:51 -05:00
}