acupload:命令行Acfun直传上传工具

在dantmnf的激励下做了这个东西。
其实也算是向biliupload致敬了。
至少思路是一样的,虽然具体操作有所不同。
最终的检验我用的是API,不是简单的返回值。加上处理一些特殊情况,代码就长了一些。这不代表Python比ruby难看。。。
地址:
https://github.com/cnbeining/acupload
代码:
Continue reading

Biligrab 0.7:极黑的再来个黑科技:直接强制解析原始源

感谢@LYF的启发。
在Oversea这里再加一个选项:
0:最基本的原始解析,使用最基本的API。
1:使用CDN(加速源)的API。
*2:尝试解析原始地址,用Flvcd解析得出下载地址。如果没有,用备份方案。
(因为懒得再挨个写一遍解析)
还是那句话:你只能选择API,不能选择真正的源,这个不完全是你可以控制的。
 
老地方:https://gist.github.com/cnbeining/9605757
 

'''
Biligrab 0.7
Beining@ACICFG
cnbeining[at]gmail.com
http://www.cnbeining.com
MIT licence
'''
import sys
import os
from StringIO import StringIO
import gzip
import urllib2
import sys
import commands
from xml.dom.minidom import parse, parseString
import xml.dom.minidom
reload(sys)
sys.setdefaultencoding('utf-8')
global vid
global cid
global partname
global title
global videourl
global part_now
def list_del_repeat(list):
    """delete repeating items in a list, and keep the order.
    http://www.cnblogs.com/infim/archive/2011/03/10/1979615.html"""
    l2 = []
    [l2.append(i) for i in list if not i in l2]
    return(l2)
