| 
									
										
										
										
											2014-03-24 22:30:32 +01:00
										 |  |  | from __future__ import unicode_literals | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-11-24 07:51:44 +01:00
										 |  |  | import re | 
					
						
							|  |  |  | import time | 
					
						
							| 
									
										
										
										
											2013-11-27 18:33:51 +01:00
										 |  |  | import xml.etree.ElementTree | 
					
						
							| 
									
										
										
										
											2013-11-24 07:51:44 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | from .common import InfoExtractor | 
					
						
							| 
									
										
										
										
											2014-03-24 22:30:32 +01:00
										 |  |  | from ..utils import ( | 
					
						
							|  |  |  |     ExtractorError, | 
					
						
							|  |  |  |     parse_duration, | 
					
						
							|  |  |  | ) | 
					
						
							| 
									
										
										
										
											2013-11-24 07:51:44 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | class ClipfishIE(InfoExtractor): | 
					
						
							| 
									
										
										
										
											2014-03-24 22:30:32 +01:00
										 |  |  |     IE_NAME = 'clipfish' | 
					
						
							| 
									
										
										
										
											2013-11-24 07:51:44 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     _VALID_URL = r'^https?://(?:www\.)?clipfish\.de/.*?/video/(?P<id>[0-9]+)/' | 
					
						
							|  |  |  |     _TEST = { | 
					
						
							| 
									
										
										
										
											2014-03-24 22:30:32 +01:00
										 |  |  |         'url': 'http://www.clipfish.de/special/game-trailer/video/3966754/fifa-14-e3-2013-trailer/', | 
					
						
							|  |  |  |         'md5': '2521cd644e862936cf2e698206e47385', | 
					
						
							|  |  |  |         'info_dict': { | 
					
						
							|  |  |  |             'id': '3966754', | 
					
						
							|  |  |  |             'ext': 'mp4', | 
					
						
							|  |  |  |             'title': 'FIFA 14 - E3 2013 Trailer', | 
					
						
							|  |  |  |             'duration': 82, | 
					
						
							| 
									
										
										
										
											2013-12-01 01:16:20 +01:00
										 |  |  |         }, | 
					
						
							| 
									
										
										
										
											2014-11-26 13:06:02 +01:00
										 |  |  |         'skip': 'Blocked in the US' | 
					
						
							| 
									
										
										
										
											2013-11-24 07:51:44 +01:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     def _real_extract(self, url): | 
					
						
							|  |  |  |         mobj = re.match(self._VALID_URL, url) | 
					
						
							|  |  |  |         video_id = mobj.group(1) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         info_url = ('http://www.clipfish.de/devxml/videoinfo/%s?ts=%d' % | 
					
						
							|  |  |  |                     (video_id, int(time.time()))) | 
					
						
							| 
									
										
										
										
											2013-11-26 18:48:52 +01:00
										 |  |  |         doc = self._download_xml( | 
					
						
							| 
									
										
										
										
											2014-11-26 13:06:02 +01:00
										 |  |  |             info_url, video_id, note='Downloading info page') | 
					
						
							| 
									
										
										
										
											2013-11-24 07:51:44 +01:00
										 |  |  |         title = doc.find('title').text | 
					
						
							|  |  |  |         video_url = doc.find('filename').text | 
					
						
							| 
									
										
										
										
											2013-11-27 18:33:51 +01:00
										 |  |  |         if video_url is None: | 
					
						
							|  |  |  |             xml_bytes = xml.etree.ElementTree.tostring(doc) | 
					
						
							| 
									
										
										
										
											2014-03-24 22:30:32 +01:00
										 |  |  |             raise ExtractorError('Cannot find video URL in document %r' % | 
					
						
							| 
									
										
										
										
											2013-11-27 18:33:51 +01:00
										 |  |  |                                  xml_bytes) | 
					
						
							| 
									
										
										
										
											2013-11-24 07:51:44 +01:00
										 |  |  |         thumbnail = doc.find('imageurl').text | 
					
						
							| 
									
										
										
										
											2014-03-24 22:30:32 +01:00
										 |  |  |         duration = parse_duration(doc.find('duration').text) | 
					
						
							| 
									
										
										
										
											2013-11-24 07:51:44 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |         return { | 
					
						
							|  |  |  |             'id': video_id, | 
					
						
							|  |  |  |             'title': title, | 
					
						
							|  |  |  |             'url': video_url, | 
					
						
							|  |  |  |             'thumbnail': thumbnail, | 
					
						
							|  |  |  |             'duration': duration, | 
					
						
							|  |  |  |         } |