[chilloutzone] Bug fix, runs against tests

Fixes a bug with python3.3 and made the extractor run successfully
against tox
pull/2338/head^2
Andreas Schmitz 11 years ago
parent 46a073bfac
commit cd8662de22

@ -9,92 +9,85 @@ video_container = ('.mp4', '.mkv', '.flv')
class ChilloutzoneIE(InfoExtractor): class ChilloutzoneIE(InfoExtractor):
_VALID_URL = r'(?:https?://)?(?:www\.)?chilloutzone\.net/video/(?P<id>[\w|-]+).html' _VALID_URL = r'(?:https?://)?(?:www\.)?chilloutzone\.net/video/(?P<id>[\w|-]+).html'
_TEST = { _TEST = {
u'url': u'http://www.chilloutzone.net/video/enemene-meck-alle-katzen-weg.html', 'url': 'http://www.chilloutzone.net/video/enemene-meck-alle-katzen-weg.html',
u'file': u'18088-enemene-meck-alle-katzen-weg.mp4', 'md5': 'a76f3457e813ea0037e5244f509e66d1',
u'md5': u'a76f3457e813ea0037e5244f509e66d1', 'info_dict': {
u'info_dict': { 'id': 'enemene-meck-alle-katzen-weg',
u"id": u"18088", 'ext': 'mp4',
u"ext": u"mp4", 'title': 'Enemene Meck - Alle Katzen weg',
u"title": u"Enemene Meck - Alle Katzen weg" },
} }
}
def _real_extract(self, url): def _real_extract(self, url):
mobj = re.match(self._VALID_URL, url) mobj = re.match(self._VALID_URL, url)
video_id = mobj.group('id') video_id = mobj.group('id')
webpage_url = 'http://www.chilloutzone.net/video/' + video_id + '.html' webpage_url = 'http://www.chilloutzone.net/video/' + video_id + '.html'
# Log that we are starting to download the page # Log that we are starting to download the page
self.report_download_webpage(webpage_url) self.report_download_webpage(webpage_url)
webpage = self._download_webpage(webpage_url, video_id) webpage = self._download_webpage(webpage_url, video_id)
# Log that we are starting to parse the page
self.report_extraction(video_id)
# Log that we are starting to parse the page # Find base64 decoded file info
self.report_extraction(video_id) base64_video_info = self._html_search_regex(r'var cozVidData = "(.+?)";', webpage, u'video Data')
# Find base64 decoded file info # decode string and find video file
base64_video_info = self._html_search_regex(r'var cozVidData = "(.+?)";', webpage, u'video Data') decoded_video_info = base64.b64decode(base64_video_info).decode("utf-8")
# decode string and find video file video_info_dict = json.loads(decoded_video_info)
decoded_video_info = base64.b64decode(base64_video_info) # get video information from dict
video_info_dict = json.loads(decoded_video_info) media_url = video_info_dict['mediaUrl']
# get video information from dict description = video_info_dict['description']
media_url = video_info_dict['mediaUrl'] title = video_info_dict['title']
description = video_info_dict['description'] native_platform = video_info_dict['nativePlatform']
title = video_info_dict['title'] native_video_id = video_info_dict['nativeVideoId']
native_platform = video_info_dict['nativePlatform'] source_priority = video_info_dict['sourcePriority']
native_video_id = video_info_dict['nativeVideoId']
source_priority = video_info_dict['sourcePriority']
# Start video extraction
video_url = ''
# Start video extraction # If nativePlatform is None a fallback mechanism is used (i.e. youtube embed)
video_url = '' if native_platform == None:
# If nativePlatform is None a fallback mechanism is used (i.e. youtube embed) # Look for other video urls
if native_platform == None: video_url = self._html_search_regex(r'<iframe.* src="(.+?)".*', webpage, u'fallback Video URL')
# Look for other video urls if 'youtube' in video_url:
video_url = self._html_search_regex(r'<iframe.* src="(.+?)".*', webpage, u'fallback Video URL') self.to_screen(u'Youtube video detected:')
if 'youtube' in video_url: return self.url_result(video_url, ie='Youtube')
self.to_screen(u'Youtube video detected:')
print video_url # For debugging purposes
return self.url_result(video_url, ie='Youtube') #print video_info_dict
#print native_platform
# For debugging purposes #print native_video_id
#print video_info_dict #print source_priority
#print native_platform #print media_url
#print native_video_id
#print source_priority # Non Fallback: Decide to use native source (e.g. youtube or vimeo) or
#print media_url # the own CDN
if source_priority == 'native':
# Non Fallback: Decide to use native source (e.g. youtube or vimeo) or if native_platform == 'youtube':
# the own CDN
if source_priority == 'native':
if native_platform == 'youtube':
self.to_screen(u'Youtube video detected:') self.to_screen(u'Youtube video detected:')
video_url = 'https://www.youtube.com/watch?v=' + native_video_id video_url = 'https://www.youtube.com/watch?v=' + native_video_id
print video_url
return self.url_result(video_url, ie='Youtube') return self.url_result(video_url, ie='Youtube')
if native_platform == 'vimeo': if native_platform == 'vimeo':
self.to_screen(u'Vimeo video detected:') self.to_screen(u'Vimeo video detected:')
video_url = 'http://vimeo.com/' + native_video_id video_url = 'http://vimeo.com/' + native_video_id
print video_url
return self.url_result(video_url, ie='Vimeo') return self.url_result(video_url, ie='Vimeo')
# No redirect, use coz media url # No redirect, use coz media url
video_url = media_url video_url = media_url
if video_url.endswith('.mp4') == False: if video_url.endswith('.mp4') == False:
self.report_warning(u'Url does not contain a video container') self.report_warning(u'Url does not contain a video container')
return [] return []
return [{ return [{
'id': video_id, 'id': video_id,
'url': video_url, 'url': video_url,
'ext': 'mp4', 'ext': 'mp4',
'title': title, 'title': title,
'description': description 'description': description,
}] }]

Loading…
Cancel
Save