Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

文件名称自定义增加新参数:增加上传者名称,mid参数 #362

Merged
merged 2 commits into from
May 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions BBDown.Core/Entity/Entity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public class Page
public string res;
public string cover;
public string desc;
public string ownerName;
public string ownerMid;
public List<ViewPoint> points = new List<ViewPoint>();

public Page(int index, string aid, string cid, string epid, string title, int dur, string res)
Expand Down Expand Up @@ -55,6 +57,21 @@ public Page(int index, string aid, string cid, string epid, string title, int du
this.desc = desc;
}

public Page(int index, string aid, string cid, string epid, string title, int dur, string res, string cover, string desc, string ownerName, string ownerMid)
{
this.aid = aid;
this.index = index;
this.cid = cid;
this.epid = epid;
this.title = title;
this.dur = dur;
this.res = res;
this.cover = cover;
this.desc = desc;
this.ownerName = ownerName;
this.ownerMid = ownerMid;
}

public Page(int index, Page page)
{
this.index = index;
Expand All @@ -65,6 +82,8 @@ public Page(int index, Page page)
this.dur = page.dur;
this.res = page.res;
this.cover = page.cover;
this.ownerName = page.ownerName;
this.ownerMid = page.ownerMid;
}

public override bool Equals(object obj)
Expand Down
9 changes: 8 additions & 1 deletion BBDown.Core/Fetcher/CheeseInfoFetcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public async Task<VInfo> FetchAsync(string id)
string cover = data.GetProperty("cover").ToString();
string title = data.GetProperty("title").ToString();
string desc = data.GetProperty("subtitle").ToString();
string ownerName = data.GetProperty("up_info").GetProperty("uname").ToString();
string ownerMid = data.GetProperty("up_info").GetProperty("mid").ToString();
var pages = data.GetProperty("episodes").EnumerateArray().ToList();
List<Page> pagesInfo = new List<Page>();
foreach (var page in pages)
Expand All @@ -32,7 +34,12 @@ public async Task<VInfo> FetchAsync(string id)
page.GetProperty("cid").ToString(),
page.GetProperty("id").ToString(),
page.GetProperty("title").ToString().Trim(),
page.GetProperty("duration").GetInt32(), "");
page.GetProperty("duration").GetInt32(),
"",
"",
"",
ownerName,
ownerMid);
if (p.epid == id) index = p.index.ToString();
pagesInfo.Add(p);
}
Expand Down
4 changes: 3 additions & 1 deletion BBDown.Core/Fetcher/FavListFetcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ public async Task<VInfo> FetchAsync(string id)
m.GetProperty("duration").GetInt32(),
"",
m.GetProperty("cover").ToString(),
m.GetProperty("intro").ToString());
m.GetProperty("intro").ToString(),
m.GetProperty("upper").GetProperty("name").ToString(),
m.GetProperty("upper").GetProperty("mid").ToString());
if (!pagesInfo.Contains(p)) pagesInfo.Add(p);
}
}
Expand Down
6 changes: 5 additions & 1 deletion BBDown.Core/Fetcher/MediaListFetcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public async Task<VInfo> FetchAsync(string id)
{
var pageCount = m.GetProperty("page").GetInt32();
var desc = m.GetProperty("intro").GetString();
var ownerName = m.GetProperty("upper").GetProperty("name").ToString();
var ownerMid = m.GetProperty("upper").GetProperty("mid").ToString();
foreach (var page in m.GetProperty("pages").EnumerateArray())
{
Page p = new Page(index++,
Expand All @@ -54,7 +56,9 @@ public async Task<VInfo> FetchAsync(string id)
page.GetProperty("duration").GetInt32(),
page.GetProperty("dimension").GetProperty("width").ToString() + "x" + page.GetProperty("dimension").GetProperty("height").ToString(),
m.GetProperty("cover").ToString(),
desc);
desc,
ownerName,
ownerMid);
if (!pagesInfo.Contains(p)) pagesInfo.Add(p);
else index--;
}
Expand Down
10 changes: 9 additions & 1 deletion BBDown.Core/Fetcher/NormalInfoFetcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public async Task<VInfo> FetchAsync(string id)
string title = data.GetProperty("title").ToString();
string desc = data.GetProperty("desc").ToString();
string pic = data.GetProperty("pic").ToString();
var owner = data.GetProperty("owner");
string ownerMid = owner.GetProperty("mid").ToString();
string ownerName = owner.GetProperty("name").ToString();
string pubTime = data.GetProperty("pubdate").ToString();
pubTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).AddSeconds(Convert.ToDouble(pubTime)).ToLocalTime().ToString();
bool bangumi = false;
Expand All @@ -36,7 +39,12 @@ public async Task<VInfo> FetchAsync(string id)
"", //epid
page.GetProperty("part").ToString().Trim(),
page.GetProperty("duration").GetInt32(),
page.GetProperty("dimension").GetProperty("width").ToString() + "x" + page.GetProperty("dimension").GetProperty("height").ToString());
page.GetProperty("dimension").GetProperty("width").ToString() + "x" + page.GetProperty("dimension").GetProperty("height").ToString(),
"",
"",
ownerName,
ownerMid
);
pagesInfo.Add(p);
}

