Merge branch 't2' into develop

This commit is contained in:
pl 2014-11-01 01:26:24 +08:00
commit e597f247e4
4 changed files with 45 additions and 17 deletions

View File

@ -994,4 +994,3 @@ def any_download_playlist(url, **kwargs):
def main():
script_main('you-get', any_download, any_download_playlist)

View File

@ -4,6 +4,7 @@ __all__ = ['acfun_download']
from ..common import *
from .letv import letvcloud_download_by_vu
from .qq import qq_download_by_id
from .sina import sina_download_by_vid
from .tudou import tudou_download_by_iid
@ -33,6 +34,8 @@ def acfun_download_by_vid(vid, title=None, output_dir='.', merge=True, info_only
tudou_download_by_iid(sourceId, title, output_dir=output_dir, merge=merge, info_only=info_only)
elif sourceType == 'qq':
qq_download_by_id(sourceId, title, output_dir=output_dir, merge=merge, info_only=info_only)
elif sourceType == 'letv':
letvcloud_download_by_vu(sourceId, title, output_dir=output_dir, merge=merge, info_only=info_only)
else:
raise NotImplementedError(sourceType)

View File

@ -1,10 +1,12 @@
#!/usr/bin/env python
__all__ = ['letv_download']
__all__ = ['letv_download', 'letvcloud_download', 'letvcloud_download_by_vu']
import json
import random
import xml.etree.ElementTree as ET
import base64, hashlib, urllib
from ..common import *
def get_timestamp():
@ -21,7 +23,6 @@ def get_key(t):
t += e
return t ^ 185025305
def video_info(vid):
tn = get_timestamp()
key = get_key(tn)
@ -40,7 +41,6 @@ def video_info(vid):
# url += '&termid=1&format=0&hwtype=un&ostype=Windows7&tag=letv&sign=letv&expect=1&pay=0&rateid={}'.format(k)
# return url, title
url="http://api.letv.com/mms/out/common/geturl?platid=3&splatid=301&playid=0&vtype=9,13,21,28&version=2.0&tss=no&vid={}&domain=www.letv.com&tkey={}".format(vid,key)
r = get_content(url, decoded=False)
info=json.loads(str(r,"utf-8"))
@ -56,8 +56,6 @@ def video_info(vid):
info2=json.loads(str(r2,"utf-8"))
return info2["location"]
# return url
def letv_download_by_vid(vid,title, output_dir='.', merge=True, info_only=False):
url= video_info(vid)
_, _, size = url_info(url)
@ -66,7 +64,36 @@ def letv_download_by_vid(vid,title, output_dir='.', merge=True, info_only=False)
if not info_only:
download_urls([url], title, ext, size, output_dir=output_dir, merge=merge)
def letvcloud_download_by_vu(vu, title=None, output_dir='.', merge=True, info_only=False):
str2Hash = 'cfflashformatjsonran0.7214574650861323uu2d8c027396ver2.1vu' + vu + 'bie^#@(%27eib58'
sign = hashlib.md5(str2Hash.encode('utf-8')).hexdigest()
request_info = urllib.request.Request('http://api.letvcloud.com/gpc.php?&sign='+sign+'&cf=flash&vu='+vu+'&ver=2.1&ran=0.7214574650861323&qr=2&format=json&uu=2d8c027396')
response = urllib.request.urlopen(request_info)
data = response.read()
info = json.loads(data.decode('utf-8'))
type_available = []
for i in info['data']['video_info']['media']:
type_available.append({'video_url': info['data']['video_info']['media'][i]['play_url']['main_url'], 'video_quality': int(info['data']['video_info']['media'][i]['play_url']['vtype'])})
urls = [base64.b64decode(sorted(type_available, key = lambda x:x['video_quality'])[-1]['video_url']).decode("utf-8")]
size = urls_size(urls)
ext = 'mp4'
print_info(site_info, title, ext, size)
if not info_only:
download_urls(urls, title, ext, size, output_dir=output_dir, merge=merge)
def letvcloud_download(url, output_dir='.', merge=True, info_only=False):
for i in url.split('&'):
if 'vu=' in i:
vu = i[3:]
if len(vu) == 0:
raise ValueError('Cannot get vu!')
title = "LETV-%s" % vu
letvcloud_download_by_vu(vu, title=title, output_dir=output_dir, merge=merge, info_only=info_only)
def letv_download(url, output_dir='.', merge=True, info_only=False):
if re.match(r'http://yuntv.letv.com/', url):
letvcloud_download(url, output_dir=output_dir, merge=merge, info_only=info_only)
else:
html = get_content(url)
#to get title
if re.match(r'http://www.letv.com/ptv/vplay/(\d+).html', url):
@ -74,9 +101,8 @@ def letv_download(url, output_dir='.', merge=True, info_only=False):
else:
vid = match1(html, r'vid="(\d+)"')
title = match1(html,r'name="irTitle" content="(.*?)"')
letv_download_by_vid(vid,title, output_dir=output_dir, merge=merge, info_only=info_only)
letv_download_by_vid(vid, title=title, output_dir=output_dir, merge=merge, info_only=info_only)
site_info = "letv.com"
site_info = "LeTV.com"
download = letv_download
download_playlist = playlist_not_supported('letv')

View File

@ -48,7 +48,7 @@ def netease_cloud_music_download(url, output_dir='.', merge=True, info_only=Fals
def netease_song_download(song, output_dir='.', info_only=False):
title = "%s. %s" % (song['position'], song['name'])
# url = song['mp3Url']
url_best = make_url(song['bMusic']['dfsId'])
url_best = make_url(song['hMusic']['dfsId'])
songtype, ext, size = url_info(url_best)
print_info(site_info, title, songtype, size)
if not info_only: