Skip to content

Commit

Permalink
Add 4K Support Hurray
Browse files Browse the repository at this point in the history
  • Loading branch information
kengwang committed May 31, 2020
1 parent 7e8d5e5 commit f78f3ed
Show file tree
Hide file tree
Showing 7 changed files with 459 additions and 89 deletions.
1 change: 1 addition & 0 deletions BiliDuang/BiliDuang.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
<ItemGroup>
<Compile Include="DownloadObject.cs" />
<Compile Include="DownloadQueue.cs" />
<Compile Include="JSONCallback\FourKPlayer.cs" />
<Compile Include="JSONCallback\BiliPlus\AV.cs" />
<Compile Include="JSONCallback\BiliPlus\Player.cs" />
<Compile Include="JSONCallback\Danmaku.cs" />
Expand Down
219 changes: 139 additions & 80 deletions BiliDuang/DownloadObject.cs

Large diffs are not rendered by default.

304 changes: 304 additions & 0 deletions BiliDuang/JSONCallback/FourKPlayer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,304 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BiliDuang.JSONCallback.FourKPlayer
{
public class SegmentBase
{
/// <summary>
///
/// </summary>
public string Initialization { get; set; }
/// <summary>
///
/// </summary>
public string indexRange { get; set; }
}

public class Segment_base
{
/// <summary>
///
/// </summary>
public string initialization { get; set; }
/// <summary>
///
/// </summary>
public string index_range { get; set; }
}

public class VideoItem
{
/// <summary>
///
/// </summary>
public int id { get; set; }
/// <summary>
///
/// </summary>
public string baseUrl { get; set; }
/// <summary>
///
/// </summary>
public string base_url { get; set; }
/// <summary>
///
/// </summary>
public List<string> backupUrl { get; set; }
/// <summary>
///
/// </summary>
public List<string> backup_url { get; set; }
/// <summary>
///
/// </summary>
public int bandwidth { get; set; }
/// <summary>
///
/// </summary>
public string mimeType { get; set; }
/// <summary>
///
/// </summary>
public string mime_type { get; set; }
/// <summary>
///
/// </summary>
public string codecs { get; set; }
/// <summary>
///
/// </summary>
public int width { get; set; }
/// <summary>
///
/// </summary>
public int height { get; set; }
/// <summary>
///
/// </summary>
public string frameRate { get; set; }
/// <summary>
///
/// </summary>
public string frame_rate { get; set; }
/// <summary>
///
/// </summary>
public string sar { get; set; }
/// <summary>
///
/// </summary>
public int startWithSap { get; set; }
/// <summary>
///
/// </summary>
public int start_with_sap { get; set; }
/// <summary>
///
/// </summary>
public SegmentBase SegmentBase { get; set; }
/// <summary>
///
/// </summary>
public Segment_base segment_base { get; set; }
/// <summary>
///
/// </summary>
public int codecid { get; set; }
}

public class AudioItem
{
/// <summary>
///
/// </summary>
public int id { get; set; }
/// <summary>
///
/// </summary>
public string baseUrl { get; set; }
/// <summary>
///
/// </summary>
public string base_url { get; set; }
/// <summary>
///
/// </summary>
public List<string> backupUrl { get; set; }
/// <summary>
///
/// </summary>
public List<string> backup_url { get; set; }
/// <summary>
///
/// </summary>
public int bandwidth { get; set; }
/// <summary>
///
/// </summary>
public string mimeType { get; set; }
/// <summary>
///
/// </summary>
public string mime_type { get; set; }
/// <summary>
///
/// </summary>
public string codecs { get; set; }
/// <summary>
///
/// </summary>
public int width { get; set; }
/// <summary>
///
/// </summary>
public int height { get; set; }
/// <summary>
///
/// </summary>
public string frameRate { get; set; }
/// <summary>
///
/// </summary>
public string frame_rate { get; set; }
/// <summary>
///
/// </summary>
public string sar { get; set; }
/// <summary>
///
/// </summary>
public int startWithSap { get; set; }
/// <summary>
///
/// </summary>
public int start_with_sap { get; set; }
/// <summary>
///
/// </summary>
public SegmentBase SegmentBase { get; set; }
/// <summary>
///
/// </summary>
public Segment_base segment_base { get; set; }
/// <summary>
///
/// </summary>
public int codecid { get; set; }
}

public class Dash
{
/// <summary>
///
/// </summary>
public int duration { get; set; }
/// <summary>
///
/// </summary>
public double minBufferTime { get; set; }
/// <summary>
///
/// </summary>
public double min_buffer_time { get; set; }
/// <summary>
///
/// </summary>
public List<VideoItem> video { get; set; }
/// <summary>
///
/// </summary>
public List<AudioItem> audio { get; set; }
}

public class Data
{
/// <summary>
///
/// </summary>
public string @from { get; set; }
/// <summary>
///
/// </summary>
public string result { get; set; }
/// <summary>
///
/// </summary>
public string message { get; set; }
/// <summary>
///
/// </summary>
public int quality { get; set; }
/// <summary>
///
/// </summary>
public string format { get; set; }
/// <summary>
///
/// </summary>
public int timelength { get; set; }
/// <summary>
///
/// </summary>
public string accept_format { get; set; }
/// <summary>
///
/// </summary>
public List<string> accept_description { get; set; }
/// <summary>
///
/// </summary>
public List<int> accept_quality { get; set; }
/// <summary>
///
/// </summary>
public int video_codecid { get; set; }
/// <summary>
///
/// </summary>
public string seek_param { get; set; }
/// <summary>
///
/// </summary>
public string seek_type { get; set; }
/// <summary>
///
/// </summary>
public Dash dash { get; set; }
}

public class VideoFrame
{
}

public class FourKPlayer
{
/// <summary>
///
/// </summary>
public int code { get; set; }
/// <summary>
///
/// </summary>
public string message { get; set; }
/// <summary>
///
/// </summary>
public int ttl { get; set; }
/// <summary>
///
/// </summary>
public Data data { get; set; }
/// <summary>
///
/// </summary>
public string session { get; set; }
/// <summary>
///
/// </summary>
public VideoFrame videoFrame { get; set; }
}
}
10 changes: 7 additions & 3 deletions BiliDuang/Other.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,17 +137,21 @@ public static Color GetBackGroundColor()
{
return IsDarkMode() ? Color.FromArgb(33, 33, 33) : Color.FromArgb(63, 81, 181);
}
public static Color GetAccentColor()
{
return IsDarkMode() ? Color.FromArgb(255, 128, 171) : Color.FromArgb(255, 128, 171);
}


