Biligrab 0.95:集成danmaku2ass以直接导出ass文件,修正axel的bug

然后就是加了100行的代码。
很简陋,主要是版本不同的问题。我个人是没办法解决了。
老地方,https://github.com/cnbeining/Biligrab
代码下面。
danmaku2ass的代码这里不附带了,本项目中有,或者去上游找:https://github.com/m13253/danmaku2ass Continue reading

小脚本:迅速AES加密文件/目录

      2 Comments on 小脚本:迅速AES加密文件/目录

需要srm:
./bash/profile:

function enc() {
  tar zcvf - $1 | openssl aes-256-cbc -salt -out $1.aes && srm -mfzr $1
}
function dec() {
  openssl aes-256-cbc -d -in $1.aes | tar zxvf - && rm -f $1.aes
}

参考:
https://github.com/JElchison/encrypt-tool/blob/master/encrypt-tool.sh
http://blog.extracheese.org/2010/05/the-tar-pipe.html
https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/srm.1.html
http://netsecurity.51cto.com/art/201301/378513.htm
http://www.361way.com/openssl-encrypt-file/2692.html
 

笔记:在LNMP下部署HHVM

      4 Comments on 笔记:在LNMP下部署HHVM

LNMP,http://lnmp.org/  ,是我目前看见的最方便的一键部署脚本。什么都不用担心,全傻瓜(bi)化操作。
但是,由于他几乎更换了所有的默认目录,HHVM会认不出这货。
网上所有的教程都是从0开始安装Nginx。这多不爽。
这里记录一下具体操作。
环境: Ubuntu 12.04 x64(<----重要!x86不能安装,在这里浪费了两个小时)
1.准备环境,安装HHVM:
Ubuntu有deb包,不必自己编译了。
具体列表看这里:https://github.com/facebook/hhvm/wiki/Prebuilt%20Packages%20for%20HHVM

#安装依赖
sudo add-apt-repository ppa:mapnik/boost
sudo apt-get update
sudo apt-get install libboost1.49-dev libboost-regex1.49-dev \
  libboost-system1.49-dev libboost-program-options1.49-dev \
  libboost-filesystem1.49-dev libboost-thread1.49-dev
#安装HHVM
# If this command is not found then do this: sudo apt-get install python-software-properties
sudo add-apt-repository ppa:mapnik/boost
wget -O - http://dl.hhvm.com/conf/hhvm.gpg.key | sudo apt-key add -
echo deb http://dl.hhvm.com/ubuntu precise main | sudo tee /etc/apt/sources.list.d/hhvm.list
sudo apt-get update
sudo apt-get install hhvm

最后你会看见:

********************************************************************
* HHVM is installed.
*
* Running PHP web scripts with HHVM is done by having your webserver talk to HHVM
* over FastCGI. Install nginx or Apache, and then:
* $ sudo /usr/share/hhvm/install_fastcgi.sh
* $ sudo /etc/init.d/hhvm restart
* (if using nginx)  $ sudo /etc/init.d/nginx restart
* (if using apache) $ sudo /etc/init.d/apache restart
*
* Detailed FastCGI directions are online at:
* https://github.com/facebook/hhvm/wiki/FastCGI
*
* If you're using HHVM to run web scripts, you probably want it to start at boot:
* $ sudo update-rc.d hhvm defaults
*
* Running command-line scripts with HHVM requires no special setup:
* $ hhvm whatever.php
*
* You can use HHVM for /usr/bin/php even if you have php-cli installed:
* $ sudo /usr/bin/update-alternatives --install /usr/bin/php php /usr/bin/hhvm 60
********************************************************************

2. 修改/usr/share/hhvm/install_fastcgi.sh
替换L187~220:

nginx_check_installed() {
	echo "Checking if Nginx is installed"
	if [ -d "/usr/local/nginx/conf/" ]
	then
		echo "Detected Nginx installation"
		return 0
	fi
	echo "Nginx not found"
	return 1
}
nginx_check_custom() {
	echo "Checking for custom Nginx configuration"
	if [ ! \( -z "$(grep -E "^[^#]*(fastcgi|hhvm.conf)" "/usr/local/nginx/conf/nginx.conf")" \) \
	  -o ! \( -z "$(grep -ER "^[^#]*(fastcgi|hhvm.conf)" "/usr/local/nginx/conf/")" \) \
          -o ! \( -z "$(grep -ER "^[^#]*(fastcgi|hhvm.conf)" "/usr/local/nginx/conf/vhost/")" \) ]
	then
		echo "WARNING: Detected clashing configuration. Look at /etc/nginx/hhvm.conf for information how to connect to the hhvm fastcgi instance."
		return 0
	fi
	return 1
}
nginx_enable_module() {
	echo "Enabling hhvm Nginx module"
	insert_line "/usr/local/nginx/conf/nginx.conf" 'server_name.*$' 'include hhvm.conf;'
	echo "Finished enabling module"
}
nginx_disable_module() {
	echo "Disabling hhvm Nginx module"
	remove_line "/usr/local/nginx/conf/nginx.conf" "hhvm.conf"
	echo "Finished disabling module"
}

执行。
3.修改相关文件:
1)
/usr/local/nginx/conf
将所有的vhosts都改成

include hhvm.conf;

2)修改~/vhosts.sh:
同样修改。
4.删除启动项:
停止php-fpm服务,删除/etc/init.d/ 里面的php-fpm,这样这东西就不自动启动了。
5.添加监视脚本:
HHVM有可能会直接就死了。需要个脚本盯着。
脚本:

#! /bin/bash
PID="`cat /var/run/hhvm/pid`"
if [ "$PID" == "" ]; then
        /etc/init.d/hhvm start
        if [ "`ps ax -o pid | grep $PID`" == "" ]; then
                /etc/init.d/hhvm stop
                /etc/init.d/hhvm start
        fi
fi

保存为/root/check_hhvm.sh,加入执行权限,添加进cron:
crontab -e

* * * * * root /root/check_hhvm.sh

好了,LNMP已经成功供PHP-FPM换成HHVM了。
从探针可以看见。
http://www.bilicloud.com/
正运行在HHVM上。
Reference:
 
http://hjc.im/auto-check-hhvm-status/
http://www.freehao123.com/hhvm-wordpress/
https://github.com/facebook/hhvm
https://github.com/facebook/hhvm/wiki/Prebuilt-Packages-on-Ubuntu-12.04
https://github.com/facebook/hhvm/wiki/Building-and-installing-HHVM-on-Ubuntu-12.04#installing-boost-149
https://www.digitalocean.com/community/tutorials/how-to-configure-the-nginx-web-server-on-a-virtual-private-server
http://lnmp.org/faq/lnmp-software-list.html
http://blog.csdn.net/xiyuan1999/article/details/8160998
http://man.ddvip.com/soft/vieditor/vi.html
http://hjc.im/ubuntufu-wu-qi-shang-de-zui-you-wordpressfang-an/

Biligrab 0.91:多个下载/合并软件支持

      No Comments on Biligrab 0.91:多个下载/合并软件支持

为了一个issue,重写了下载和合并模块,结果这个issue的问题还没解决。。。。。
 
但是倒是支持更多下载器了:aria2c,wget,axel,curl 。
合并模块请大家赐教。
论怎么把代码从34行代码 变成31行 变成17行 变成12行:

'''
        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'''
'''
output = commands.getstatusoutput('ffmpeg --help')
if str(output[0]) != '32512':
    is_ffmpeg = 1
output = commands.getstatusoutput('avconv --help')
if str(output[0]) != '32512':
    is_avconv = 1
output = commands.getstatusoutput('aria2c --help')
if str(output[0]) != '32512':
    is_aria2c = 1
output = commands.getstatusoutput('aria2c --help')
if str(output[0]) != '32512':
    is_aria2c = 1
output = commands.getstatusoutput('wget --help')
if str(output[0]) != '32512':
    is_wget = 1
output = commands.getstatusoutput('curl --help')
if str(output[0]) == '32512':
    is_curl = 1
if is_ffmpeg == 1:
    concat_software = 'ffmpeg'
elif is_avconv == 1:
    concat_software = 'avconv'
else:
    print('ERROR: Cannot find any concating software!\nPlease get a ffmpeg or avconv!')
    exit()
if is_aria2c == 1:
    download_software = 'aria2c'
elif is_wget == 1:
    is_aria2c = 'wget'
elif is_curl == 1:
    is_aria2c = 'curl'
else:
    print('ERROR: Cannot find any downloading software!\nPlease get a aria2c, wget or, at very least, curl!')
    exit()
    '''
'''
concat_software = ''
download_software = ''
output = commands.getstatusoutput('ffmpeg --help')
if str(output[0]) == '32512':
    output = commands.getstatusoutput('avconv --help')
    if str(output[0]) == '32512':
        print('ERROR: Cannot find any concating software!\nPlease get a ffmpeg or avconv!')
        exit()
    else:
        concat_software = 'avconv'
else:
    concat_software = 'ffmpeg'
output = commands.getstatusoutput('aria2c --help')
if str(output[0]) == '32512':
    output = commands.getstatusoutput('axel --help')
    if str(output[0]) == '32512':
        output = commands.getstatusoutput('wget --help')
        if str(output[0]) == '32512':
            output = commands.getstatusoutput('curl --help')
            if str(output[0]) == '32512':
                print('ERROR: Cannot find any downloading software!\nPlease get a aria2c, wget or, at very least, curl!')
                exit()
            else:
                download_software = 'curl'
        else:
            download_software = 'wget'
    else:
        download_software = 'axel'
else:
    download_software = 'aria2c'
    '''
'''
    if download_software.strip().lower() not in download_software_list:
        print('WARNING: Requested Software not supported!\nBiligrab only support these following software(s):\n' + str(download_software_list) + 'Trying to find avalable one...')
        for software in download_software_list:
            output = commands.getstatusoutput(software + ' --help')
            if str(output[0]) != '32512':  #If exist
                download_software = software
                break
    if concat_software.strip().lower() not in concat_software_list:
        print('WARNING: Requested Software not supported!\nBiligrab only support these following software(s):\n' + str(concat_software_list) + 'Trying to find avalable one...')
        for software in concat_software_list:
            output = commands.getstatusoutput(software + ' --help')
            if str(output[0]) != '32512':  #If exist
                concat_software = software
                break'''

总之,上代码,老地方。
https://github.com/cnbeining/Biligrab
Continue reading