Skip to content

Commit

Permalink
Merge pull request #2 from Ovler-Young/nmb.best
Browse files Browse the repository at this point in the history
Nmb.best
  • Loading branch information
Ovler-Young authored Oct 23, 2022
2 parents 217d67e + 2b80b68 commit 816317e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 24 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
workflow_dispatch:

jobs:
build:
Expand All @@ -14,6 +13,13 @@ jobs:
- uses: actions/checkout@v1
name: Checkout Code

- uses: actions/cache@v1
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }} #hash of project files
restore-keys: |
${{ runner.os }}-nuget-
- name: Setup MSBuild Path
uses: warrenbuckley/Setup-MSBuild@v1
env:
Expand Down
41 changes: 19 additions & 22 deletions AdnmbBackup-gui/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,16 @@ private void button1_Click(object sender, EventArgs e)
var t = http.GetAsync(url + "?id=" + id + "&page=1");
t.Wait();
var result = t.Result;
label4.Text = "5";
var t2 = result.Content.ReadAsByteArrayAsync();
t2.Wait();
var bytes = t2.Result;
var str = ReadGzip(bytes);
label4.Text = str;
var fpjson = JsonConvert.DeserializeObject<JObject>(str);
label4.Text = "1";
var replyCount = int.Parse(fpjson["replyCount"].ToString());
label4.Text = "2";
var replyCount = int.Parse(fpjson["ReplyCount"].ToString());
int pageCount = replyCount / 19;
if (replyCount % pageCount != 0) pageCount++;
JArray contentJA = fpjson["replys"].ToObject<JArray>();
JArray contentJA = fpjson["Replies"].ToObject<JArray>();
for (var page = 2; page <= pageCount; page++)
{
label4.Text = "正在获取第" + page + "页";
Expand All @@ -81,7 +78,7 @@ private void button1_Click(object sender, EventArgs e)
bytes = t2.Result;
str = ReadGzip(bytes);
var jo = JsonConvert.DeserializeObject<JObject>(str);
JArray ja = jo["replys"].ToObject<JArray>();
JArray ja = jo["Replies"].ToObject<JArray>();
var rpcount = ja.Count;
for (int j = 0; j < rpcount; j++)
{
Expand All @@ -90,14 +87,14 @@ private void button1_Click(object sender, EventArgs e)
}
for (var index = 0; index < contentJA.Count; index++)
{
if (contentJA[index]["title"].ToString() == "广告")
if (contentJA[index]["user_hash"].ToString() == "Tips")
{
contentJA.RemoveAt(index);
index--;
}
}
label4.Text = "完成";
fpjson["replys"].Replace(contentJA);
fpjson["Replies"].Replace(contentJA);
var fjsonstr = JsonConvert.SerializeObject(fpjson, Formatting.Indented);
File.WriteAllText(path, fjsonstr);
}
Expand All @@ -118,18 +115,18 @@ static void ConvertToText(string path)
{
var jo = JsonConvert.DeserializeObject<JObject>(File.ReadAllText(path));
var sb = new StringBuilder();
sb.Append(jo["userid"].ToString()); sb.Append(" "); sb.Append(jo["now"].ToString());
sb.Append(jo["user_hash"].ToString()); sb.Append(" "); sb.Append(jo["now"].ToString());
sb.Append(" No."); sb.Append(jo["id"].ToString()); sb.Append(Environment.NewLine);
if (jo["title"].ToString() != "无标题")
{
sb.Append("标题:"); sb.Append(jo["title"].ToString()); sb.Append(Environment.NewLine);
}
sb.Append(ContentProcess(jo["content"].ToString())); sb.Append(Environment.NewLine);
var ja = jo["replys"].ToObject<JArray>();
var ja = jo["Replies"].ToObject<JArray>();
for (int i = 0; i < ja.Count; i++)
{
sb.Append("------------------------------------"); sb.Append(Environment.NewLine);
sb.Append(ja[i]["userid"].ToString()); sb.Append(" "); sb.Append(ja[i]["now"].ToString());
sb.Append(ja[i]["user_hash"].ToString()); sb.Append(" "); sb.Append(ja[i]["now"].ToString());
sb.Append(" No."); sb.Append(ja[i]["id"].ToString()); sb.Append(Environment.NewLine);
sb.Append(ContentProcess(ja[i]["content"].ToString())); sb.Append(Environment.NewLine);
}
Expand All @@ -139,22 +136,22 @@ static void ConvertToTextPoOnly(string path)
{
var jo = JsonConvert.DeserializeObject<JObject>(File.ReadAllText(path));
var sb = new StringBuilder();
sb.Append(jo["userid"].ToString()); sb.Append(" "); sb.Append(jo["now"].ToString());
sb.Append(jo["user_hash"].ToString()); sb.Append(" "); sb.Append(jo["now"].ToString());
sb.Append(" No."); sb.Append(jo["id"].ToString()); sb.Append(Environment.NewLine);
if (jo["title"].ToString() != "无标题")
{
sb.Append("标题:"); sb.Append(jo["title"].ToString()); sb.Append(Environment.NewLine);
}
sb.Append(ContentProcess(jo["content"].ToString())); sb.Append(Environment.NewLine);
var ja = jo["replys"].ToObject<JArray>();
var poid = jo["userid"].ToString();
var ja = jo["Replies"].ToObject<JArray>();
var poid = jo["user_hash"].ToString();
for (int i = 0; i < ja.Count; i++)
{
if (ja[i]["userid"].ToString() == poid)
if (ja[i]["user_hash"].ToString() == poid)
{
sb.Append("------------------------------------"); sb.Append(Environment.NewLine);
sb.Append(ja[i]["userid"].ToString()); sb.Append(" "); sb.Append(ja[i]["now"].ToString());
sb.Append("N."); sb.Append(ja[i]["id"].ToString()); sb.Append(Environment.NewLine);
sb.Append(ja[i]["user_hash"].ToString()); sb.Append(" "); sb.Append(ja[i]["now"].ToString());
sb.Append("No."); sb.Append(ja[i]["id"].ToString()); sb.Append(Environment.NewLine);
sb.Append(ContentProcess(ja[i]["content"].ToString())); sb.Append(Environment.NewLine);
}
}
Expand Down Expand Up @@ -220,10 +217,10 @@ private void Form1_Shown(object sender, EventArgs e)
var bytes = t2.Result;
var str = ReadGzip(bytes);
var fpjson = JsonConvert.DeserializeObject<JObject>(str);
var replyCount = int.Parse(fpjson["replyCount"].ToString());
var replyCount = int.Parse(fpjson["ReplyCount"].ToString());
int pageCount = replyCount / 19;
if (replyCount % pageCount != 0) pageCount++;
JArray contentJA = fpjson["replys"].ToObject<JArray>();
JArray contentJA = fpjson["Replies"].ToObject<JArray>();
for (var page = 2; page <= pageCount; page++)
{
label4.Text = ">>" + id + " 正在获取第" + page + "页";
Expand All @@ -235,7 +232,7 @@ private void Form1_Shown(object sender, EventArgs e)
bytes = t2.Result;
str = ReadGzip(bytes);
var jo = JsonConvert.DeserializeObject<JObject>(str);
JArray ja = jo["replys"].ToObject<JArray>();
JArray ja = jo["Replies"].ToObject<JArray>();
var rpcount = ja.Count;
for (int j = 0; j < rpcount; j++)
{
Expand All @@ -244,13 +241,13 @@ private void Form1_Shown(object sender, EventArgs e)
}
for (var index = 0; index < contentJA.Count; index++)
{
if (contentJA[index]["title"].ToString() == "广告")
if (contentJA[index]["user_hash"].ToString() == "Tips")
{
contentJA.RemoveAt(index);
index--;
}
}
fpjson["replys"].Replace(contentJA);
fpjson["Replies"].Replace(contentJA);
var fjsonstr = JsonConvert.SerializeObject(fpjson, Formatting.Indented);
File.WriteAllText(path, fjsonstr);
ConvertToText(path);
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# AdnmbBackup-gui
一个让你本地备份A岛串的小程序
已完美适配X岛
[饼干获取教程](https://www.coldthunder11.com/index.php/2020/03/19/%e5%a6%82%e4%bd%95%e8%8e%b7%e5%8f%96a%e5%b2%9b%e7%9a%84%e9%a5%bc%e5%b9%b2/)
支持批量自动备份,在程序目录下新建AtuobBackupList.txt将需要自动备份的串号填入(一行一个),每天第一次打开会自动备份
需要 .net framework4.8
Expand Down

0 comments on commit 816317e

Please sign in to comment.