Skip to content

Commit

Permalink
增加移动端 接口,推荐使用!!!
Browse files Browse the repository at this point in the history
  • Loading branch information
hupo376787 committed Oct 13, 2024
1 parent 5104157 commit 09c7ea9
Show file tree
Hide file tree
Showing 7 changed files with 887 additions and 75 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ PC打开[weibo.com](https://weibo.com/),点击某一用户头像,进入主



按F12进入控制台,网络-全部,在名称栏选择uid,标头-请求标头-Cookie。右键复制后请填入到Seetings.json。
Cookie可以通过点击上方按钮打开页面扫码获取,或者按F12进入控制台,网络-全部,在名称栏选择uid,标头-请求标头-Cookie。右键复制后请填入到Seetings.json。



Expand Down
13 changes: 4 additions & 9 deletions WeiboAlbumDownloader/Enums/WeiboDataSource.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WeiboAlbumDownloader.Enums
namespace WeiboAlbumDownloader.Enums
{
public enum WeiboDataSource
{
WeiboCn = 0,
WeiboCom1 = 1,
WeiboCom2 = 2,
WeiboCnMobile = 1,
WeiboCom1 = 2,
WeiboCom2 = 3,
}
}
24 changes: 24 additions & 0 deletions WeiboAlbumDownloader/Helpers/HttpHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public static async Task<T> GetAsync<T>(string url, WeiboDataSource dataSource,
{
var stream = lxResponse.GetResponseStream();
StreamReader reader = new StreamReader(stream);

if (!string.IsNullOrEmpty(fileName))
{
FileStream lxFS = File.Create(fileName);
Expand All @@ -73,5 +74,28 @@ public static async Task<T> GetAsync<T>(string url, WeiboDataSource dataSource,
throw;
}
}

public static string GetUniqueFileName(string filePath)
{
// 获取文件目录和扩展名
string directory = Path.GetDirectoryName(filePath)!;
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(filePath);
string extension = Path.GetExtension(filePath);

int count = 1;

// 初始文件路径
string uniqueFilePath = filePath;

// 检查文件是否存在,如果存在则循环添加编号直到找到一个不存在的文件名
while (File.Exists(uniqueFilePath))
{
string newFileName = $"{fileNameWithoutExtension}({count}){extension}";
uniqueFilePath = Path.Combine(directory, newFileName);
count++;
}

return uniqueFilePath;
}
}
}
393 changes: 345 additions & 48 deletions WeiboAlbumDownloader/MainWindow.xaml.cs

Large diffs are not rendered by default.

22 changes: 9 additions & 13 deletions WeiboAlbumDownloader/Models/AlbumDetailModel2.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WeiboAlbumDownloader.Models
{
public partial class AlbumDetailModel2
{
[JsonProperty("data")]
public PhotoListData2 PhotoListData2 { get; set; }
public PhotoListData2? PhotoListData2 { get; set; }

[JsonProperty("ok")]
public long Ok { get; set; }
Expand All @@ -19,10 +15,10 @@ public partial class AlbumDetailModel2
public partial class PhotoListData2
{
[JsonProperty("type")]
public string Type { get; set; }
public string? Type { get; set; }

[JsonProperty("list")]
public List<PhotoListItem2> PhotoListItem2 { get; set; }
public List<PhotoListItem2>? PhotoListItem2 { get; set; }

[JsonProperty("since_id")]
public long SinceId { get; set; }
Expand All @@ -31,24 +27,24 @@ public partial class PhotoListData2
public partial class PhotoListItem2
{
[JsonProperty("pid")]
public string Pid { get; set; }
public string? Pid { get; set; }

[JsonProperty("mid")]
public string Mid { get; set; }
public string? Mid { get; set; }

[JsonProperty("is_paid")]
public bool IsPaid { get; set; }

[JsonProperty("timeline_month")]
public string TimelineMonth { get; set; }
public string? TimelineMonth { get; set; }

[JsonProperty("timeline_year")]
public string TimelineYear { get; set; }
public string? TimelineYear { get; set; }

[JsonProperty("object_id")]
public string ObjectId { get; set; }
public string? ObjectId { get; set; }

[JsonProperty("type")]
public string Type { get; set; }
public string? Type { get; set; }
}
}
8 changes: 4 additions & 4 deletions WeiboAlbumDownloader/Models/SettingsModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
public class SettingsModel
{
//weibo.cn cookie
public string WeiboCnCookie { get; set; }
public string? WeiboCnCookie { get; set; }
//weibo.com cookie
public string WeiboComCookie { get; set; }
public string? WeiboComCookie { get; set; }
//推送到微信,填了就会发送
public string PushPlusToken { get; set; }
public string? PushPlusToken { get; set; }
//是否开启Crontab定时任务
public bool EnableCrontab { get; set; } = true;
//Crontab定时任务
public string Crontab { get; set; } = "14 2 * * *";
public string? Crontab { get; set; } = "14 2 * * *";
//用来跳过到下一个uid的计数。如果当前uid下载的时候已存在文件超过此计数,则判定下载过了。-1表示不判定
public int CountDownloadedSkipToNextUser { get; set; } = 20;
}
Expand Down
Loading

0 comments on commit 09c7ea9

Please sign in to comment.