add support: CBS & thePlatform

This commit is contained in:
Mort Yao 2014-04-26 15:18:28 +02:00
parent b3d10e32a9
commit 4ba7ce686c
4 changed files with 51 additions and 0 deletions

View File

@ -5,6 +5,7 @@ from .alive import *
from .baidu import * from .baidu import *
from .bilibili import * from .bilibili import *
from .blip import * from .blip import *
from .cbs import *
from .cntv import * from .cntv import *
from .coursera import * from .coursera import *
from .dailymotion import * from .dailymotion import *
@ -32,6 +33,7 @@ from .sina import *
from .sohu import * from .sohu import *
from .songtaste import * from .songtaste import *
from .soundcloud import * from .soundcloud import *
from .theplatform import *
from .tudou import * from .tudou import *
from .tumblr import * from .tumblr import *
from .vid48 import * from .vid48 import *

View File

@ -24,6 +24,7 @@ def url_to_module(url):
'bilibili': bilibili, 'bilibili': bilibili,
'blip': blip, 'blip': blip,
'cntv': cntv, 'cntv': cntv,
'cbs': cbs,
'coursera': coursera, 'coursera': coursera,
'dailymotion': dailymotion, 'dailymotion': dailymotion,
'douban': douban, 'douban': douban,
@ -53,6 +54,7 @@ def url_to_module(url):
'songtaste':songtaste, 'songtaste':songtaste,
'soundcloud': soundcloud, 'soundcloud': soundcloud,
'ted': ted, 'ted': ted,
'theplatform': theplatform,
'tudou': tudou, 'tudou': tudou,
'tumblr': tumblr, 'tumblr': tumblr,
'vid48': vid48, 'vid48': vid48,

View File

@ -0,0 +1,21 @@
#!/usr/bin/env python
__all__ = ['cbs_download']
from ..common import *
from .theplatform import theplatform_download_by_pid
def cbs_download(url, output_dir='.', merge=True, info_only=False):
"""Downloads CBS videos by URL.
"""
html = get_content(url)
pid = match1(html, r'video\.settings\.pid\s*=\s*\'([^\']+)\'')
title = match1(html, r'video\.settings\.title\s*=\s*\"([^\"]+)\"')
theplatform_download_by_pid(pid, title, output_dir=output_dir, merge=merge, info_only=info_only)
site_info = "CBS.com"
download = cbs_download
download_playlist = playlist_not_supported('cbs')

View File

@ -0,0 +1,26 @@
#!/usr/bin/env python
from ..common import *
def theplatform_download_by_pid(pid, title, output_dir='.', merge=True, info_only=False):
smil_url = "http://link.theplatform.com/s/dJ5BDC/%s/meta.smil?format=smil&mbr=true" % pid
smil = get_content(smil_url)
smil_base = unescape_html(match1(smil, r'<meta base="([^"]+)"'))
smil_videos = {y:x for x,y in dict(re.findall(r'<video src="([^"]+)".+height="([^"]+)"', smil)).items()}
for height in ['1080', '720', '480', '360', '240', '216']:
if height in smil_videos:
smil_video = smil_videos[height]
break
assert smil_video
type, ext, size = 'mp4', 'mp4', 0
print_info(site_info, title, type, size)
if not info_only:
from ..processor.rtmpdump import has_rtmpdump_installed, download_rtmpdump_stream
assert has_rtmpdump_installed(), "RTMPDump not installed."
download_rtmpdump_stream(url=smil_base, playpath=ext+':'+smil_video, title=title, ext=ext, output_dir=output_dir)
site_info = "thePlatform.com"
download = theplatform_download_by_pid
download_playlist = playlist_not_supported('theplatform')