m13253 / BiliDan

Play videos on Bilibili.com with MPV and Danmaku2ASS
http://m13253.blogspot.com/2014/06/watch-bilibili-with-biligrab-danmaku2ass.html
Other
513 stars 69 forks source link

Add Video + Comment Download Capability #42

Closed antonizoon closed 8 years ago

antonizoon commented 8 years ago

I noticed that while BiliDan is able to play videos with comments, it is also capable of recording them with comments. Thus, I have added a video/comment download feature to BiliDan.

mpv has an argument called --stream-dump=<file>, which can be used to record streaming video to a folder, so I added the argument -r/--record that will set this on mpv. Helpfully, the video will only download, not display, when this argument is used.

I also save the BiliBili API's video_metadata in bilibili-av<AID>-<CID>.json, with the original URL attached, just for the sake of archival.


As a result, the user will get three files when using the --record argument:

bilibili-av<AID>-<CID>.ext        # extension depends on the video type
bilibili-av<AID>-<CID>.ass
bilibili-av<AID>-<CID>.json

In fact, when you use mpv or VLC to play the video, since the .ass file has the same filename, the player will automatically load the comments.


One minor issue is that mpv shows an error even though the file was downloaded correctly. Somehow we need to catch and silence that error, because there is no problem at all.

INFO: Launching media player...
INFO: NOTICE: Ignore "Exiting... (Errors when loading file)", the video downloaded correctly if "Dumping..." finishes.
Playing: http://ws.acgvideo.com/8/65/3262388-1.flv?wsTime=1448875618&wsSecret2=dfe83f92bd05b4d489e74b0bda0318f9&oi=1111974496&appkey=85eb6835b0a1034e&or=3231821114

Dumping 6122886/6122886...

Exiting... (Errors when loading file)
m13253 commented 8 years ago

Thank you for your contribution!

But I'm sorry that BiliDan not initially designed for "downloading". For example, BiliDan does not plan to support multi-thread download or auto-resuming.

However you can try Biligrab to suit your need. It is capable to call aria2, axel, or wget to download your video in high resolution.

m13253 commented 8 years ago

Are you planning to isolate the downloader, so that we can make the downloader independent on MPV? If we stick on the existing architecture, it will be fairly hard to add some features such as auto-resuming, batch downloading, or parallel downloading.

By the way, do you have any knowledge on making a GUI? Many users asked about the GUI thing, but I am not good at it.

cnbeining commented 8 years ago

It is not hard: how about we start with refactoring Biligrab?

2015年12月20日星期日,Star Brilliant notifications@github.com 写道:

Are you plan to isolate the download function, so that we can make the downloader independent on MPV? If we stick on the existing architecture, it will be fairly hard to add some features such as auto-resuming, batch downloading, or parallel downloading.

By the way, do you have any knowledge on making a GUI? Many users asked about the GUI thing, but I am not good at it.

— Reply to this email directly or view it on GitHub https://github.com/m13253/BiliDan/pull/42#issuecomment-166135490.

antonizoon commented 8 years ago

For a GUI, I recommend trying out PySide/PyQt, or Kivy. These are good cross-platform GUI toolkits and can even be packed together to work on Windows. But that doesn't particularly address the mpv dependency.

Another method is to stream it to a quick python webserver at http://localhost:5000, from which an HTML5 webapp is generated to play the streaming video. This removes the mpv dependency, as the browser should already have good support for streaming.

I may not be able to spend much more time working on this myself though. I slapped the mod together in one night on request from one of my organization members, but he was too inept to figure out how to install it, as his system used avconv...

cnbeining commented 8 years ago

For running a webserver, refer to: https://github.com/cnbeining/ABPlayerHTML5-Py .

Since I am not in the Mainland, what I focused on is to maximize my connection with multiple threads(the more the better), which makes combining ABPlayerHTML5-Py and Biligrab impossible.

If we are using some single-thread downloader, it is possible that we can make a join: but we have had you-get right now...

antonizoon commented 8 years ago

I've developed a new version of the Bilibili archiver that utilizes Biligrab instead. However, the work done in this fork was instrumental to understanding how to scrape Bilibili metadata for reupload in an item, so thanks a lot.

https://github.com/bibanon/Biligrab