mirror of
				https://github.com/yt-dlp/yt-dlp.git
				synced 2025-10-31 14:45:14 +00:00 
			
		
		
		
	Added an IE for todou
This commit is contained in:
		
							
								
								
									
										32
									
								
								youtube_dl/extractor/tudou.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								youtube_dl/extractor/tudou.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,32 @@ | ||||
| import re | ||||
|  | ||||
| from .common import InfoExtractor | ||||
|  | ||||
|  | ||||
| class TudouIE(InfoExtractor): | ||||
|     _VALID_URL = r'(?:http://)?(?:www\.)?tudou\.com/(?:listplay|programs)/(?:view|(.+?))/(?:([^/]+)|([^/]+)\.html)' | ||||
|  | ||||
|     def _real_extract(self, url): | ||||
|         mobj = re.match(self._VALID_URL, url) | ||||
|         video_id = mobj.group(2).replace('.html','') | ||||
|         webpage = self._download_webpage(url, video_id) | ||||
|         video_id = re.search('"k":(.+?),',webpage).group(1) | ||||
|         title = re.search(",kw:\"(.+)\"",webpage) | ||||
|         if title is None: | ||||
|             title = re.search(",kw: \'(.+)\'",webpage) | ||||
|         title = title.group(1) | ||||
|         thumbnail_url = re.search(",pic: \'(.+?)\'",webpage) | ||||
|         if thumbnail_url is None: | ||||
|             thumbnail_url = re.search(",pic:\"(.+?)\"",webpage) | ||||
|         thumbnail_url = thumbnail_url.group(1) | ||||
|         info_url = "http://v2.tudou.com/f?id="+str(video_id) | ||||
|         webpage = self._download_webpage(info_url, video_id, "Opening the info webpage") | ||||
|         final_url = re.search('\>(.+?)\<\/f\>',webpage).group(1) | ||||
|         ext = (final_url.split('?')[0]).split('.')[-1] | ||||
|         return [{ | ||||
|             'id':        video_id, | ||||
|             'url':       final_url, | ||||
|             'ext':       ext, | ||||
|             'title':     title, | ||||
|             'thumbnail': thumbnail_url, | ||||
|         }] | ||||
		Reference in New Issue
	
	Block a user
	 M.Yasoob Khalid
					M.Yasoob Khalid