Expand Down
6 changes: 5 additions & 1 deletion BBDown.Core/Fetcher/SeriesListFetcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ public async Task<VInfo> FetchAsync(string id)
{
var pageCount = m.GetProperty("page").GetInt32();
var desc = m.GetProperty("intro").GetString();
var ownerName = m.GetProperty("upper").GetProperty("name").ToString();
var ownerMid = m.GetProperty("upper").GetProperty("mid").ToString();
foreach (var page in m.GetProperty("pages").EnumerateArray())
{
Page p = new Page(index++,
Expand All @@ -56,7 +58,9 @@ public async Task<VInfo> FetchAsync(string id)
page.GetProperty("duration").GetInt32(),
page.GetProperty("dimension").GetProperty("width").ToString() + "x" + page.GetProperty("dimension").GetProperty("height").ToString(),
m.GetProperty("cover").ToString(),
desc);
desc,
ownerName,
ownerMid);
if (!pagesInfo.Contains(p)) pagesInfo.Add(p);
else index--;
}
Expand Down
6 changes: 5 additions & 1 deletion BBDown/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,9 @@ public static async Task<int> Main(params string[] args)
$"<videoCodecs>: 视频编码\r\n" +
$"<videoBandwidth>: 视频码率\r\n" +
$"<audioCodecs>: 音频编码\r\n" +
$"<audioBandwidth>: 音频码率\r\n\r\n" +
$"<audioBandwidth>: 音频码率\r\n" +
$"<ownerName>: 上传者名称\r\n" +
$"<ownerMid>: 上传者mid\r\n\r\n" +
$"默认为: {SinglePageDefaultSavePath}\r\n"),
new Option<string>(
new string[]{ "--multi-file-pattern", "-M"},
Expand Down Expand Up @@ -1209,6 +1211,8 @@ private static string FormatSavePath(string savePathFormat, string title, Video
"pageTitle" => GetValidFileName(p.title, filterSlash: true),
"aid" => p.aid,
"cid" => p.cid,
"ownerName" => p.ownerName == null ? "" : GetValidFileName(p.ownerName, filterSlash: true),
"ownerMid" => p.ownerMid == null ? "" : p.ownerMid,
"dfn" => videoTrack == null ? "" : videoTrack.dfn,
"res" => videoTrack == null ? "" : videoTrack.res,
"fps" => videoTrack == null ? "" : videoTrack.fps,
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ Options:
<videoBandwidth>: 视频码率
<audioCodecs>: 音频编码
<audioBandwidth>: 音频码率
<ownerName>: 上传者名称
<ownerMid>: 上传者mid

默认为: <videoTitle>

Expand Down Expand Up @@ -174,6 +176,8 @@ Commands:
`<videoBandwidth>`|视频码率
`<audioCodecs>`|音频编码
`<audioBandwidth>`|音频码率
`<ownerName>`|上传者名称(下载番剧时,该值为"")
`<ownerMid>`|上传者mid(下载番剧时,该值为"")

</details>

Expand Down