Skip to content

Commit

Permalink
feat(配置文件): 增加上传者名称,mid参数
Browse files Browse the repository at this point in the history
  • Loading branch information
yukinotech committed May 26, 2022
1 parent fb06e53 commit 3a9d2f1
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 5 deletions.
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
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

0 comments on commit 3a9d2f1

Please sign in to comment.