mirror of
https://github.com/blackjack4494/yt-dlc.git
synced 2024-12-23 00:07:49 +00:00
[chilloutzone] Simplify (#2338)
This commit is contained in:
parent
9f31be7000
commit
4a9540b6d2
1 changed files with 28 additions and 52 deletions
|
@ -1,14 +1,15 @@
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import re
|
import re
|
||||||
import base64
|
import base64
|
||||||
import urllib
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
|
from ..utils import clean_html
|
||||||
|
|
||||||
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 = {
|
||||||
'url': 'http://www.chilloutzone.net/video/enemene-meck-alle-katzen-weg.html',
|
'url': 'http://www.chilloutzone.net/video/enemene-meck-alle-katzen-weg.html',
|
||||||
'md5': 'a76f3457e813ea0037e5244f509e66d1',
|
'md5': 'a76f3457e813ea0037e5244f509e66d1',
|
||||||
|
@ -16,6 +17,7 @@ class ChilloutzoneIE(InfoExtractor):
|
||||||
'id': 'enemene-meck-alle-katzen-weg',
|
'id': 'enemene-meck-alle-katzen-weg',
|
||||||
'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
'title': 'Enemene Meck - Alle Katzen weg',
|
'title': 'Enemene Meck - Alle Katzen weg',
|
||||||
|
'description': 'Ist das der Umkehrschluss des Niesenden Panda-Babys?',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,71 +25,45 @@ class ChilloutzoneIE(InfoExtractor):
|
||||||
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 = self._download_webpage(url, video_id)
|
||||||
|
|
||||||
# Log that we are starting to download the page
|
base64_video_info = self._html_search_regex(
|
||||||
self.report_download_webpage(webpage_url)
|
r'var cozVidData = "(.+?)";', webpage, 'video data')
|
||||||
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")
|
decoded_video_info = base64.b64decode(base64_video_info).decode("utf-8")
|
||||||
video_info_dict = json.loads(decoded_video_info)
|
video_info_dict = json.loads(decoded_video_info)
|
||||||
|
|
||||||
# get video information from dict
|
# get video information from dict
|
||||||
media_url = video_info_dict['mediaUrl']
|
video_url = video_info_dict['mediaUrl']
|
||||||
description = video_info_dict['description']
|
description = clean_html(video_info_dict.get('description'))
|
||||||
title = video_info_dict['title']
|
title = video_info_dict['title']
|
||||||
native_platform = video_info_dict['nativePlatform']
|
native_platform = video_info_dict['nativePlatform']
|
||||||
native_video_id = video_info_dict['nativeVideoId']
|
native_video_id = video_info_dict['nativeVideoId']
|
||||||
source_priority = video_info_dict['sourcePriority']
|
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 nativePlatform is None a fallback mechanism is used (i.e. youtube embed)
|
||||||
if native_platform == None:
|
if native_platform is None:
|
||||||
# Look for other video urls
|
youtube_url = self._html_search_regex(
|
||||||
video_url = self._html_search_regex(r'<iframe.* src="(.+?)".*', webpage, u'fallback Video URL')
|
r'<iframe.* src="((?:https?:)?//(?:[^.]+\.)?youtube\.com/.+?)"',
|
||||||
if 'youtube' in video_url:
|
webpage, 'fallback video URL', default=None)
|
||||||
self.to_screen(u'Youtube video detected:')
|
if youtube_url is not None:
|
||||||
return self.url_result(video_url, ie='Youtube')
|
return self.url_result(youtube_url, ie='Youtube')
|
||||||
|
|
||||||
# For debugging purposes
|
|
||||||
#print video_info_dict
|
|
||||||
#print native_platform
|
|
||||||
#print native_video_id
|
|
||||||
#print source_priority
|
|
||||||
#print media_url
|
|
||||||
|
|
||||||
# Non Fallback: Decide to use native source (e.g. youtube or vimeo) or
|
# Non Fallback: Decide to use native source (e.g. youtube or vimeo) or
|
||||||
# the own CDN
|
# the own CDN
|
||||||
if source_priority == 'native':
|
if source_priority == 'native':
|
||||||
if native_platform == 'youtube':
|
if native_platform == 'youtube':
|
||||||
self.to_screen(u'Youtube video detected:')
|
return self.url_result(video_id, ie='Youtube')
|
||||||
video_url = 'https://www.youtube.com/watch?v=' + native_video_id
|
|
||||||
return self.url_result(video_url, ie='Youtube')
|
|
||||||
if native_platform == 'vimeo':
|
if native_platform == 'vimeo':
|
||||||
self.to_screen(u'Vimeo video detected:')
|
return self.url_result(
|
||||||
video_url = 'http://vimeo.com/' + native_video_id
|
'http://vimeo.com/' + native_video_id, ie='Vimeo')
|
||||||
return self.url_result(video_url, ie='Vimeo')
|
|
||||||
|
|
||||||
# No redirect, use coz media url
|
if not video_url:
|
||||||
video_url = media_url
|
raise ExtractorError('No video found')
|
||||||
if video_url.endswith('.mp4') == False:
|
|
||||||
self.report_warning(u'Url does not contain a video container')
|
|
||||||
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…
Reference in a new issue