Skip to content

Commit

Permalink
新增 Bilibili TV 源 (无水印)
Browse files Browse the repository at this point in the history
我说这个源,太神奇了,下载下来的视频真的没有水印诶~
灵感来自 https://github.com/nilaoda/BBDown

顺带在此版本修复了删除任务后仍在下载的BUG
  • Loading branch information
kengwang committed Nov 22, 2020
1 parent fc8cfa1 commit 6ca19c9
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 13 deletions.
54 changes: 46 additions & 8 deletions BiliDuang/DownloadObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Diagnostics;
using System.IO;
using System.Net;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
using System.Windows.Forms;
Expand Down Expand Up @@ -36,6 +37,7 @@ public class DownloadObject
public string message;
private bool wcusing = false;
public bool handpause;
private bool cancel = false;

//基本信息
public string saveto;
Expand Down Expand Up @@ -193,6 +195,7 @@ internal void Resume()
internal void Cancel()
{
wcusing = false;
cancel = true;
wc.CancelAsync();
wc.Dispose();
}
Expand Down Expand Up @@ -241,16 +244,20 @@ private void CompletedHandle(object sender, AsyncCompletedEventArgs e)

private void Completed(bool complete, string msg)
{
wc.Dispose();
wcusing = false;
sw.Reset();
if (status == 1) return;
if (complete != true)
{
status = -4;
message = "下载未完成,可能是网络中断,正在重试";
Console.WriteLine("下载出错," + msg);
LinkStart();
return;
if (!cancel)
{
status = -4;
message = "下载未完成,可能是网络中断,正在重试";
Console.WriteLine("下载出错," + msg);
LinkStart();
return;
}
}
else
{
Expand Down Expand Up @@ -334,7 +341,7 @@ private void MergeVideo()
exep.StartInfo.FileName = Environment.CurrentDirectory + "/tools/mp4box.exe";
else
exep.StartInfo.FileName = "mp4box";
exep.Start();
exep.Start();
exep.WaitForExit();//关键,等待外部程序退出后才能往下执行
if (File.Exists(saveto + "/" + avname + "." + urls[0].type))
{
Expand Down Expand Up @@ -411,6 +418,12 @@ private bool GetDownloadUrls()
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; //加上这一句
callback = Encoding.UTF8.GetString(MyWebClient.DownloadData(string.Format("https://www.biliplus.com/BPplayurl.php?otype=json&module=bangumi&avid={0}&cid={1}&qn={2}", aid, cid, quality.ToString()))); //如果获取网站页面采用的是UTF-8,则使用这句
break;
case 2:
//force_host=0&&npcybs=0
MyWebClient.Headers.Add("Cookie", User.cookie);
string api = string.Format("/x/tv/ugc/playurl?avid={0}&cid={1}&qn={2}&type=&otype=json&device=android&platform=android&mobi_app=android_tv_yst&build=102801&fnver=0&fnval=80", aid, cid, quality.ToString());
callback = Encoding.UTF8.GetString(MyWebClient.DownloadData("https://api.bilibili.com"+api)); //如果获取网站页面采用的是UTF-8,则使用这句
break;
}
}
catch (WebException e)
Expand Down Expand Up @@ -470,8 +483,33 @@ private bool GetDownloadUrls()
}
return true;
break;
default:
throw new NotImplementedException();
case 2:
if (callback.Contains("-400")) return false;
JSONCallback.FourKPlayer.Data playertv = JsonConvert.DeserializeObject<JSONCallback.FourKPlayer.Data>(callback);
if (!playertv.accept_quality.Contains(quality))
{
Console.WriteLine(string.Format("没有指定的画质 {0} ,最高画质为 {1}, 自动下载最高画质{1}", VideoQuality.Name(quality), VideoQuality.Name(playertv.accept_quality[0])));
quality = playertv.accept_quality[0];
return GetDownloadUrls();//我太懒了,直接递归吧
}
foreach (JSONCallback.FourKPlayer.VideoItem Item in playertv.dash.video)
{
if (Item.id != quality) continue;
DownloadUrl du = new DownloadUrl();
du.type = "mp4";
du.url = Item.base_url;
du.size = -1;//暂不支持检测大小
urls.Add(du);
du = new DownloadUrl();
du.type = "mp3";
du.url = playertv.dash.audio[1].base_url;
du.size = -1;//暂不支持检测大小
urls.Add(du);
return true;
}
return false;
break;
default:
return false;
}

Expand Down
4 changes: 2 additions & 2 deletions BiliDuang/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ namespace BiliDuang
{
class Settings
{
public static string versionCode = "2.1.2";
public static string versionName = "Torikago";
public static string versionCode = "2.1.3";
public static string versionName = "Mindfuck";

public static int maxMission = 1;
public static int useapi=0; //0 - Bilibili 1 - BiliPlus 2 - BiliBili TV
Expand Down
2 changes: 1 addition & 1 deletion BiliDuang/UI/About.resx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@
作者会尽力不断更新功能 所以.......
欢迎打赏,作者现在完全为爱发电,更新的最勤快,功能搞的更多
打赏可以去爱发电给作者打赏.拜托了,这真的对我很重要(逃
本项目使用了 MaterialSkin 的中国修改版 本项目使用了ffmpeg
本项目使用了 MaterialSkin 的中国修改版 本项目使用了mp4box
本项目使用了 NewtonSoft.Json 库 具体见 GitHub 的 README</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
Expand Down
23 changes: 21 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
- [x] 支持港澳台番剧下载
- [x] 支持4K
- [x] 支持互动视频
- [ ] 支持断点续传
- [ ] 支持断点续传 (未实现)
- [ ] 支持aria2c (未实现)



Expand Down Expand Up @@ -145,7 +146,13 @@

感谢 [BiliPlus](https://www.biliplus.com/) 提供的 API 接口.

只需要在设置中勾选 `大陆无版权` 即可使用 BiliPlus API 来解锁区域限制
只需要在设置中选择 API 为 `BiliPlus`即可

### 下载无水印

> 请谨慎使用,注意版权问题,引起的纠纷本作者概不负责
在设置中选择API为 `Bilibili TV`即可

### 互动视频

Expand All @@ -171,6 +178,18 @@
> 请注意: 目前测试出来 [铁心博弈](https://www.bilibili.com/video/BV1MJ411C7ie) 会出现问题,暂时没有时间去适配
## 进阶操作

### 低缓存模式

在此模式下所有图片都不会显示,也不会主动下载,对于感觉卡顿的可以开启

### API 源

* `Bilibili`:原生API,使用了Bilibili网页 API下载
* `BiliPlus`:使用 [BiliPlus API](https://www.biliplus.com/) ,可以下载港澳台资源
* `Bilibili TV`: 使用 `Bilibili`的 TV版 的 API接口

## 感谢

* 感谢各个网站提供的代码提示与API参考
Expand Down

0 comments on commit 6ca19c9

Please sign in to comment.