#----------------------------------------------------------------------
def find_cid_api(vid, p):
    """find cid and print video detail"""
    global cid
    global partname
    global title
    global videourl
    cid = 0
    title = ''
    partname = ''
    if str(p) is '0':
        biliurl = 'http://api.bilibili.tv/view?type=xml&appkey=876fe0ebd0e67a0f&id=' + str(vid)
    else:
        biliurl = 'http://api.bilibili.tv/view?type=xml&appkey=876fe0ebd0e67a0f&id=' + str(vid) + '&page=' + str(p)
    videourl = 'http://www.bilibili.tv/video/av'+ str(vid)+'/index_'+ str(p)+'.html'
    print('Fetching webpage...')
    try:
        request = urllib2.Request(biliurl, headers={ 'User-Agent' : 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36', 'Cache-Control': 'no-cache', 'Pragma': 'no-cache' })
        response = urllib2.urlopen(request)
        data = response.read()
        data_list = data.split('\n')
        for lines in data_list:
            if 'cid' in lines:
                cid = lines[7:-6]
                print('cid is ' + str(cid))
                break
        for lines in data_list:
            if 'partname' in lines:
                partname = lines[12:-11]
                print('partname is ' + str(partname))
                break
        if str(p) is not '0':
            for lines in data_list:
                if 'title' in lines:
                    title = lines[9:-8]
                    print('title is ' + str(title))
                    break
    except:  #If API failed
        print('ERROR: Cannot connect to API server!')
#----------------------------------------------------------------------
def find_cid_flvcd(videourl):
    """"""
    global vid
    global cid
    global partname
    global title
    print('Fetching webpage via Flvcd...')
    request = urllib2.Request(videourl, headers={ 'User-Agent' : 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36', 'Cache-Control': 'no-cache', 'Pragma': 'no-cache' })
    request.add_header('Accept-encoding', 'gzip')
    response = urllib2.urlopen(request)
    if response.info().get('Content-Encoding') == 'gzip':
        buf = StringIO( response.read())
        f = gzip.GzipFile(fileobj=buf)
        data = f.read()
    data_list = data.split('\n')
    #Todo: read title
    for lines in data_list:
        if 'cid=' in lines:
            cid = lines.split('&')
            cid = cid[0].split('=')
            cid = cid[-1]
            print('cid is ' + str(cid))
            break
#----------------------------------------------------------------------
def find_link_flvcd(videourl):
    """"""
    request = urllib2.Request('http://www.flvcd.com/parse.php?kw='+videourl, headers={ 'User-Agent' : 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36', 'Cache-Control': 'no-cache', 'Pragma': 'no-cache' })
    request.add_header('Accept-encoding', 'gzip')
    response = urllib2.urlopen(request)
    data = response.read()
    data_list = data.split('\n')
    for items in data_list:
        if 'name' in items and 'inf' in items and 'input' in items:
            c = items
            rawurlflvcd = c[39:-5]
            rawurlflvcd = rawurlflvcd.split('|')
            return rawurlflvcd
#----------------------------------------------------------------------
def main(vid, p, oversea):
    global cid
    global partname
    global title
    global videourl
    global is_first_run
    biliurl = 'http://api.bilibili.tv/view?type=xml&appkey=876fe0ebd0e67a0f&id=' + str(vid) + '&page=' + str(p)
    videourl = 'http://www.bilibili.tv/video/av'+ str(vid)+'/index_'+ str(p)+'.html'
    output = commands.getstatusoutput('ffmpeg --help')
    if str(output[0]) == '32512':
        print('FFmpeg does not exist! Trying to get you a binary, need root...')
        os.system('sudo curl -o /usr/bin/ffmpeg https://raw.githubusercontent.com/superwbd/ABPlayerHTML5-Py--nix/master/ffmpeg')
    output = commands.getstatusoutput('aria2c --help')
    if str(output[0]) == '32512':
        print('aria2c does not exist! Trying to get you a binary, need root... Thanks for @MartianZ \'s work.')
        os.system('sudo curl -o /usr/bin/aria2c https://raw.githubusercontent.com/MartianZ/fakeThunder/master/fakeThunder/aria2c')
    find_cid_api(vid, p)
    global cid
    if cid is 0:
        print('Cannot find cid, trying to do it brutely...')
        find_cid_flvcd(videourl)
    if cid is 0:
        is_black3 = str(raw_input('Strange, still cannot find cid... Type y for trying the unpredictable way, or input the cid by yourself, press ENTER to quit.'))
        if 'y' in str(is_black3):
            vid = vid - 1
            p = 1
            find_cid_api(vid-1, p)
            cid = cid + 1
        elif str(is_black3) is '':
            print('Cannot get cid anyway! Quit.')
            exit()
        else:
            cid = str(is_black3)
    #start to make folders...
    if title is not '':
        folder = title
    else:
        folder = cid
    if partname is not '':
        filename = partname
    elif title is not '':
        filename = title
    else:
        filename = cid
    # In case make too much folders
    folder_to_make = os.getcwd() + '/' + folder
    if is_first_run == 0:
        if not os.path.exists(folder_to_make):
            os.makedirs(folder_to_make)
        is_first_run = 1
        os.chdir(folder_to_make)
    print('Fetching XML...')
    os.system('curl -o "'+filename+'.xml" --compressed  http://comment.bilibili.cn/'+cid+'.xml')
    os.system('gzip -d '+cid+'.xml.gz')
    print('The XML file, ' + filename + '.xml should be ready...enjoy!')
    print('Finding video location...')
    #try api
    if oversea == '1':
        try:
            request = urllib2.Request('http://interface.bilibili.cn/v_cdn_play?cid='+cid, headers={ 'User-Agent' : 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36', 'Cache-Control': 'no-cache', 'Pragma': 'no-cache' })
        except:
            print('ERROR: Cannot connect to CDN API server!')
    elif oversea is '2':
        #Force get oriurl
        try:
            request = urllib2.Request('http://interface.bilibili.com/player?id=cid:'+cid, headers={ 'User-Agent' : 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36', 'Cache-Control': 'no-cache', 'Pragma': 'no-cache' })
        except:
            print('ERROR: Cannot connect to original source API server!')
    else:
        try:
            request = urllib2.Request('http://interface.bilibili.tv/playurl?cid='+cid, headers={ 'User-Agent' : 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36', 'Cache-Control': 'no-cache', 'Pragma': 'no-cache' })
        except:
            print('ERROR: Cannot connect to normal API server!')
    response = urllib2.urlopen(request)
    data = response.read()
    #print(data_list)
    rawurl = []
    originalurl = ''
    if oversea is '2':
        data = data.split('\n')
        for l in data:
            if 'oriurl' in l:
                originalurl = str(l[8:-9])
                print('Original URL is ' + originalurl)
                break
        if originalurl is not '':
            rawurl = find_link_flvcd(originalurl)
        else:
            print('Cannot get original URL! Using falloff plan...')
            pass
    else:
        dom = parseString(data)
        for node in dom.getElementsByTagName('url'):
            if node.parentNode.tagName == "durl":
                rawurl.append(node.toxml()[14:-9])
                #print(str(node.toxml()[14:-9]))
            pass
    if rawurl is []:  #hope this never happen
        rawurl = find_link_flvcd(videourl)
        #flvcd
    #print(rawurl)
    vid_num = len(rawurl)
    if vid_num is 0:
        print('Cannot get download URL!')
        exit()
    #print(rawurl)
    print(str(vid_num) + ' videos in part ' + str(part_now) + ' to download, fetch yourself a cup of coffee...')
    for i in range(vid_num):
        print('Downloading ' + str(i+1) + ' of ' + str(vid_num) + ' videos in part ' + str(part_now) + '...')
        #print('aria2c -llog.txt -c -s16 -x16 -k1M --out '+str(i)+'.flv "'+rawurl[i]+'"')
        os.system('aria2c -c -s16 -x16 -k1M --out '+str(i)+'.flv "'+rawurl[i]+'"')
        #os.system('aria2c -larialog.txt -c -s16 -x16 -k1M --out '+str(i)+'.flv "'+rawurl[i]+'"')
        #not debugging, not fun.
    f = open('ff.txt', 'w')
    ff = ''
    os.getcwd()
    for i in range(vid_num):
        ff = ff + 'file \'' + str(os.getcwd()) + '/'+ str(i) + '.flv\'\n'
    ff = ff.encode("utf8")
    f.write(ff)
    f.close()
    print('Concating videos...')
    os.system('ffmpeg -f concat -i ff.txt -c copy "'+filename+'".mp4')
    os.system('rm -r ff.txt')
    for i in range(vid_num):
        os.system('rm -r '+str(i)+'.flv')
    print('Done, enjoy yourself!')
    #
vid = str(raw_input('av'))
p_raw = str(raw_input('P'))
oversea = str(input('Source?'))
p_list = []
p_raw = p_raw.split(',')
for item in p_raw:
    if '~' in item:
        #print(item)
        lower = 0
        higher = 0
        item = item.split('~')
        try:
            lower = int(item[0])
        except:
            print('Cannot read lower!')
        try:
            higher = int(item[1])
        except:
            print('Cannot read higher!')
        if lower == 0 or higher == 0:
            if lower == 0 and higher != 0:
                lower = higher
            elif lower != 0 and higher == 0:
                higher = lower
            else:
                print('Cannot find any higher or lower, ignoring...')
                #break
        mid = 0
        if higher < lower:
            mid = higher
            higher = lower
            lower = mid
        p_list.append(lower)
        while lower < higher:
            lower = lower + 1
            p_list.append(lower)
        #break
    else:
        try:
            p_list.append(int(item))
        except:
            print('Cannot read "'+str(item)+'", abondon it.')
            #break
p_list = list_del_repeat(p_list)
global is_first_run
is_first_run = 0
part_now = '0'
print(p_list)
for p in p_list:
    reload(sys)
    sys.setdefaultencoding('utf-8')
    part_now = str(p)
    main(vid, p, oversea)
exit()
'''
        data_list = data.split('\r')
        for lines in data_list:
            lines = str(lines)
            if '<url>' in lines:
                if 'youku'  in lines:
                    url = lines[17:-9]
                elif 'sina' in lines:
                    url = lines[16:-9]
                elif 'qq.com' in lines:
                    url = lines[17:-9]
                elif 'letv.com' in lines:
                    url = lines[17:-9]
                    break
                elif 'acgvideo' in lines:
                    url = lines[17:-9]
                    is_local = 1
                rawurl.append(url)
            if 'backup_url' in lines and is_local is 1:
                break'''

 

个人项目:开始提供@lolicon.xyz 与@moeloli.xyz的邮箱

开始提供@lolicon.xyz 与@moeloli.xyz 的邮箱.
基于Yandex。
登陆:http://mail.lolicon.xyz
http://mail.moeloli.xyz
用户名+密码。会自动跳转到https。
登陆后,页面右下角可以调英文。
 
需要的。。。。恩可以邮件我 也可以直接留评论 在评论表格里面留自己邮箱(这样只有我能看见) 或者其他联系方式 注明自己喜欢的前缀(???????@lolicon.xyz/moeloli.xyz)。
 
起码能用1年。过后域名要钱了,有可能扔了自然死,如果大家乐意集资,10欧元1年。
 
以上。

继续毁灭世界:乐视的视频信息API逆向解析

http://api.letvcloud.com/gpc.php?&sign=abd0db0d9181e5e4b5d89e4c414c4988&ver=2.1&uu=2d8c027396&cf=flash&skinnable=0&vu=8cb47801f0&ran=0.7214574650861323&format=xml
 
以上参数不能再少了。
 
uu和vu参考之前的文章。
 
这API太缺德了,把上传者信息都公布了。唉。
 
至于sign生成办法,暂时不公开。想知道的人肯定知道我邮箱。。。。。
(对于不乐意公开留邮箱的,评论时留下邮箱,我就能在后台看见了哦。)

关于A,B站直传后的黑科技的一切,乐视的各种黑科技,外加修正(更新:乐视API整个让人拆了)

我还想这东西会不会让人灭了呢。想想算了。who gives a shit.
感谢萌神,没有他的帮助我不可能完成。
转载注明出处http://www.cnbeining.com/  ,谢谢。
 
是的,有时间,也看一下这个:http://www.cnbeining.com/2014/07/continue-to-destroy-the-world-tv-plus-video-api-reverse-resolution/
 
是的,我知道某些地方看完了肯定会全程高潮加漏尿,但是,我Blog的东西禁止转载到百度任何服务,包括但不限于贴吧、空间、知道、以及天杀的经验等。
 
从重磅开始爆料吧。
0.A站有直传了,也是乐视。
以免某些人还继续研究sina,特此通知。
Due to respect, 不放出黑科技进入方法,想要的私下找我,或者多打听打听。
 
1.A站和B站的直传代码可以通用。
下定义:
vu:乐视云视频的视频ID
uu:乐视云视频的客户ID
也就是,请自己读一遍坑爹API文档去。虽然这API文档语焉不详,但是毕竟不是啥文档都是Python的Documentation啊。
是个人都应该知道,B站的代码:[localup]f879855cda[/localup]。
这个代码就是我们要的vu。
在A站投稿,你也会看见乐视云。是的,也只需要vu而已。
可以这么理解:乐视的vu就相当于Sina的vid,Youku的ykid,Tencent的qid.
怎么投稿不用多说.
B->A:投稿完成,直接进入编辑,取vu,找乐视云投稿。
A->B:投稿完成,着急就直接编辑看,不着急就等私信通知转码完成,会给你vu。去B站代码投稿。
 
2.A站继续不改尿性。
是的,使用之前的某公开API可以查看任何投稿的信息,现在也能看vu。
有什么用大家心里明白。
 
2.5.B站也一个味。
用API也可以知道B站投稿的vu。
心拔凉拔凉的。
 
3.直接越过审核,单独把视频剥离出来。
当然可以,只要视频转码成功了。
是不是有种当年日穿Sina的雄风?
直接上Letv的播放器吧。
http://yuntv.letv.com/bcloud.swf?uu=leshishabi&vu=5409de04a2
发现了,呃?uu可以随便写哦。
你看,
http://yuntv.letv.com/bcloud.swf?uu=leshishisb&vu=5409de04a2
也可以正常用。
 
当然我觉得你们有可能认为太简陋了。没关系。

#网页版本
http://yuntv.letv.com/bcloud.html?uu=78e2e89114&vu=e1c6d52343&auto_play=1&gpcflag=1&width=640&height=360
#JS版本
<script type="text/javascript"> var letvcloud_player_conf =  {"uu":"78e2e89114","vu":"e1c6d52343","auto_play":1,"gpcflag":1,"width":640,"height":360};</script><script type="text/javascript" src="http://yuntv.letv.com/bcloud.js"></script>
#直接版本
http://yuntv.letv.com/bcloud.swf?uu=78e2e89114&vu=e1c6d52343&auto_play=1&gpcflag=1
#HTML
<embed src="http://yuntv.letv.com/bcloud.swf" allowFullScreen="true" quality="high"  width="640" height="360" align="middle" allowScriptAccess="always" flashvars="uu=78e2e89114&vu=e1c6d52343&auto_play=1&gpcflag=1&width=640&height=360" type="application/x-shockwave-flash"></embed>
#JS自适应
<script id="autoJse1c6d52343" type="text/javascript">var pNode=document.getElementById("autoJse1c6d52343").parentNode,pnd=pNode.style,dWidth=pnd.width,pHeight=pnd.height,dHeight=ReCallHeight(pHeight,pNode);function ReCallHeight(e,t){if(e==""||e=="100%"){var n=t.parentNode,r=t.parentNode.style.height;if(r)return r;var i=ReCallHeight(r,n);return i}return e} var letvcloud_player_conf =  {"uu":"78e2e89114","vu":"e1c6d52343","auto_play":1,"gpcflag":1,"width": dWidth,"height": dHeight};</script><script type="text/javascript" src="http://yuntv.letv.com/bcloud.js"></script>

自己换uu和vu。
 
4.乐视到底可以传多High的视频?
恩。。。。1080P。码率最高可达6M多。
 
5.乐视到底有啥黑科技?
是的,我不地道了。
看代码:

               "FLV_350":1,
               "3GP_320X240":2,
               "FLV_ENP":3,
               "CHINAFILM_350":4,
               "FLV_VIP":8,
               "MP4":9,
               "FLV_LIVE":10,
               "UNION_LOW":11,
               "UNION_HIGH":12,
               "MP4_800":13,
               "FLV_1000":16,
               "FLV_1300":17,
               "FLV_720P":18,
               "MP4_1080P":19,
               "FLV_1080P6M":20,
               "MP4_350":21,
               "MP4_1300":22,
               "MP4_800_DB":23,
               "MP4_1300_DB":24,
               "MP4_720P_DB":25,
               "MP4_1080P6M_DB":26,
               "FLV_YUANHUA":27,
               "MP4_YUANHUA":28,
               "FLV_720P_3D":29,
               "MP4_720P_3D":30,
               "FLV_1080P6M_3D":31,
               "MP4_1080P6M_3D":32,
               "FLV_1080P_3D":33,
               "MP4_1080P_3D":34,
               "FLV_1080P3M":35,
               "FLV_4K":44,
               "H265_800":45,
               "H265_1300":46,
               "H265_720P":47,
               "H265_1080P”:48

不言而喻了吧。
 
6.尼玛死,如果我用黑科技,我岂不是不知道有多少人看我视频了么?
确定:不会的。
请自己去乐视云注册会员,自己建播放器。OK,你自己的统计代码。用自己的uu和pu。
或者用GA,短链接,随便你。
 
转载注明出处http://www.cnbeining.com/  ,谢谢。