2016-08-19 20:39:28 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								# coding: utf-8  
						 
					
						
							
								
									
										
										
										
											2015-02-02 21:48:54 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								from  __future__  import  unicode_literals  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-08-19 20:39:28 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								import  re  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-02-02 21:48:54 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								from  . common  import  InfoExtractor  
						 
					
						
							
								
									
										
										
										
											2016-01-14 22:05:04 +06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								from  . . compat  import  compat_urlparse  
						 
					
						
							
								
									
										
										
										
											2015-02-02 21:48:54 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								from  . . utils  import  (  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    int_or_none , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    js_to_json , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    parse_duration , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								)  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								class  NTVDeIE ( InfoExtractor ) :  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    IE_NAME  =  ' n-tv.de ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    _VALID_URL  =  r ' https?://(?:www \ .)?n-tv \ .de/mediathek/videos/[^/?#]+/[^/?#]+-article(?P<id>.+) \ .html ' 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    _TESTS  =  [ { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        ' url ' :  ' http://www.n-tv.de/mediathek/videos/panorama/Schnee-und-Glaette-fuehren-zu-zahlreichen-Unfaellen-und-Staus-article14438086.html ' , 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-02 21:57:48 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        ' md5 ' :  ' 6ef2514d4b1e8e03ca24b49e2f167153 ' , 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-02 21:48:54 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        ' info_dict ' :  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ' id ' :  ' 14438086 ' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ' ext ' :  ' mp4 ' , 
							 
						 
					
						
							
								
									
										
										
										
											2017-01-02 20:08:07 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            ' thumbnail ' :  r ' re:^https?://.* \ .jpg$ ' , 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-02 21:48:54 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								            ' title ' :  ' Schnee und Glätte führen zu zahlreichen Unfällen und Staus ' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ' alt_title ' :  ' Winterchaos auf deutschen Straßen ' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ' description ' :  ' Schnee und Glätte sorgen deutschlandweit für einen chaotischen Start in die Woche: Auf den Straßen kommt es zu kilometerlangen Staus und Dutzenden Glätteunfällen. In Düsseldorf und München wirbelt der Schnee zudem den Flugplan durcheinander. Dutzende Flüge landen zu spät, einige fallen ganz aus. ' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ' duration ' :  4020 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ' timestamp ' :  1422892797 , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ' upload_date ' :  ' 20150202 ' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    def  _real_extract ( self ,  url ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        video_id  =  self . _match_id ( url ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        webpage  =  self . _download_webpage ( url ,  video_id ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        info  =  self . _parse_json ( self . _search_regex ( 
							 
						 
					
						
							
								
									
										
										
										
											2016-01-14 22:12:24 +06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            r ' (?s)ntv \ .pageInfo \ .article \ s*= \ s*( \ { .*? \ }); ' ,  webpage ,  ' info ' ) , 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-02 21:48:54 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								            video_id ,  transform_source = js_to_json ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        timestamp  =  int_or_none ( info . get ( ' publishedDateAsUnixTimeStamp ' ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        vdata  =  self . _parse_json ( self . _search_regex ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            r ' (?s) \ $ \ ( \ s* " \ #player " \ s* \ ) \ s* \ .data \ ( \ s* " player " , \ s*( \ { .*? \ }) \ ); ' , 
							 
						 
					
						
							
								
									
										
										
										
											2016-08-19 20:39:28 +08:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            webpage ,  ' player data ' ) ,  video_id , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            transform_source = lambda  s :  js_to_json ( re . sub ( r ' advertising: \ s* { [^}]+}, ' ,  ' ' ,  s ) ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-02 21:48:54 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        duration  =  parse_duration ( vdata . get ( ' duration ' ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2016-01-14 22:05:04 +06:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        formats  =  [ ] 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  vdata . get ( ' video ' ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            formats . append ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                ' format_id ' :  ' flash ' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                ' url ' :  ' rtmp://fms.n-tv.de/ %s '  %  vdata [ ' video ' ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  vdata . get ( ' videoMp4 ' ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            formats . append ( { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                ' format_id ' :  ' mobile ' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                ' url ' :  compat_urlparse . urljoin ( ' http://video.n-tv.de ' ,  vdata [ ' videoMp4 ' ] ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                ' tbr ' :  400 ,   # estimation 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        if  vdata . get ( ' videoM3u8 ' ) : 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            m3u8_url  =  compat_urlparse . urljoin ( ' http://video.n-tv.de ' ,  vdata [ ' videoM3u8 ' ] ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            formats . extend ( self . _extract_m3u8_formats ( 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                m3u8_url ,  video_id ,  ext = ' mp4 ' ,  entry_protocol = ' m3u8_native ' , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								                preference = 0 ,  m3u8_id = ' hls ' ,  fatal = False ) ) 
							 
						 
					
						
							
								
									
										
										
										
											2015-02-02 21:48:54 +01:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								        self . _sort_formats ( formats ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        return  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ' id ' :  video_id , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ' title ' :  info [ ' headline ' ] , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ' description ' :  info . get ( ' intro ' ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ' alt_title ' :  info . get ( ' kicker ' ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ' timestamp ' :  timestamp , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ' thumbnail ' :  vdata . get ( ' html5VideoPoster ' ) , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ' duration ' :  duration , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            ' formats ' :  formats , 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        }