From 46a073bfac5ff2eb9b31d2b27b64d6fb6895566c Mon Sep 17 00:00:00 2001 From: Andreas Schmitz Date: Thu, 6 Feb 2014 11:44:44 +0100 Subject: [PATCH 1/2] [chilloutzone] Added support for chilloutzone.net Added support for chilloutzone.net videos including embedded youtube and vimeo movies. In case you find a not working movie, drop me an email. --- youtube_dl/extractor/__init__.py | 1 + youtube_dl/extractor/chilloutzone.py | 100 +++++++++++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 youtube_dl/extractor/chilloutzone.py diff --git a/youtube_dl/extractor/__init__.py b/youtube_dl/extractor/__init__.py index 4e0501ec3..02a422fe6 100644 --- a/youtube_dl/extractor/__init__.py +++ b/youtube_dl/extractor/__init__.py @@ -25,6 +25,7 @@ from .canalplus import CanalplusIE from .canalc2 import Canalc2IE from .cbs import CBSIE from .channel9 import Channel9IE +from .chilloutzone import ChilloutzoneIE from .cinemassacre import CinemassacreIE from .clipfish import ClipfishIE from .cliphunter import CliphunterIE diff --git a/youtube_dl/extractor/chilloutzone.py b/youtube_dl/extractor/chilloutzone.py new file mode 100644 index 000000000..31618e4c9 --- /dev/null +++ b/youtube_dl/extractor/chilloutzone.py @@ -0,0 +1,100 @@ +import re +import base64 +import urllib +import json + +from .common import InfoExtractor + +video_container = ('.mp4', '.mkv', '.flv') + +class ChilloutzoneIE(InfoExtractor): + _VALID_URL = r'(?:https?://)?(?:www\.)?chilloutzone\.net/video/(?P[\w|-]+).html' + + _TEST = { + u'url': u'http://www.chilloutzone.net/video/enemene-meck-alle-katzen-weg.html', + u'file': u'18088-enemene-meck-alle-katzen-weg.mp4', + u'md5': u'a76f3457e813ea0037e5244f509e66d1', + u'info_dict': { + u"id": u"18088", + u"ext": u"mp4", + u"title": u"Enemene Meck - Alle Katzen weg" + } + } + + def _real_extract(self, url): + mobj = re.match(self._VALID_URL, url) + video_id = mobj.group('id') + + webpage_url = 'http://www.chilloutzone.net/video/' + video_id + '.html' + + # Log that we are starting to download the page + self.report_download_webpage(webpage_url) + webpage = self._download_webpage(webpage_url, video_id) + + + + # Log that we are starting to parse the page + self.report_extraction(video_id) + # Find base64 decoded file info + base64_video_info = self._html_search_regex(r'var cozVidData = "(.+?)";', webpage, u'video Data') + # decode string and find video file + decoded_video_info = base64.b64decode(base64_video_info) + video_info_dict = json.loads(decoded_video_info) + # get video information from dict + media_url = video_info_dict['mediaUrl'] + description = video_info_dict['description'] + title = video_info_dict['title'] + native_platform = video_info_dict['nativePlatform'] + native_video_id = video_info_dict['nativeVideoId'] + source_priority = video_info_dict['sourcePriority'] + + + # Start video extraction + video_url = '' + # If nativePlatform is None a fallback mechanism is used (i.e. youtube embed) + if native_platform == None: + # Look for other video urls + video_url = self._html_search_regex(r' Date: Thu, 6 Feb 2014 21:31:04 +0100 Subject: [PATCH 2/2] [chilloutzone] Bug fix, runs against tests Fixes a bug with python3.3 and made the extractor run successfully against tox --- youtube_dl/extractor/chilloutzone.py | 119 +++++++++++++-------------- 1 file changed, 56 insertions(+), 63 deletions(-) diff --git a/youtube_dl/extractor/chilloutzone.py b/youtube_dl/extractor/chilloutzone.py index 31618e4c9..59a188746 100644 --- a/youtube_dl/extractor/chilloutzone.py +++ b/youtube_dl/extractor/chilloutzone.py @@ -9,92 +9,85 @@ video_container = ('.mp4', '.mkv', '.flv') class ChilloutzoneIE(InfoExtractor): _VALID_URL = r'(?:https?://)?(?:www\.)?chilloutzone\.net/video/(?P[\w|-]+).html' - _TEST = { - u'url': u'http://www.chilloutzone.net/video/enemene-meck-alle-katzen-weg.html', - u'file': u'18088-enemene-meck-alle-katzen-weg.mp4', - u'md5': u'a76f3457e813ea0037e5244f509e66d1', - u'info_dict': { - u"id": u"18088", - u"ext": u"mp4", - u"title": u"Enemene Meck - Alle Katzen weg" - } - } + 'url': 'http://www.chilloutzone.net/video/enemene-meck-alle-katzen-weg.html', + 'md5': 'a76f3457e813ea0037e5244f509e66d1', + 'info_dict': { + 'id': 'enemene-meck-alle-katzen-weg', + 'ext': 'mp4', + 'title': 'Enemene Meck - Alle Katzen weg', + }, + } def _real_extract(self, 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 - self.report_download_webpage(webpage_url) - webpage = self._download_webpage(webpage_url, video_id) - + # Log that we are starting to download the page + self.report_download_webpage(webpage_url) + webpage = self._download_webpage(webpage_url, video_id) + + # Log that we are starting to parse the page + self.report_extraction(video_id) + # Find base64 decoded file info + base64_video_info = self._html_search_regex(r'var cozVidData = "(.+?)";', webpage, u'video Data') + # decode string and find video file + decoded_video_info = base64.b64decode(base64_video_info).decode("utf-8") + video_info_dict = json.loads(decoded_video_info) + # get video information from dict + media_url = video_info_dict['mediaUrl'] + description = video_info_dict['description'] + title = video_info_dict['title'] + native_platform = video_info_dict['nativePlatform'] + native_video_id = video_info_dict['nativeVideoId'] + source_priority = video_info_dict['sourcePriority'] - # Log that we are starting to parse the page - self.report_extraction(video_id) - # Find base64 decoded file info - base64_video_info = self._html_search_regex(r'var cozVidData = "(.+?)";', webpage, u'video Data') - # decode string and find video file - decoded_video_info = base64.b64decode(base64_video_info) - video_info_dict = json.loads(decoded_video_info) - # get video information from dict - media_url = video_info_dict['mediaUrl'] - description = video_info_dict['description'] - title = video_info_dict['title'] - native_platform = video_info_dict['nativePlatform'] - native_video_id = video_info_dict['nativeVideoId'] - source_priority = video_info_dict['sourcePriority'] + # Start video extraction + video_url = '' + # If nativePlatform is None a fallback mechanism is used (i.e. youtube embed) + if native_platform == None: + # Look for other video urls + video_url = self._html_search_regex(r'