public static string GetHtml(string url)
public static string GetHtml(string url, bool withcookie = false)
{
string htmlCode;
HttpWebRequest webRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url);
webRequest.Timeout = 30000;
webRequest.Method = "GET";
webRequest.UserAgent = "Mozilla/4.0";
webRequest.Headers.Add("Accept-Encoding", "gzip, deflate");

if (withcookie)
webRequest.Headers.Add("Cookie", User.cookie + ";CURRENT_QUALITY=120");

HttpWebResponse webResponse = (System.Net.HttpWebResponse)webRequest.GetResponse();

Expand Down
4 changes: 2 additions & 2 deletions BiliDuang/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("2.1.1.0")]
[assembly: AssemblyFileVersion("2.1.1.0")]
1 change: 1 addition & 0 deletions BiliDuang/VideoClass/AV.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class VideoQuality
public static int Q1080P = 80;
public static int Q1080PP = 112;
public static int Q1080P60 = 116;
public static int Q4K = 120;

public static int Int(string q)
{
Expand Down
9 changes: 5 additions & 4 deletions BiliDuang/VideoClass/Video.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ public Video(string vlink)
//第一步,bilibili网址转换
//注意垃圾spm!
//例如 https://www.bilibili.com/bangumi/play/ss28615/?spm=3.0212
if (vlink.IndexOf("?") != -1)
{//去除后置参数
vlink = vlink.Substring(0, vlink.IndexOf("?"));
}

if (vlink.Contains("space.bilibili.com"))
{
//https://space.bilibili.com/341151171
if (vlink.IndexOf("?") != -1)
{
vlink = vlink.Substring(0, vlink.IndexOf("?"));
}

string uid = vlink.Substring(vlink.LastIndexOf("/")+1, vlink.Length - 1 - vlink.LastIndexOf("/"));
ProcessUid(uid);
return;
Expand Down

0 comments on commit f78f3ed

Please sign in to comment.