Coder Social home page Coder Social logo

m13253 / bilidan Goto Github PK

View Code? Open in Web Editor NEW
514.0 514.0 69.0 144 KB

Play videos on Bilibili.com with MPV and Danmaku2ASS

Home Page: http://m13253.blogspot.com/2014/06/watch-bilibili-with-biligrab-danmaku2ass.html

License: Other

Python 100.00%
bilibili mpv player

bilidan's People

Contributors

cnbeining avatar dragoonz avatar gongshw avatar lencerf avatar liushuyu avatar m13253 avatar oychao avatar pandada8 avatar tcya avatar tianren avatar typcn avatar zanderzhng avatar zodiacg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bilidan's Issues

API失效啦,但其实也没变太多

@m13253
@910JQK

RT

在5个小时不吃不喝后,问题解决了。

但是我还没想好是不是要开源,因为我用了个比较无耻的办法。。。谁帮我下个决心?

其实不用这么麻烦,但是谁能帮我讲明白,B站的API(http://docs.bilibili.cn/wiki/%E5%88%86%E7%B1%BB:API ) 的签名是怎么生成的?原谅我IQ不足没看懂啥意思。。。给个一步步的给三岁小孩讲的例子吧。。。这问题困扰我一年了。。。

标题格式串怎么样?

个人喜欢截屏, 所以在标题上加一些信息怎么样?

默认值给 %(author)s-%(title)s-%(partname)s

diff --git a/bilidan.py b/bilidan.py
index ac5a20b..e826514 100755
--- a/bilidan.py
+++ b/bilidan.py
@@ -57,8 +57,9 @@ APPSEC = '2ad42749773c441109bdc0191257a664'  # Do not abuse please, get one your
BILIGRAB_HEADER = {'User-Agent': USER_AGENT_API, 'Cache-Control': 'no-cache', 'Pragma': 'no-cache'}


-def biligrab(url, *, debug=False, verbose=False, media=None, cookie=None, quality=None, source=None, mpvflags=[], d2aflags={}):
-
+def biligrab(url, *, debug=False, verbose=False, media=None, cookie=None, quality=None, source=None, 
+    mpvflags=[], d2aflags={}, title_fmt = "%(title)s"):
+   
    url_get_metadata = 'http://api.bilibili.com/view?'
    url_get_comment = 'http://comment.bilibili.com/%(cid)s.xml'
    if source == 'overseas':
@@ -178,7 +179,7 @@ def biligrab(url, *, debug=False, verbose=False, media=None, cookie=None, qualit
        comment_out.flush()
        return comment_out

-    def launch_player(video_metadata, media_urls, comment_out, is_playlist=False):
+    def launch_player(video_metadata, media_urls, comment_out, is_playlist=False, title_fmt = "%(title)s"):
        '''Launch MPV media player

        Arguments: video_metadata, media_urls, comment_out
@@ -195,14 +196,14 @@ def biligrab(url, *, debug=False, verbose=False, media=None, cookie=None, qualit
            command_line += ['--cache-file', 'TMP']
        command_line += ['--http-header-fields', 'User-Agent: '+USER_AGENT_PLAYER.replace(',', '\\,')]
        if mpv_version_gte_0_6:
-            command_line += ['--media-title', video_metadata.get('title', url)]
+            command_line += ['--media-title', title_fmt % video_metadata]
        if is_playlist or len(media_urls) > 1:
            command_line += ['--merge-files']
        if mpv_version_gte_0_4:
            command_line += ['--no-video-aspect', '--sub-ass', '--sub-file', comment_out.name]
        else:
            command_line += ['--no-aspect', '--ass', '--sub', comment_out.name]
-        command_line += ['--vf', 'lavfi="fps=fps=50:round=down"']
+        #command_line += ['--vf', 'lavfi="fps=fps=50:round=down"']
        command_line += mpvflags
        if is_playlist:
            command_line += ['--playlist']
@@ -253,7 +254,7 @@ def biligrab(url, *, debug=False, verbose=False, media=None, cookie=None, qualit
    comment_out = convert_comments(video_metadata['cid'], video_size)

    logging.info('Launching media player...')
-    player_exit_code = launch_player(video_metadata, media_urls, comment_out)
+    player_exit_code = launch_player(video_metadata, media_urls, comment_out, title_fmt=title_fmt)
    comment_out.close()
    return player_exit_code

@@ -434,6 +435,7 @@ def main():
    parser.add_argument('--hd', action='store_true', help='Shorthand for -q 4')
    parser.add_argument('--mpvflags', metavar='FLAGS', default='', help='Parameters passed to mpv, formed as \'--option1=value1 --option2=value2\'')
    parser.add_argument('--d2aflags', '--danmaku2assflags', metavar='FLAGS', default='', help='Parameters passed to Danmaku2ASS, formed as \'option1=value1,option2=value2\'')
+    parser.add_argument('-t', '--titleformat', default="%(author)s-%(title)s-%(partname)s", help='Custom title format from Bilibili API fields')
    parser.add_argument('url', metavar='URL', nargs='+', help='Bilibili video page URL (http://www.bilibili.com/video/av*/)')
    args = parser.parse_args()
    logging.basicConfig(format='%(levelname)s: %(message)s', level=logging.DEBUG if args.verbose else logging.INFO)
@@ -445,10 +447,11 @@ def main():
        raise ValueError('invalid value specified for --source, see --help for more information')
    mpvflags = args.mpvflags.split()
    d2aflags = dict((i.split('=', 1) if '=' in i else [i, ''] for i in args.d2aflags.split(','))) if args.d2aflags else {}
+    title_fmt = args.titleformat
    retval = 0
    for url in args.url:
        try:
-            retval = retval or biligrab(url, debug=args.debug, verbose=args.verbose, media=args.media, cookie=args.cookie, quality=quality, source=source, mpvflags=mpvflags, d2aflags=d2aflags)
+            retval = retval or biligrab(url, debug=args.debug, verbose=args.verbose, media=args.media, cookie=args.cookie, quality=quality, source=source, mpvflags=mpvflags, d2aflags=d2aflags, title_fmt=title_fmt)
        except OSError as e:
            logging.error(e)
            retval = retval or e.errno

Python version check code not run on Python 2

Hello,

I noticed some code snippets like this:

def biligrab(url, *, debug=False, verbose=False, …):
    pass

But the interpreter(python2 on OS X) shows syntax error(caused by asterisk)
and will also trigger

File "bilidan.py", line 14
SyntaxError: Non-ASCII character '\xe2' in file bilidan.py on line 14, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

thus,

if sys.version_info < (3, 0):
    sys.stderr.write('ERROR: Python 3.0 or newer version is required.\n')
    sys.exit(1)

will never run
Insignificant minor bug :-)

部分视频无法播放

部分视频无法用 BiliDan 播放,会卡在 "Playing" 的位置,但没有 mpv 弹出。
尝试用 Chrome 播放了几个相关视频,都出现了 Error #2048,
在关闭 HTTPS-Everywhere 之后恢复正常,不确定是否和此有关。

OS: Fedora 23 x64
BiliDan: master branch, lastest
mpv: from Russian Fedora repo

$ mpv -version
mpv 0.17.0 (C) 2000-2016 mpv/MPlayer/mplayer2 projects
 built on UNKNOWN
ffmpeg library versions:
   libavutil       54.31.100
   libavcodec      56.60.100
   libavformat     56.40.101
   libswscale      3.1.101
   libavfilter     5.40.101
   libswresample   1.2.101
ffmpeg version: 2.8.6

console log:

$ bilidan http://www.bilibili.com/video/av4402402/
INFO: Loading video info...
INFO: Got video cid: 7128089
INFO: Loading video content...
INFO: Got media URLs:
      1: http://cn-tj4-dx.acgvideo.com/vg5/7/1a/7128089-1.flv?expires=1461498900&ssig=9eBbOjwKubexgJFr-S8UOg&oi=3546554225&appkey=452d3958f048c02a&or=987503882&rate=0
      2: http://cn-tj4-dx.acgvideo.com/vg5/7/1a/7128089-2.flv?expires=1461498900&ssig=SyneqUMGoddwMyD916cNCw&oi=3546554225&appkey=452d3958f048c02a&or=987503882&rate=0
      3: http://cn-tj4-dx.acgvideo.com/vg5/7/1a/7128089-3.flv?expires=1461498900&ssig=w_HfY1Dy_MXTA0Lk6rd0vQ&oi=3546554225&appkey=452d3958f048c02a&or=987503882&rate=0
      4: http://cn-tj4-dx.acgvideo.com/vg5/7/1a/7128089-4.flv?expires=1461498900&ssig=kQCHzvA3UFDrlIb3futY5A&oi=3546554225&appkey=452d3958f048c02a&or=987503882&rate=0
      5: http://cn-tj4-dx.acgvideo.com/vg5/7/1a/7128089-5.flv?expires=1461498900&ssig=sm8c-omiPnVw1NOZbolt_w&oi=3546554225&appkey=452d3958f048c02a&or=987503882&rate=0
      6: http://cn-tj4-dx.acgvideo.com/vg5/7/1a/7128089-6.flv?expires=1461498900&ssig=1ZCzcENw5EAZZC6r4flt6g&oi=3546554225&appkey=452d3958f048c02a&or=987503882&rate=0
      7: http://cn-tj4-dx.acgvideo.com/vg5/7/1a/7128089-7.flv?expires=1461498900&ssig=fZ8HUgOuJaG0wpcCHJB9wg&oi=3546554225&appkey=452d3958f048c02a&or=987503882&rate=0
      8: http://cn-tj4-dx.acgvideo.com/vg5/7/1a/7128089-8.flv?expires=1461498900&ssig=ruNo1noB-BUqIRNe6cPiTA&oi=3546554225&appkey=452d3958f048c02a&or=987503882&rate=0
      9: http://cn-tj4-dx.acgvideo.com/vg5/7/1a/7128089-9.flv?expires=1461498900&ssig=Mwjo7e1Gj301JTk30E2wKw&oi=3546554225&appkey=452d3958f048c02a&or=987503882&rate=0
      10: http://cn-tj4-dx.acgvideo.com/vg5/7/1a/7128089-10.flv?expires=1461498900&ssig=pJ7WLTq-nLmFiSpXn6Kr4Q&oi=3546554225&appkey=452d3958f048c02a&or=987503882&rate=0
      11: http://cn-tj4-dx.acgvideo.com/vg5/7/1a/7128089-11.flv?expires=1461498900&ssig=ed_18KcEDDT1UX8LrzDnMA&oi=3546554225&appkey=452d3958f048c02a&or=987503882&rate=0
      12: http://cn-tj4-dx.acgvideo.com/vg5/7/1a/7128089-12.flv?expires=1461498900&ssig=QSZLYZSsyKdKLD4yBiGKrw&oi=3546554225&appkey=452d3958f048c02a&or=987503882&rate=0
      13: http://cn-tj4-dx.acgvideo.com/vg5/7/1a/7128089-13.flv?expires=1461498900&ssig=f3UmvMlAoLF7qAKYhk9TNw&oi=3546554225&appkey=452d3958f048c02a&or=987503882&rate=0
      14: http://cn-tj4-dx.acgvideo.com/vg5/7/1a/7128089-14.flv?expires=1461498900&ssig=QF5lc5vAvnpsBy1vKH2ZtA&oi=3546554225&appkey=452d3958f048c02a&or=987503882&rate=0
      15: http://cn-tj4-dx.acgvideo.com/vg5/7/1a/7128089-15.flv?expires=1461498900&ssig=VkV7x1ycogmltBk5joEtHA&oi=3546554225&appkey=452d3958f048c02a&or=987503882&rate=0
      16: http://cn-tj4-dx.acgvideo.com/vg5/7/1a/7128089-16.flv?expires=1461498900&ssig=BFV-7_7FXFdegZev-hh-qA&oi=3546554225&appkey=452d3958f048c02a&or=987503882&rate=0
      17: http://cn-tj4-dx.acgvideo.com/vg5/7/1a/7128089-17.flv?expires=1461498900&ssig=Z1GRMiTmZP1tl48yAthrIQ&oi=3546554225&appkey=452d3958f048c02a&or=987503882&rate=0
      18: http://cn-tj4-dx.acgvideo.com/vg5/7/1a/7128089-18.flv?expires=1461498900&ssig=ZyAZUX3f1uHQBKaDOzFDkA&oi=3546554225&appkey=452d3958f048c02a&or=987503882&rate=0
      19: http://cn-tj4-dx.acgvideo.com/vg5/7/1a/7128089-19.flv?expires=1461498900&ssig=uWthiz_38EbrzTo1e4vXqg&oi=3546554225&appkey=452d3958f048c02a&or=987503882&rate=0
      20: http://cn-tj4-dx.acgvideo.com/vg5/7/1a/7128089-20.flv?expires=1461498900&ssig=T1OnXqoRZEpsc1XBXpVMKA&oi=3546554225&appkey=452d3958f048c02a&or=987503882&rate=0
INFO: Determining video resolution...
INFO: Video resolution: 1280x720
INFO: Loading comments...
INFO: Invoking Danmaku2ASS, converting to /tmp/tmp-danmaku2ass-4bjat0cs.ass
INFO: Launching media player...
Playing: edl://%157%http://cn-tj4-dx.acgvideo.com/vg5/7/1a/7128089-1.flv?expires=1461498900&ssig=9eBbOjwKubexgJFr-S8UOg&oi=3546554225&appkey=452d3958f048c02a&or=987503882&rate=0;%157%http://cn-tj4-dx.acgvideo.com/vg5/7/1a/7128089-2.flv?expires=1461498900&ssig=SyneqUMGoddwMyD916cNCw&oi=3546554225&appkey=452d3958f048c02a&or=987503882&rate=0;%157%http://cn-tj4-dx.acgvideo.com/vg5/7/1a/7128089-3.flv?expires=1461498900&ssig=w_HfY1Dy_MXTA0Lk6rd0vQ&oi=3546554225&appkey=452d3958f048c02a&or=987503882&rate=0;%157%http://cn-tj4-dx.acgvideo.com/vg5/7/1a/7128089-4.flv?expires=1461498900&ssig=kQCHzvA3UFDrlIb3futY5A&oi=3546554225&appkey=452d3958f048c02a&or=987503882&rate=0;%157%http://cn-tj4-dx.acgvideo.com/vg5/7/1a/7128089-5.flv?expires=1461498900&ssig=sm8c-omiPnVw1NOZbolt_w&oi=3546554225&appkey=452d3958f048c02a&or=987503882&rate=0;%157%http://cn-tj4-dx.acgvideo.com/vg5/7/1a/7128089-6.flv?expires=1461498900&ssig=1ZCzcENw5EAZZC6r4flt6g&oi=3546554225&appkey=452d3958f048c02a&or=987503882&rate=0;%157%http://cn-tj4-dx.acgvideo.com/vg5/7/1a/7128089-7.flv?expires=1461498900&ssig=fZ8HUgOuJaG0wpcCHJB9wg&oi=3546554225&appkey=452d3958f048c02a&or=987503882&rate=0;%157%http://cn-tj4-dx.acgvideo.com/vg5/7/1a/7128089-8.flv?expires=1461498900&ssig=ruNo1noB-BUqIRNe6cPiTA&oi=3546554225&appkey=452d3958f048c02a&or=987503882&rate=0;%157%http://cn-tj4-dx.acgvideo.com/vg5/7/1a/7128089-9.flv?expires=1461498900&ssig=Mwjo7e1Gj301JTk30E2wKw&oi=3546554225&appkey=452d3958f048c02a&or=987503882&rate=0;%158%http://cn-tj4-dx.acgvideo.com/vg5/7/1a/7128089-10.flv?expires=1461498900&ssig=pJ7WLTq-nLmFiSpXn6Kr4Q&oi=3546554225&appkey=452d3958f048c02a&or=987503882&rate=0;%158%http://cn-tj4-dx.acgvideo.com/vg5/7/1a/7128089-11.flv?expires=1461498900&ssig=ed_18KcEDDT1UX8LrzDnMA&oi=3546554225&appkey=452d3958f048c02a&or=987503882&rate=0;%158%http://cn-tj4-dx.acgvideo.com/vg5/7/1a/7128089-12.flv?expires=1461498900&ssig=QSZLYZSsyKdKLD4yBiGKrw&oi=3546554225&appkey=452d3958f048c02a&or=987503882&rate=0;%158%http://cn-tj4-dx.acgvideo.com/vg5/7/1a/7128089-13.flv?expires=1461498900&ssig=f3UmvMlAoLF7qAKYhk9TNw&oi=3546554225&appkey=452d3958f048c02a&or=987503882&rate=0;%158%http://cn-tj4-dx.acgvideo.com/vg5/7/1a/7128089-14.flv?expires=1461498900&ssig=QF5lc5vAvnpsBy1vKH2ZtA&oi=3546554225&appkey=452d3958f048c02a&or=987503882&rate=0;%158%http://cn-tj4-dx.acgvideo.com/vg5/7/1a/7128089-15.flv?expires=1461498900&ssig=VkV7x1ycogmltBk5joEtHA&oi=3546554225&appkey=452d3958f048c02a&or=987503882&rate=0;%158%http://cn-tj4-dx.acgvideo.com/vg5/7/1a/7128089-16.flv?expires=1461498900&ssig=BFV-7_7FXFdegZev-hh-qA&oi=3546554225&appkey=452d3958f048c02a&or=987503882&rate=0;%158%http://cn-tj4-dx.acgvideo.com/vg5/7/1a/7128089-17.flv?expires=1461498900&ssig=Z1GRMiTmZP1tl48yAthrIQ&oi=3546554225&appkey=452d3958f048c02a&or=987503882&rate=0;%158%http://cn-tj4-dx.acgvideo.com/vg5/7/1a/7128089-18.flv?expires=1461498900&ssig=ZyAZUX3f1uHQBKaDOzFDkA&oi=3546554225&appkey=452d3958f048c02a&or=987503882&rate=0;%158%http://cn-tj4-dx.acgvideo.com/vg5/7/1a/7128089-19.flv?expires=1461498900&ssig=uWthiz_38EbrzTo1e4vXqg&oi=3546554225&appkey=452d3958f048c02a&or=987503882&rate=0;%158%http://cn-tj4-dx.acgvideo.com/vg5/7/1a/7128089-20.flv?expires=1461498900&ssig=T1OnXqoRZEpsc1XBXpVMKA&oi=3546554225&appkey=452d3958f048c02a&or=987503882&rate=0

视频不从0秒开始播放

你好作者, 我今天才第一次接触这工具, 很是喜欢. 玩了一天还用Automator调了个applescript方便右键直接获取链接并调用, 感谢感谢.

我发现个问题, 启动mpv之后b站的视频都不是从0秒开始播放的, 都是从1%的地方开始, 这是怎么回事? 难道只有我是这种情况么..

Thanks and it is good !

[Continued from https://github.com/m13253/biligrab-danmaku2ass/commit/5e1b22a1f6568c77b60a42c15e4018ad03dc651e#commitcomment-7072492]

Thank you! After installing the latest version of mpv and ffmpeg from gihub, I could run the code successfully! Although some url on bilibili could not be reached.

Additionally, do you have any plan to write a client for bilibili?

会员的世界有办法播放吗0 0

rt,,
bilidan -v -d http://www.bilibili.com/video/av2095086/
DEBUG: Detected mpv version: 0.8.2
INFO: Loading video info...
DEBUG: Fetch: http://api.bilibili.com/view?id=2095086&type=json&page=1&appkey=85eb6835b0a1034e&sign=a8d38ffbca26176a0e8187b435ed2f5d
ERROR: Error message: no perm error, please login.
ERROR: Can not get 'cid' from http://www.bilibili.com/video/av2095086/
Traceback (most recent call last):
File "/usr/share/bilidan/bilidan.py", line 466, in
sys.exit(main())
File "/usr/share/bilidan/bilidan.py", line 451, in main
retval = retval or biligrab(url, debug=args.debug, verbose=args.verbose, media=args.media, cookie=args.cookie, quality=quality, source=source, mpvflags=mpvflags, d2aflags=d2aflags)
File "/usr/share/bilidan/bilidan.py", line 276, in biligrab
video_metadata = fetch_video_metadata(aid, pid)
File "/usr/share/bilidan/bilidan.py", line 99, in fetch_video_metadata
raise ValueError('Can not get 'cid' from %s' % url)
ValueError: Can not get 'cid' from http://www.bilibili.com/video/av2095086/

会员的世界会返回一个未登录error orz2333
我试了下把登录过的cookie导入依然访问不能orz

[Win]有视频无弹幕

涉及到Win很可能是个wont fix不过还是斗胆一问……

C:\Tools\BiliDan>python bilidan.py -v http://www.bilibili.com/video/av2441808/
DEBUG: Detected mpv version: git-82ff32f
INFO: Loading video info...
DEBUG: Fetch: http://api.bilibili.com/view?appkey=85eb6835b0a1034e&sign=130ba302
ca4eab9667589543be81a74d&type=json&id=2441808&page=1
INFO: Got video cid: 3822526
INFO: Loading video content...
DEBUG: Fetch: http://interface.bilibili.com/playurl?appkey=85eb6835b0a1034e&sign
=e8d27ae463e090d51f86c43747673780&cid=3822526
INFO: Got media URLs:
      1: http://cn-jlcc1-cu.acgvideo.com/vg3/1/ff/3822526-1.flv?expires=14345805
00&ssig=3d9QRYspyMGjDTbldnFEyw&o=658609317&rate=0
INFO: Determining video resolution...
DEBUG: Executing: ffprobe -icy 0 -loglevel repeat+warning -print_format json -se
lect_streams v -show_streams -timeout 60000000 -user-agent 'Mozilla/5.0 (Windows
 NT 6.1; WOW64; rv:6.0.2) Gecko/20100101 Firefox/6.0.2 Fengfan/1.0' -- 'http://c
n-jlcc1-cu.acgvideo.com/vg3/1/ff/3822526-1.flv?expires=1434580500&ssig=3d9QRYspy
MGjDTbldnFEyw&o=658609317&rate=0'
INFO: Video resolution: 1280x720
INFO: Loading comments...
DEBUG: Fetch: http://comment.bilibili.com/3822526.xml
INFO: Invoking Danmaku2ASS, converting to c:\users\leoliu\appdata\local\temp\tmp
-danmaku2ass-ghqb7z.ass
INFO: Launching media player...
DEBUG: Compare mpv version: git-82ff32f >= 0.6
DEBUG: Compare mpv version: git-82ff32f >= 0.4
DEBUG: Executing: mpv --autofit 950x540 --cache-file TMP --framedrop vo --http-h
eader-fields 'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0.2) Gecko/20
100101 Firefox/6.0.2 Fengfan/1.0' --media-title 【四月是你的谎言AMV】一直“有”
你的四月 --no-video-aspect --sub-ass --sub-file c:\users\leoliu\appdata\local\te
mp\tmp-danmaku2ass-ghqb7z.ass --vf 'lavfi="fps=fps=60:round=down"' -- 'http://cn
-jlcc1-cu.acgvideo.com/vg3/1/ff/3822526-1.flv?expires=1434580500&ssig=3d9QRYspyM
GjDTbldnFEyw&o=658609317&rate=0'

尝试在Fetch的部分加了一句logging.info输出可以看到resp_comment是有内容的,但临时ass是0字节。danmaku2ass的部分没有更多的调试信息输出所以不知道问题出在哪里。

另:Win下解压mpv和ffmpeg,安装python3(或portable python),设置好PATH后可以跑起来bilidan,但是需要将两处用到subprocess.DEVNULL替换:

FNULL = open(os.devnull,'w')

用FNULL替换掉subprocess.DEVNULL即可正常运行。但遇到了上述问题。

木有视频,弹幕输出在终端里面,有声音.

终端输出如下:
kkk@kkk-ThinkPad-Edge-E530:~$ ./bilidan.py http://www.bilibili.com/video/av2273687/
INFO: Loading video info...
INFO: Got video cid: 3544591
INFO: Loading video content...
INFO: Got media URLs:
1: http://cn-hnhy1-dx.acgvideo.com/vg4/c/0b/3544591-1.flv?expires=1430567700&ssig=or59IGSY4pUtPMGs-9wWgg&o=1873787758&rate=0
INFO: Determining video resolution...
INFO: Video resolution: 1280x720
INFO: Loading comments...
INFO: Invoking Danmaku2ASS, converting to /tmp/tmp-danmaku2ass-dyybhzh7.ass
WARNING: Invalid comment:
WARNING: Invalid comment:
INFO: Launching media player...
Playing: http://cn-hnhy1-dx.acgvideo.com/vg4/c/0b/3544591-1.flv?expires=1430567700&ssig=or59IGSY4pUtPMGs-9wWgg&o=1873787758&rate=0
[ytdl_hook] Traceback (most recent call last):
[ytdl_hook] File "/usr/bin/youtube-dl", line 3, in
[ytdl_hook] import youtube_dl
[ytdl_hook] ImportError: No module named 'youtube_dl'
[ytdl_hook] Your version of youtube-dl is too old! You need at least version '2014.11.26', try running youtube-dl -U.
[libav/demuxer] flv: max_analyze_duration 5000000 reached
(+) Video --vid=1 (h264)
(+) Audio --aid=1 (aac)
(+) Subs --sid=1 'tmp-danmaku2ass-dyybhzh7.ass' (ass) (external)
Opening video filter: [lavfi graph=fps=fps=60:round=down]
AO: [pulse] 44100Hz stereo 2ch float
[libav] fps: No such option: round.
[libav] AVFilterGraph: Error initializing filter 'fps' with args 'fps=60:round=down'
[lavfi] Can't configure libavfilter graph.
Video filter chain:
[vd] 1280x720 yuv420p BT.709 (HD)/TV CL=mpeg2/4/h264
[in] 1280x720 yuv420p BT.709 (HD)/TV CL=mpeg2/4/h264
[lavfi] 1280x720 yuv420p BT.709 (HD)/TV CL=mpeg2/4/h264 <---
[out] ???
Cannot initialize video filters.
Could not initialize video chain.
Video: no video

Is it possible to add a '--no-merge-files' option?

Option --merge-files in mpv makes that all files in the playlist are concatenated into a single, big file. BiliDan enables it by default so that for users it looks like just a long video, with no split.
And that's what I'm embarrassed. I'm a college student and get a limited network bandwidth. That's to say, I am able to watch videos in bilibili.com IMMEDIATELLY only when I spend all my bandwidth. However, with --merge-files, mpv player always tries fetching videos parallelly, which means I have to wait for a long long time before it's ready. Then I remove that option in the script, and it just works like I watch the viedo in web browser.
So is it possible to add a '--no-merge-files' option? Although the strange duration would amaze users, I think time is more precious in a way.
Thanks!
A URL for test:http://www.bilibili.com/video/av431146/

无法播放多P视频

系统:Arch,发issue时前刚更新
mpv: 0.15.0,官方源

无法播放B站的多P视频,mpv 一直在提示[cache] Cache is not responding - slow/stuck network connection?,但是带宽是占满的,通过nethogs查看的确是mpv这个进程占用着网速,但是mpv仍然提示网速慢。

在我的系统上一直都可以复现:找一个多P的视频(比如叛逆的鲁鲁修)即可。

终端的输出:

$ bilidan -v http://www.bilibili.com/video/av391459/
DEBUG: Detected mpv version: 0.15.0
INFO: Loading video info...
DEBUG: Fetch: http://api.bilibili.com/view?type=json&id=391459&sign=40276994573249a38d68ad17c3918885&appkey=85eb6835b0a1034e&page=1
INFO: Got video cid: 600819
INFO: Loading video content...
DEBUG: Fetch: http://interface.bilibili.com/playurl?cid=600819&sign=5b293e128a7f61f96785d3c8ee6ee813&appkey=85eb6835b0a1034e
INFO: Got media URLs:
      1: http://cn-jsyz1-dx.acgvideo.com/vg5/9/19/600819-1.flv?expires=1453237200&ssig=G-TXj2vlT64WhGmz-Wu9Cw&oi=3080560680&appkey=85eb6835b0a1034e&or=2061576138&rate=0
      2: http://cn-jsyz1-dx.acgvideo.com/vg5/9/19/600819-2.flv?expires=1453237200&ssig=GpgdVPu6_FyKjlSAg8zpYw&oi=3080560680&appkey=85eb6835b0a1034e&or=2061576138&rate=0
      3: http://cn-jsyz1-dx.acgvideo.com/vg5/9/19/600819-3.flv?expires=1453237200&ssig=C5PCdHDiuYwwaQtzIHzLcg&oi=3080560680&appkey=85eb6835b0a1034e&or=2061576138&rate=0
      4: http://cn-jsyz1-dx.acgvideo.com/vg5/9/19/600819-4.flv?expires=1453237200&ssig=b2smgxcOVkNmiaegFxiVaw&oi=3080560680&appkey=85eb6835b0a1034e&or=2061576138&rate=0
      5: http://cn-jsyz1-dx.acgvideo.com/vg5/9/19/600819-5.flv?expires=1453237200&ssig=c-bkzmNThi8ACRjjjk0FfA&oi=3080560680&appkey=85eb6835b0a1034e&or=2061576138&rate=0
INFO: Determining video resolution...
DEBUG: Executing: ffprobe -icy 0 -loglevel repeat+warning -print_format json -select_streams v -show_streams -timeout 60000000 -user-agent 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0.2) Gecko/20100101 Firefox/6.0.2 Fengfan/1.0' -- 'http://cn-jsyz1-dx.acgvideo.com/vg5/9/19/600819-1.flv?expires=1453237200&ssig=G-TXj2vlT64WhGmz-Wu9Cw&oi=3080560680&appkey=85eb6835b0a1034e&or=2061576138&rate=0'
INFO: Video resolution: 1920x1080
INFO: Loading comments...
DEBUG: Fetch: http://comment.bilibili.com/600819.xml
INFO: Invoking Danmaku2ASS, converting to /tmp/tmp-danmaku2ass-o1o1rdmm.ass
WARNING: Invalid comment: <d p="135.47700500488,1,25,16777215,1440501458,0,D46a51a2,1150877945"/>
WARNING: Invalid comment: <d p="180.89700317383,1,25,16777215,1440501567,0,D46a51a2,1150884819"/>
INFO: Launching media player...
DEBUG: Compare mpv version: 0.15.0 >= 0.10
DEBUG: Compare mpv version: 0.15.0 >= 0.6
DEBUG: Compare mpv version: 0.15.0 >= 0.4
DEBUG: Executing: mpv --autofit 950x540 --cache-file TMP --framedrop vo --http-header-fields 'User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:6.0.2) Gecko/20100101 Firefox/6.0.2 Fengfan/1.0' --force-media-title '【合集】Code Gease 反叛的鲁鲁修 第一季【1080P】【SOSG】' --merge-files --no-video-aspect --sub-ass --sub-file /tmp/tmp-danmaku2ass-o1o1rdmm.ass --vf 'lavfi="fps=fps=60:round=down"' -- 'http://cn-jsyz1-dx.acgvideo.com/vg5/9/19/600819-1.flv?expires=1453237200&ssig=G-TXj2vlT64WhGmz-Wu9Cw&oi=3080560680&appkey=85eb6835b0a1034e&or=2061576138&rate=0' 'http://cn-jsyz1-dx.acgvideo.com/vg5/9/19/600819-2.flv?expires=1453237200&ssig=GpgdVPu6_FyKjlSAg8zpYw&oi=3080560680&appkey=85eb6835b0a1034e&or=2061576138&rate=0' 'http://cn-jsyz1-dx.acgvideo.com/vg5/9/19/600819-3.flv?expires=1453237200&ssig=C5PCdHDiuYwwaQtzIHzLcg&oi=3080560680&appkey=85eb6835b0a1034e&or=2061576138&rate=0' 'http://cn-jsyz1-dx.acgvideo.com/vg5/9/19/600819-4.flv?expires=1453237200&ssig=b2smgxcOVkNmiaegFxiVaw&oi=3080560680&appkey=85eb6835b0a1034e&or=2061576138&rate=0' 'http://cn-jsyz1-dx.acgvideo.com/vg5/9/19/600819-5.flv?expires=1453237200&ssig=c-bkzmNThi8ACRjjjk0FfA&oi=3080560680&appkey=85eb6835b0a1034e&or=2061576138&rate=0'
Playing: edl://%159%http://cn-jsyz1-dx.acgvideo.com/vg5/9/19/600819-1.flv?expires=1453237200&ssig=G-TXj2vlT64WhGmz-Wu9Cw&oi=3080560680&appkey=85eb6835b0a1034e&or=2061576138&rate=0;%159%http://cn-jsyz1-dx.acgvideo.com/vg5/9/19/600819-2.flv?expires=1453237200&ssig=GpgdVPu6_FyKjlSAg8zpYw&oi=3080560680&appkey=85eb6835b0a1034e&or=2061576138&rate=0;%159%http://cn-jsyz1-dx.acgvideo.com/vg5/9/19/600819-3.flv?expires=1453237200&ssig=C5PCdHDiuYwwaQtzIHzLcg&oi=3080560680&appkey=85eb6835b0a1034e&or=2061576138&rate=0;%159%http://cn-jsyz1-dx.acgvideo.com/vg5/9/19/600819-4.flv?expires=1453237200&ssig=b2smgxcOVkNmiaegFxiVaw&oi=3080560680&appkey=85eb6835b0a1034e&or=2061576138&rate=0;%159%http://cn-jsyz1-dx.acgvideo.com/vg5/9/19/600819-5.flv?expires=1453237200&ssig=c-bkzmNThi8ACRjjjk0FfA&oi=3080560680&appkey=85eb6835b0a1034e&or=2061576138&rate=0
[cache] Cache is not responding - slow/stuck network connection?
[cache] Cache is not responding - slow/stuck network connection?
[cache] Cache is not responding - slow/stuck network connection? # 按下Q键
[file-cache] unexpected EOF
[ffmpeg/demuxer] flv: Could not find codec parameters for stream 0 (Video: none, none): unknown codec
[ffmpeg/demuxer] Consider increasing the value for the 'analyzeduration' and 'probesize' options
[ffmpeg/demuxer] flv: Could not find codec parameters for stream 1 (Audio: none, 0 channels): unknown codec
[ffmpeg/demuxer] Consider increasing the value for the 'analyzeduration' and 'probesize' options
[lavf] av_find_stream_info() failed
EDL: Could not open source file 'http://cn-jsyz1-dx.acgvideo.com/vg5/9/19/600819-2.flv?expires=1453237200&ssig=GpgdVPu6_FyKjlSAg8zpYw&oi=3080560680&appkey=85eb6835b0a1034e&or=2061576138&rate=0'.


Exiting... (Quit)
$

作者,MPV似乎出问题了

i@debian:~/pytools/BiliDan$ ./bilidan.py http://www.bilibili.com/video/av899574/
INFO: Loading video info...
INFO: Got video cid: 1445374
INFO: Loading video content...
INFO: Got media URLs:
      1: http://cn-jsyz4-dx.acgvideo.com/vg6/7/d6/1445374-1.flv?expires=1445665200&ssig=PsA3_NQvtOZ_tgIstdLCLQ&oi=3074389819&appkey=85eb6835b0a1034e&or=244857364&rate=0
      2: http://cn-jsyz4-dx.acgvideo.com/vg6/7/d6/1445374-2.flv?expires=1445665200&ssig=UydrL5VDyB96uibg46xhpg&oi=3074389819&appkey=85eb6835b0a1034e&or=244857364&rate=0
INFO: Determining video resolution...
http://cn-jsyz4-dx.acgvideo.com/vg6/7/d6/1445374-1.flv?expires=1445665200&ssig=PsA3_NQvtOZ_tgIstdLCLQ&oi=3074389819&appkey=85eb6835b0a1034e&or=244857364&rate=0: Input/output error
INFO: Video resolution: 0x0
ERROR: Can not get video size. Comments may be wrongly positioned.
INFO: Loading comments...
INFO: Invoking Danmaku2ASS, converting to /tmp/tmp-danmaku2ass-odazox25.ass
INFO: Launching media player...
Warning: mpv was compiled against a different version of ffmpeg than the shared
library it is linked against. This can expose subtle ABI compatibility issues
and can lead to misbehavior and crashes.
Error parsing option force-media-title (option not found)
Setting commandline option --force-media-title= failed.

Exiting... (Fatal error)

通报:Biligrab上游正式集合danmaku2ass

Biligrab已经在0.95版本内集成了danmaku2ass的代码和调用代码。

由于版本问题,只能通过命令行方式另行调用,但是已经集成了。

我查阅是,MIT与GNUv2兼容,那么我的上游应该可以保持MIT协议。反正我也不准备闭源。

如果有2.7的版本,效果会好得多。。。但是目前也能用了。先这么放着吧。

祝好,
Beining

Bangumi Parse Issue

Some archived bangumi can be parsed successfully. While serial bangumi which is not end yet has a parse error.
New bangumi is saved as an individual video. So we can not add index_n to preprocessed url naively.

One alternative solution is to wait response in fetch_video_metadata to see if it is a 404 Not Found and decide if we should remove the index_n.html from the url or set pid as 1 manually.

Also, I'm wondering if you can refer to http://www.flvcd.com to accelerate and simplify url parsing process.
Thanks for your nice work!

Buffering speed too slow

安装后可以观看视频,但是缓冲速度极慢,极容易中断
(12M电信带宽下缓冲速度每秒大约只有50KB/S)
且暂停后视频不会完全缓冲完毕
但直接将解析信息放入VLC播放却没有这一问题
出现问题的主要是乐视云和直传的视频

Thanks

有些视频某段卡顿

比如http://www.bilibili.com/video/av2033512/
大概50秒开始到58秒结束。关掉弹幕的话就好了。
应该是解析弹幕卡?没看过bilidan源码不清楚。。。
是这样的话不知道什么时候会被刷掉。再遇到我再贴。
截图的话感觉没意义啊。。。

bilidan为当前最新
bilidan --cookie "..." --mpvflags ' --cache=1048576 ' http://www.bilibili.com/video/av2033512/
MPV版本
mpv 0.8.0 (C) 2000-2015 mpv/MPlayer/mplayer2 projects
built on 2015-02-23T17:57:54
ffmpeg library versions:
libavutil 54.15.100
libavcodec 56.13.100
libavformat 56.15.102
libswscale 3.1.101
libavfilter 5.2.103
libswresample 1.1.100

Can not open external file /tmp/tmp-danmaku2ass-46vcnms6.ass.

播放av314的时候,没有弹幕

$ ./bilidan.py http://www.bilibili.com/video/av314/

INFO: Loading video info...
INFO: Got video cid: 529622
INFO: Loading video content...
INFO: Got media URLs:
1: http://edge.v.iask.com.lxdns.com/83873314.hlv?KID=sina,viask&Expires=1424966400&ssig=HA5drDRw6H
INFO: Determining video resolution...
INFO: Video resolution: 512x384
INFO: Loading comments...
INFO: Invoking Danmaku2ASS, converting to /tmp/tmp-danmaku2ass-46vcnms6.ass
ERROR: '8'
ERROR: Danmaku2ASS failed, comments are disabled.
INFO: Launching media player...
Playing: http://edge.v.iask.com.lxdns.com/83873314.hlv?KID=sina,viask&Expires=1424966400&ssig=HA5drDRw6H
[ytdl_hook] youtube-dl not found, not executable, or broken.
Can not open external file /tmp/tmp-danmaku2ass-46vcnms6.ass.
(+) Video --vid=1 (h264)
(+) Audio --aid=1 (aac)
Opening video filter: [lavfi graph=fps=fps=60:round=down]
AO: [pulse] 44100Hz stereo 2ch float
VO: [opengl] 512x384 yuv420p
AV: 00:01:35 / 00:01:36 (99%) A-V: 0.000 Dropped: 6 Cache: 0s+0KB

我去/tmp/tmp-danmaku2ass-46vcnms6.ass 看了一下,长度为0

letv 视频源解析有问题

原因是 urlfetch(url_get_cid+urllib.parse.urlencode(cid_args), user_agent=API_USER_AGENT, cookie=cookie) 里的API_USER_AGENT,换成USER_AGENT 即可...很奇怪其他源没这个问题。

--vf 'lavfi="fps=fps=50:round=down"'意义何在?

使用该vf会关闭硬件解码, 这样不利于省电
不少mpv参数和我自己的mpv选项冲突, 感觉没必要加这些不必要的选项诸如--framedrop no --vo wayland,opengl,opengl-old,x11,corevideo,direct3d_shaders,direct3d,sdl,xv, --

HTML5 API 处理优酷失败

bilidan.py http://www.bilibili.com/video/av1731043/ --source html5 -v
DEBUG: Detected mpv version: 0.6.2
INFO: Loading video info...
DEBUG: Fetch: http://api.bilibili.com/view?sign=251d5404fef1a34a88282f3a952c183e&type=json&page=1&appkey=85eb6835b0a1034e&id=1731043
INFO: Got video cid: 2643856
INFO: This API can be slow, and is unavalable for some source like Tencent.
INFO: Found m3u8, processing...
ERROR: Type str doesn't support the buffer API

Type str doesn't support the buffer API 应该是把 Python 3 的 bytesstr 弄混了吧?

另外 INFO: This API can be slow, and is unavalable for some source like Tencent. 这里用 WARNING 等级是不是比 INFO 好呢?
总觉得这英语怪怪的,好像还拼错了一个词……
改成 WARNING: You are using --source html5, which is an experimental feature and may be slow or unstable.

@cnbeining

Can not get valid media URLs on New Animate

python3 ~/UsefulPythonScript/bilidan.py http://www.bilibili.com/video/av2331762/ --source overseas
INFO: Loading video info...
INFO: Got video cid: 3641122
INFO: Loading video content...
ERROR: Can not get valid media URLs.

I am not in China

mpv的硬件解码无法使用

我的笔记本只支持vaapi硬件解码,默认的mpv的auto模式是无法调用硬件解码,需要在配置文件上写上
hwdec=vaapi
bilidan调用mpv的时候输出
"Error using hardware decoding, falling back to software decoding."
这应该是没有直接用vaapi模式而是自动探测失败后用软解,实际使用也是cpu占用比平时要高,而且会有音画不同步的情况,是不是调用mpv的时候需要特殊的配置文件
我现在在~/.config/mpv/mpv.conf和/etc/mpv/mpv.conf文件都有写hwdec=vaapi,平时使用mpv也是直接就有硬件加速

mpv沒聲音

Welcome to the Emacs shell

0: /home/xyh
(set-frame-parameter nil 'name (buffer-name))
0: /home/xyh
(set-frame-parameter nil 'cursor-type 'hollow)
0: /home/xyh
cd softwares/danmaku2ass/
0: /home/xyh/softwares/danmaku2ass
./bilidan.py http://www.bilibili.com/video/av12847/#
INFO: Loading video info...
INFO: Got video cid: 581303
INFO: Loading video content...
INFO: Got media URLs:
1: http://edge.v.iask.com.lxdns.com/88237778.hlv?KID=sina,viask&Expires=1417968000&ssig=4G5Rva%2FEsV
2: http://edge.v.iask.com.lxdns.com/88237425.hlv?KID=sina,viask&Expires=1417968000&ssig=ClEmpXrIug
3: http://edge.v.iask.com.lxdns.com/88237427.hlv?KID=sina,viask&Expires=1417968000&ssig=%2FlGHBjUJtk
4: http://edge.v.iask.com.lxdns.com/88237784.hlv?KID=sina,viask&Expires=1417968000&ssig=uT8eGsKNM6
5: http://edge.v.iask.com.lxdns.com/88237786.hlv?KID=sina,viask&Expires=1417968000&ssig=usAGdH3kKE
INFO: Determining video resolution...
INFO: Video resolution: 640x480
INFO: Loading comments...
INFO: Invoking Danmaku2ASS, converting to /tmp/tmp-danmaku2ass-er7d1azd.ass
INFO: Launching media player...
�=Playing: edl://%97%http://edge.v.iask.com.lxdns.com/88237778.hlv?KID=sina,viask&Expires=1417968000&ssig=4G5Rva%2FEsV;%95%http://edge.v.iask.com.lxdns.com/88237425.hlv?KID=sina,viask&Expires=1417968000&ssig=ClEmpXrIug;%97%http://edge.v.iask.com.lxdns.com/88237427.hlv?KID=sina,viask&Expires=1417968000&ssig=%2FlGHBjUJtk;%95%http://edge.v.iask.com.lxdns.com/88237784.hlv?KID=sina,viask&Expires=1417968000&ssig=uT8eGsKNM6;%95%http://edge.v.iask.com.lxdns.com/88237786.hlv?KID=sina,viask&Expires=1417968000&ssig=usAGdH3kKE
Stream is not seekable.
[cache] Cache is not responding - slow/stuck network connection?
[cache] Cache is not responding - slow/stuck network connection?
[cache] Cache is not responding - slow/stuck network connection?
[cache] Cache keeps not responding.
[cache] Cache is not responding - slow/stuck network connection?
[cache] Cache is not responding - slow/stuck network connection?
[cache] Cache is not responding - slow/stuck network connection?
[cache] Cache is not responding - slow/stuck network connection?
[stream] Video (+) --vid=1 (h264)
[stream] Audio (+) --aid=1 (aac)
[stream] Subs (+) --sid=1 'tmp-danmaku2ass-er7d1azd.ass' (ass) (external)
[vo/wayland/wayland] failed to connect to a wayland server: check if a wayland compositor is running
[vo/opengl/x11] X11 error: GLXBadFBConfig
[vo/opengl] Could not create GL3 context. Retrying with legacy context.
Opening video filter: [lavfi graph=fps=fps=50:round=down]
AO: [pulse] 44100Hz stereo 2ch float
VO: [opengl] 640x480 yuv420p

fontconfig: cannot find font 'SimHei', falling back to 'DejaVu Sans'

fontconfig: cannot find glyph U+9AD8 in font 'SimHei', falling back to 'SimSun'

[cache] Cache is not responding - slow/stuck network connection?

[cache] Cache is not responding - slow/stuck network connection?
Opening video filter: [lavfi graph=fps=fps=50:round=down]

[cache] Cache is not responding - slow/stuck network connection?

[cache] Cache keeps not responding.

[cache] Cache keeps not responding.

[cache] Cache keeps not responding.
[cache] Cache keeps not responding.
�>INFO: Terminating media player...
Traceback (most recent call last):
File "./bilidan.py", line 215, in launch_player
player_process.wait()
File "/usr/lib/python3.4/subprocess.py", line 1565, in wait
(pid, sts) = self._try_wait(0)
File "/usr/lib/python3.4/subprocess.py", line 1513, in _try_wait
(pid, sts) = _eintr_retry_call(os.waitpid, self.pid, wait_flags)
File "/usr/lib/python3.4/subprocess.py", line 491, in _eintr_retry_call
return func(*args)
KeyboardInterrupt

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "./bilidan.py", line 466, in
sys.exit(main())
File "./bilidan.py", line 451, in main
retval = retval or biligrab(url, debug=args.debug, verbose=args.verbose, media=args.media, cookie=args.cookie, quality=quality, source=source, mpvflags=mpvflags, d2aflags=d2aflags)
File "./bilidan.py", line 256, in biligrab
player_exit_code = launch_player(video_metadata, media_urls, comment_out)
File "./bilidan.py", line 221, in launch_player
player_process.wait(timeout=2)
File "/usr/lib/python3.4/subprocess.py", line 1559, in wait
time.sleep(delay)
KeyboardInterrupt
1: /home/xyh/softwares/danmaku2ass

为什么会播放失败

试了好多次,都是这个结果,怎么解决

liaronce@liaronce-desktop:$ cd BiliDan
liaronce@liaronce-desktop:
/BiliDan$ ./bilidan.py http://www.bilibili.com/video/av4044639/
INFO: Loading video info...
INFO: Got video cid: 6525010
INFO: Loading video content...
INFO: Got media URLs:
1: http://cn-gdfs16-dx.acgvideo.com/vg8/6/92/6525010-1.flv?expires=1462640400&ssig=V9HdLS-fCD7Kb_xmGY50eA&oi=463441933&appkey=452d3958f048c02a&or=244857364&rate=0
2: http://cn-gdfs16-dx.acgvideo.com/vg8/6/92/6525010-2.flv?expires=1462640400&ssig=JcZAxZ42lo5HyxnHH_WTQw&oi=463441933&appkey=452d3958f048c02a&or=244857364&rate=0
3: http://cn-gdfs16-dx.acgvideo.com/vg8/6/92/6525010-3.flv?expires=1462640400&ssig=TpVNfoOEjB0ufZVrrLupMQ&oi=463441933&appkey=452d3958f048c02a&or=244857364&rate=0
4: http://cn-gdfs16-dx.acgvideo.com/vg8/6/92/6525010-4.flv?expires=1462640400&ssig=hT2ICjGZPMdWwNq05bBODw&oi=463441933&appkey=452d3958f048c02a&or=244857364&rate=0
5: http://cn-gdfs16-dx.acgvideo.com/vg8/6/92/6525010-5.flv?expires=1462640400&ssig=_Am5f__uFUMOoZ7V66jkqA&oi=463441933&appkey=452d3958f048c02a&or=244857364&rate=0
INFO: Determining video resolution...
INFO: Video resolution: 1920x1080
INFO: Loading comments...
INFO: Invoking Danmaku2ASS, converting to /tmp/tmp-danmaku2ass-qv_xj3ry.ass
WARNING: Invalid comment:
WARNING: Invalid comment:
INFO: Launching media player...
Error parsing option force-media-title (option not found)
Setting command line option '--force-media-title=' failed.

Exiting... (Fatal error)

mpv version detection

bilidan.py 检测 mpv version 的代码有些问题。当前通过比较 tuple of strings 来确定版本。但在 python 中 '9'>'10',因此不论 mpv 的版本,mpv_version_gte_0_10 都会被设为 True。

下面是我暂用的补救措施,其仍然含有 bug (没有检查 str 能否被转为 int),仅供参考

-        mpv_version_gte_0_10 = mpv_version_master >= ('0', '10') or (len(mpv_version_master) >= 2 and len(mpv_version_master[1]) >= 3) or mpv_version_master[0] == 'git'
-        mpv_version_gte_0_6 = mpv_version_gte_0_10 or mpv_version_master >= ('0', '6') or (len(mpv_version_master) >= 2 and len(mpv_version_master[1]) >= 2) or mpv_version_master[0] == 'git'
-        mpv_version_gte_0_4 = mpv_version_gte_0_6 or mpv_version_master >= ('0', '4') or (len(mpv_version_master) >= 2 and len(mpv_version_master[1]) >= 2) or mpv_version_master[0] == 'git'
+        mpv_version_gte_0_10 = (len(mpv_version_master) >= 2 and len(mpv_version_master[1]) >= 3) or mpv_version_master[0] == 'git' or tuple(map(int,mpv_version_master)) >= (0, 10)
+        mpv_version_gte_0_6 = mpv_version_gte_0_10 or (len(mpv_version_master) >= 2 and len(mpv_version_master[1]) >= 2) or tuple(map(int,mpv_version_master)) >= (0, 6)
+        mpv_version_gte_0_4 = mpv_version_gte_0_6 or tuple(map(int,mpv_version_master)) >= (0, 4)

请教一下为什么我无法转换B站弹幕呢?提示:ValueError: Unknown comment file format

以下命令行转换NICONICO弹幕可以正常完成,但是转换B站字幕时会报错,提示:ValueError: Unknown comment file format,请教一下这是为什么呢?以下是报错信息:
D:\danmaku2ass-master\danmaku2ass.py -o "1 (2).ass" -
s 1920x1080 -fn "微软雅黑" -fs 45 -a 0.8 -dm 5 -ds 5 "1 (2).xml"
Traceback (most recent call last):
File "D:\danmaku2ass-master\danmaku2ass.py", line 870, in
main()
File "D:\danmaku2ass-master\danmaku2ass.py", line 866, in main
Danmaku2ASS(args.file, args.output, width, height, args.protect, args.font,
args.fontsize, args.alpha, args.duration_marquee, args.duration_still, args.redu
ce)
File "D:\danmaku2ass-master\danmaku2ass.py", line 802, in Danma
ku2ASS
comments = ReadComments(input_files, font_size)
File "D:\danmaku2ass-master\danmaku2ass.py", line 831, in ReadC
omments
raise ValueError(_('Unknown comment file format: %s') % i)
ValueError: Unknown comment file format: 1 (2).xml

The "increase_fps" option causes a videoless playback on some configuration of libav.

When using bilidan with default option, along with mpv provided by debian testing, mpv tells me:

[stream] Video (+) --vid=1 (h264)
[stream] Audio (+) --aid=1 (aac)
[stream] Subs (+) --sid=1 'tmp-danmaku2ass-w498a9_7.ass' (ass) (external)
Opening video filter: [lavfi graph=fps=fps=60:round=down]
AO: [pulse] 48000Hz stereo 2ch float
[libav] fps: No such option: round.
[libav] AVFilterGraph: Error initializing filter 'fps' with args 'fps=60:round=down'
[lavfi] Can't configure libavfilter graph.
Video filter chain:
[vd] 640x480 yuv420p Autoselect/Autoselect CL=1
[in] 640x480 yuv420p BT.601 (SD)/TV CL=1
[lavfi] 640x480 yuv420p BT.601 (SD)/TV CL=1 <---
[out] ???
Cannot initialize video filters.
Could not initialize video chain.

and leaves me a videoless playback. Now I have to disable "increase_fps" in the source code.

Error message: app has been blocked.

例如试图加载av314时返回如下信息:

INFO: Loading video info...
ERROR: Error message: app has been blocked.
ERROR: Can not get 'cid' from http://www.bilibili.com/video/av314

Feature request: Freedesktop compliance

Just as a thought that I mentioned to @m13253 over a instant messaging chat. I believe it is reasonable for BiliDan to consider a file type for a playlist/link-list, and with that type of file, BiliDan can use some Freedesktop technique to implement "double-click and play" support of certain Bilibili videos.

For example. A file like the following... (Shebang shows a distribution packaged scenario)

#!/usr/bin/bilidan 
http://www.bilibili.com/video/av2989364/
http://www.bilibili.com/video/av2995079/

As simple as a list of Bilibili links, or it can even be expanded with certain parameters (picture quality, play delay, etc. Which are already implemented by mpv itself). Then a .desktop file containing information and invoke details for BiliDan can be provided with the program itself, showing...

Exec=bilidan %U

And match it with a proper MIME type (even a new one to be introduced), then BiliDan can take care of reading these "list" files when double clicked in a file browser, with no need for command line operations.

Please, reply with questions and doubts.

ubuntu14.0.4上使用报错

mpv使用的源安装, 不是编译安装的, 求解

INFO: Determining video resolution...
INFO: Video resolution: 1280x720
INFO: Loading comments...
INFO: Invoking Danmaku2ASS, converting to /tmp/tmp-danmaku2ass-zcbxhc_m.ass
INFO: Launching media player...
Invalid value for option framedrop: vo
Valid values are: no yes hard
Error parsing option framedrop (option parameter could not be parsed)
Setting commandline option --framedrop=vo failed.

Exiting... (Fatal error)

--d2aflags设置部分d2a参数无效

使用--d2aflags设置duration_marquee或duration_still时,会遇到

ERROR: can't multiply sequence by non-int of type 'float'
ERROR: Danmaku2ASS failed, comments are disabled.

在convert_comments中有部分参数没有从字符串转换为float。

檀木加载不了

INFO: Loading video info...
INFO: Got video cid: 5409444
INFO: Loading video content...
INFO: Got media URLs:
1: http://cn-hbyc7-dx.acgvideo.com/vg126/a/c1/5409444-1.flv?expires=1450763700&ssig=qWggsXjNlan997Vyc1JQTQ&oi=3684215954&appkey=85eb6835b0a1034e&or=2002014922&rate=0
INFO: Determining video resolution...
INFO: Video resolution: 1280x720
INFO: Loading comments...
INFO: Invoking Danmaku2ASS, converting to /tmp/tmp-danmaku2ass-l7m63fzj.ass
WARNING: Invalid comment:
INFO: Launching media player...
Playing: http://cn-hbyc7-dx.acgvideo.com/vg126/a/c1/5409444-1.flv?expires=1450763700&ssig=qWggsXjNlan997Vyc1JQTQ&oi=3684215954&appkey=85eb6835b0a1034e&or=2002014922&rate=0
Can not open external file /tmp/tmp-danmaku2ass-l7m63fzj.ass.
(+) Video --vid=1 (h264)
(+) Audio --aid=1 (aac)
Opening video filter: [lavfi graph=fps=fps=60:round=down]
AO: [alsa] 48000Hz stereo 2ch float
VO: [opengl] 1280x720 yuv420p
AV: 00:01:28 / 00:05:22 (27%) A-V: 0.000 Dropped: 4 Cache: 9s+42MB

Exiting... (Quit)

Application broken..

output:

INFO: Loading video info...
ERROR: Can not get 'cid' from http://www.bilibili.com/video/av4624739/

播放视频只在终端输出弹幕,不弹出播放器

heracles@Avenger:~$ ./bilidan.py http://www.bilibili.com/video/av314
INFO: Loading video info...
INFO: Got video cid: 3262388
INFO: Loading video content...
INFO: Got media URLs:
1: http://cn-hbjm1-dx.acgvideo.com/vg1/5/ae/3262388-1.flv?expires=1430664900&ssig=mLl9HMRnE9FxLEPkTDHQqQ&o=2874353341&rate=0
INFO: Determining video resolution...
INFO: Video resolution: 512x384
INFO: Loading comments...
INFO: Invoking Danmaku2ASS, converting to /tmp/tmp-danmaku2ass-hkjcs6xz.ass
WARNING: Invalid comment: '/n/n/n/n ~~BILIBILI'
WARNING: Invalid comment: '- -'
INFO: Launching media player...
Playing: http://cn-hbjm1-dx.acgvideo.com/vg1/5/ae/3262388-1.flv?expires=1430664900&ssig=mLl9HMRnE9FxLEPkTDHQqQ&o=2874353341&rate=0
[libav/demuxer] flv: max_analyze_duration 5000000 reached
(+) Video --vid=1 (h264)
(+) Audio --aid=1 (aac)
(+) Subs --sid=1 'tmp-danmaku2ass-hkjcs6xz.ass' (ass) (external)
[vo/opengl/x11] X11 error: GLXBadFBConfig
[vo/opengl] Could not create GL3 context. Retrying with legacy context.
Opening video filter: [lavfi graph=fps=fps=60:round=down]
AO: [pulse] 44100Hz stereo 2ch float
[libav] fps: No such option: round.
[libav] AVFilterGraph: Error initializing filter 'fps' with args 'fps=60:round=down'
[lavfi] Can't configure libavfilter graph.
Video filter chain:
[vd] 512x384 yuv420p Autoselect/Autoselect CL=mpeg2/4/h264
[in] 512x384 yuv420p BT.601 (SD)/TV CL=mpeg2/4/h264
[lavfi] 512x384 yuv420p BT.601 (SD)/TV CL=mpeg2/4/h264 <---
[out] ???
Cannot initialize video filters.
Could not initialize video chain.
Video: no video

Add M3U export.

This function is implemented in Biligrab 0.98.

不再在之前的pull request讨论了,这里单开一个issue。

那么有个问题了:对于不完整的分段或整段视频,我们如何不下载就知道他的长度?这个是应对很多版权或地理限制问题的关键。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.