break和exit()都有问题,一看这个东西就没人用嘛。
唉。
Crayon在WP升级后不显示了,看来需要等待更新了。
代码先扔Gist吧。
https://gist.github.com/superwbd/9605757
还是需要XML啊。
重写了视频源获取,这样B站自己的源也可以保证没问题了。
老地方:https://gist.github.com/superwbd/9605757
'''
Biligrab 0.6
Beining@ACICFG
cnbeining[at]gmail.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 = ''
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))
if 'partname' in lines:
partname = lines[12:-11]
print('partname is ' + str(partname))
if 'title' in lines:
title = lines[9:-8]
print('title is ' + str(title))
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)
request.add_header('Accept-encoding', 'gzip')
response = urllib2.urlopen(request, 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' })
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 main(vid, p, oversea):
global cid
global partname
global title
global videourl
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:
print('Strange, still cannot find cid... One last try, unpredictable')
vid = vid - 1
p = 1
find_cid_api(vid-1, p)
cid = cid + 1
if cid is 0:
cid = str(input('Cannot get cid anyway! If you know the cid, please type it in here, or I will just quit.'))
exit()
#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
folder_to_make = os.getcwd() + '/' + folder
if not os.path.exists(folder_to_make):
os.makedirs(folder_to_make)
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 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 API server!')
response = urllib2.urlopen(request)
data = response.read()
#print(data_list)
rawurl = []
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
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
rawurl = c[39:-5]
rawurl = rawurl.split('|')
break
#print(rawurl)
vid_num = len(rawurl)
#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 -larialog.txt -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!')
exit()
vid = str(raw_input('av'))
p_raw = str(raw_input('P'))
oversea = str(input('Oversea?'))
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
try:
p_list.append(int(item))
except:
print('Cannot read "'+str(item)+'", abondon it.')
break
p_list = list_del_repeat(p_list)
part_now = '0'
for p in p_list:
part_now = str(p)
main(vid, p, oversea)
'''
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'''
我自己不用RSS(没找到好的阅读器。。。我的GR啊),老文章更新后,RSS会提示么?
如果不想,就得发个状态了。
这次是Linux与OSX下原生战渣浪的方法,brought you by dantmnf(http://danknest.org/ ).
项目地址:https://github.com/dantmnf/FlvPatcher/blob/master/blacker.sh
使用方法:
先chmod 777 ./blacker.sh
然后
./blacker.sh -b 500000 /root/fff.mp4 /root/ff400.flv
-b 后接比特数,不是千比特,请注意!如果后黑目标码率大于原始码率,会不能进行。
输入文件需要可以被ffmpeg直接转换成flv。
需要新版ffmpeg,ffmsindex,mkvmerge。
测试视频:http://video.sina.com.cn/v/b/131212996-1062265712.html
原长度4:54,sina播放器显示是这个,但是的确后黑了。
你的捐助会用于40+字幕组的发布和数个汉化组的发布工作。
每月只需要$25。
动动手,帮我们做下去!
首先是,前天晚上,整个机器突然死的起不来了。
Mac的尿性是绝对不会让你知道为什么出问题的,只能猜是系统某个文件挂了。
幸亏学校wifi给力,大干1小时,联网修复,机器就好了。幸好没丢数据。
然后,今天想用的时候,aria2c的binary华丽丽的死了。
dyld: Library not loaded: /usr/local/lib/libnettle.4.5.dylib
一怒之下,删binary,上homebrew。
但是,伟大的homebrew出了问题:这货不建立soft link。结果当然是出不来了。
重置nettle和 gnutls 无果。倒是趁这次机会安了cli tool。
最终抱着试试的态度研究brew到底做了什么,安到哪去了。这货自己弄好了binary,但是藏起来了。
直接soft link过去,齐活。
谁知道系统死了一次后什么东西变了。。。。。。问神吧。
我整个人都不好了:JS版FFMpeg https://github.com/bgrins/videoconverter.js
在P的地方输入:
1,2,3,4,5,6~10
简单明了吧。
单独也好用。
今天发现B站API如果死了程序报错,做一下error-handling.
Gist老地方:https://gist.github.com/superwbd/9605757
代码藏起来,否则页面都慢了。
Continue reading
我们等下会测试效果。
作者:@野生的卷毛君
方法概要:
1.将需上传的视频用专业切割工具分为2段(视音频同时进行切割,不要使用AVS的Trim参数)并分别封装为FLV格式;
(小丸就可以)
2.使用前一代后黑工具Sinahigh 4.0对分段①进行目标码率大于100小于500的后黑;
3.使用维棠硕鼠等支持FLV合并的软件对后黑完成后的分段①和第1步切割完成的分段②进行FLV合并操作;
(个人推荐月亮flv合并器,简单可靠无广告,ffmpeg党随便)
4.直接上传新浪然后等吐出来后投稿。
效果:
上传到新浪后新浪会对分段①的后黑进行CUT操作,也就是自动删掉了后黑,最后吐出来的视频就是分段①+分段②且画质与本地上传用文件相同,源文件5000码率用此法测试通过,画质不变。(至于此法最大能吃多少码率,欢迎更多测试)
优势:
相比于后黑法,此法优势有:
·可以直接在缓冲全部完成前直接拖动进度条而不会出现进度条傲娇
·手动控制新浪分段,节省新浪转换时间
·节省缓冲时间,让小水管获得新生
·可以让原本审核不通过的视频过审(擦边OK 本番禁止)
进度条显示效果:
1.新浪播放器总时间直接为去掉后黑的时间
2.AB站播放器总时间为分段①后黑+分段②时间,缓冲在分段①+分段②的缓冲完成后就会停止,因为新浪已经去掉了后黑(所以拖动进度条时请务必在分段①+分段②总时间之内拖动)
例外情况:
对于极其特殊的某些视频,使用此法后新浪并不会对其进行砍掉后黑的操作,而是保留后黑,但是在播放时Acfun播放器和新浪播放器会在分段①播放完成后直接跳过后黑继续播放分段②→最后产生的效果就是视频播放正常,进度条傲娇穿越。Bilibili播放器则会出现分段①播放完成后画面卡住,待进度条走完后黑到分段②时再继续播放。
移动端测试效果:
AB站移动端最终效果与新浪播放器完全相同→砍掉后黑,总时间与源文件相同,进度条可拖动且不傲娇。
【关于详细使用方法已在编写中,以方便各位使用】
【欢迎进行样本反馈,同时也欢迎各位勇于尝试这个全新的战渣浪方法——中黑法】
Thanks For @忧伤珲舞
Powerd By @咬直钩的卷毛君
http://tieba.baidu.com/p/2967811329?see_lz=1
Python3和2对于input()函数要求不同。
Python2是可以使用raw_input()的。
于是就解决了烦人的“ ‘ ”问题。wwwwwww
地址:
老地方:
https://github.com/superwbd/Mukioplayer-Py-Mac
https://github.com/superwbd/ABPlayerHTML5-Py--nix
以上。
其实是因为晚上吃了面条结果不消化,睡不着打发时间的时候弄的。
系统是OSX10.9.2,随时升级。
地址:https://github.com/superwbd/ffmpeg-x264-tMod-OSX
真没啥好说的,8bit和10bit都有,需要自取,自己安装,Macbook炸了不负责(希望你有AppleCare)。
有啥事可以留言,当然上游问题咱没法解决,直接去上游开issue会快得多。
换了一下系统中的ffmpeg,使用一个单独的binary,而不是homebrew的,重置x264。
Beining@ACICFG
Starting to make binary of ffmpeg and x264-tMod for OSX.
Built on OSX 10.9.2, and will update as it goes.
Github: https://github.com/superwbd/ffmpeg-x264-tMod-OSX
Hope you 've already know what are these. Both 8bit and 10bit of x264 are provided. Use it at your own risk, I am not responsible for your Macbook blowed up(Hope you have AppleCare).
Feel free to leave comments or issues, however I cannot solve any problem from upstream. To make it quick, better reach them to open issues instead of here.
Fix: Use a standalone binary of FFmpeg instead one installed via Homebrew, hope this will make a difference. x264 redone.
Beining@ACICFG