重新封装一下Bilibili弹幕组件的API

      2 Comments on 重新封装一下Bilibili弹幕组件的API

主要为了算PMF。
不授权任何转载。

import xml.etree.ElementTree as ET
import requests
########################################################################
class BilibiliDanmaku:
    """"""
    cid = 0
    danmaku_list = []
    danmaku_url = 'http://comment.bilibili.com/{cid}.xml'
    danmaku_xml = ''
    danmaku_xml_tree = {}
    danmaku_pmf_data = {}
    headers = {
        'accept-encoding': 'gzip, deflate, sdch',
        'accept-language': 'en-CA,en;q=0.8,en-US;q=0.6,zh-CN;q=0.4,zh;q=0.2',
        'user-agent': '(Python-urllib/2.7, like libcurl/1.0 NSS-Mozilla/2.0)',
        'accept': '*/*',}
    chatserver = ''
    #self.chatid = 0
    mission = 0
    maxlimit = 0
    source = ''
    #----------------------------------------------------------------------
    def __init__(self):
        """Constructor"""
        pass
    #----------------------------------------------------------------------
    def init(self):
        """great init"""
        if  self.cid <= 0:
            raise ValueError('invalid cid')
        self.get()
        self.parse()
        pass
    @classmethod
    #----------------------------------------------------------------------
    def setcid(self, cid):
        """"""
        self.cid = cid
        self.danmaku_url = self.danmaku_url.format(cid = cid)
    #----------------------------------------------------------------------
    def get(self):
        """"""
        if not self.cid:
            raise ValueError('Cid not set')
        responce = requests.get(self.danmaku_url, headers= self.headers)
        self.danmaku_xml = responce.content
    @classmethod
    #----------------------------------------------------------------------
    def load(self, file_this):
        """"""
        if type(file_this) == str:
            self.danmaku_xml = file_this
        elif type(file_this) == file:
            f = open(file_this, 'r')
            self.danmaku_xml = f.read()
            f.close()
    #----------------------------------------------------------------------
    def parse(self):
        """"""
        if not self.danmaku_xml:
            raise ValueError('No Danmaku Data')
        tree = ET.ElementTree(ET.fromstring(self.danmaku_xml))
        root = tree.getroot()
        for child_of_root in root:
            if child_of_root.tag == 'chatserver':
                self.chatserver = child_of_root.text
            if child_of_root.tag == 'chatid':
                self.cid = int(child_of_root.text)
            if child_of_root.tag == 'mission':
                self.mission = child_of_root.text
            if child_of_root.tag == 'maxlimit':
                self.maxlimit = int(child_of_root.text)
            if child_of_root.tag == 'source':
                self.source = child_of_root.text
            if child_of_root.tag == 'd':
                info = str(child_of_root.attrib.get('p')).split(',')
                self.danmaku_xml_tree[info[7]] = {'stime': info[0],
                                                  'mode': info[1],
                                                  'size': info[2],
                                                  'color': info[3],
                                                  'timestamp': info[4],
                                                  'pool': info[5],
                                                  'sender': info[6],
                                                  'msg': child_of_root.text
                                                  }
    @classmethod
    #----------------------------------------------------------------------
    def get_pmf(self, period):
        """"""
        timelist = [(k, v['stime']) for k, v in self.danmaku_xml_tree.iteritems()]
        timelist.sort(key = lambda tup:tup[1])
        if period == 0:
            return timelist
        start = 0
        #not 0
        self.danmaku_pmf_data = {0: [], }
        for i in timelist:
            if i[1] <= int(start + period):
                self.danmaku_pmf_data[start].append(i[0])
            elif i[1] > int(start + period):
                start += period
                self.danmaku_pmf_data[start] = []
                self.danmaku_pmf_data[start].append(i[0])

 

关于与所谓Fuckbilibili项目关系的声明

      3 Comments on 关于与所谓Fuckbilibili项目关系的声明

我未专为Fuckbilibili项目开发过任何部分,亦不为其可能造成的任何不良后果负责。
截止声明时,Fuckbilibili网站所援引的的大量源码违反了GPL协议,所谓自行开发的源码违反了MIT协议。
请自行斟酌使用该项目中的任何部分。部分可能的后果会造成直接的人身、财产和/或名誉伤害。
Beining

Acfun黑科技:强制使用乐视源!垃圾画质吃屎去吧!

又及:
关于直接上传到乐视云:
参见

acupload 0.04:巨大更新


 
更新:我写插件了:
https://github.com/cnbeining/acfun-api-replace-server/tree/master/chrome
Acfun fix chrome 插件。
 
Chrome有很多插件,可以直接重定向请求。
我喜欢Switcheroo Redirector 。
加规则:

http://cdn.aixifan.com/player/sslhomura/AcNewPlayer151029.swf
重定向到
https://acfun-api.cnbeining.com/static/AcNewPlayer151029.swf

http://www.acfun.tv/video/getVideo.aspx?

https://acfun-api.cnbeining.com/getVideo?

服务端在Openshift,前面挂了CF。
懒得配置环境,人多了我也不知道怎样,随便吧。
服务端:https://github.com/cnbeining/acfun-api-replace-server
欢迎反馈。
 

不就是免费Comodo SSL么?simple(就是淘宝上1块钱的SSL)

EDIT:
偶尔其他渠道收不到确认邮件。
等2分钟,直接去取证书就是。
 
手残?回复,我帮你签。
 
两种方法,先说一个:
1. 把玉米解析到IP段:
83.170.64.0 - 83.170.127.255
109.123.64.0 - 109.123.127.255
77.92.64.0 - 77.92.95.255
要是不行换个
2. 要么关WHOIS隐私 要么保证admin@ webmaster@ 这种常见邮箱可以收信
3. 生成CSR等
4. https://ssl.uk2.net/cgi-bin/certificate-apply.pl 申请
记住订单号!!!!!
5. WHOIS邮箱收信,去链接确认
6. https://ssl.uk2.net/cgi-bin/retrieve-certificate.pl 取证书
反正Letsencrypt要来了,这东西很快就烂了。无伤大雅。

换用Cloudflare当DNS

      No Comments on 换用Cloudflare当DNS

DNSPod感觉不靠谱。
CloudXNS。。。国内无爱。
Route53要钱。
Linode的大陆封。
所以老老实实,Cloudflare。
好处是没什么限制,TTL2分钟也够良心。
当然了,缺点是看不见记录:没办法了。