2024-06-11 23:09:58 +00:00
import urllib . parse
2014-04-03 22:05:43 +00:00
from . common import InfoExtractor
class MotorsportIE ( InfoExtractor ) :
2024-03-09 00:02:45 +00:00
_WORKING = False
2014-04-03 22:05:43 +00:00
IE_DESC = ' motorsport.com '
2016-09-08 11:29:05 +00:00
_VALID_URL = r ' https?://(?:www \ .)?motorsport \ .com/[^/?#]+/video/(?:[^/?#]+/)(?P<id>[^/]+)/?(?:$|[?#]) '
2014-04-03 22:05:43 +00:00
_TEST = {
' url ' : ' http://www.motorsport.com/f1/video/main-gallery/red-bull-racing-2014-rules-explained/ ' ,
' info_dict ' : {
2015-01-05 18:14:50 +00:00
' id ' : ' 2-T3WuR-KMM ' ,
2014-04-03 22:05:43 +00:00
' ext ' : ' mp4 ' ,
' title ' : ' Red Bull Racing: 2014 Rules Explained ' ,
2015-01-05 18:14:50 +00:00
' duration ' : 208 ,
2014-04-03 22:05:43 +00:00
' description ' : ' A new clip from Red Bull sees Daniel Ricciardo and Sebastian Vettel explain the 2014 Formula One regulations – which are arguably the most complex the sport has ever seen. ' ,
2015-01-05 18:14:50 +00:00
' uploader ' : ' mcomstaff ' ,
' uploader_id ' : ' UC334JIYKkVnyFoNCclfZtHQ ' ,
' upload_date ' : ' 20140903 ' ,
2024-06-11 23:09:58 +00:00
' thumbnail ' : r ' re:^https?://.+ \ .jpg$ ' ,
2015-01-05 18:14:50 +00:00
} ,
' add_ie ' : [ ' Youtube ' ] ,
' params ' : {
' skip_download ' : True ,
} ,
2014-04-03 22:05:43 +00:00
}
def _real_extract ( self , url ) :
2014-12-13 11:24:42 +00:00
display_id = self . _match_id ( url )
2014-04-03 22:05:43 +00:00
webpage = self . _download_webpage ( url , display_id )
2014-12-13 11:24:42 +00:00
2015-01-05 18:14:50 +00:00
iframe_path = self . _html_search_regex (
2022-09-01 20:21:04 +00:00
r ' <iframe id= " player_iframe " [^>]+src= " ([^ " ]+) " ' , webpage , ' iframe path ' , default = None )
if iframe_path is None :
iframe_path = self . _html_search_regex (
r ' <iframe [^>]* \ bsrc= " (https://motorsport \ .tv/embed/[^ " ]+) ' , webpage , ' embed iframe path ' )
return self . url_result ( iframe_path )
2015-01-05 18:14:50 +00:00
iframe = self . _download_webpage (
2024-06-11 23:09:58 +00:00
urllib . parse . urljoin ( url , iframe_path ) , display_id ,
2015-01-05 18:14:50 +00:00
' Downloading iframe ' )
youtube_id = self . _search_regex (
r ' www.youtube.com/embed/(. {11} ) ' , iframe , ' youtube id ' )
2014-04-03 22:05:43 +00:00
return {
2015-01-05 18:14:50 +00:00
' _type ' : ' url_transparent ' ,
2014-04-03 22:05:43 +00:00
' display_id ' : display_id ,
2024-06-11 23:09:58 +00:00
' url ' : f ' https://youtube.com/watch?v= { youtube_id } ' ,
2014-04-03 22:05:43 +00:00
}