Skip to content

Commit

Permalink
🚧 Misc
Browse files Browse the repository at this point in the history
  • Loading branch information
rmbadmin committed Nov 15, 2023
1 parent 3d84c89 commit f957a43
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/BD.SteamClient/Constants/SteamApiUrls.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public static class SteamApiUrls
public const string STEAM_PROFILES_URL = "https://steamcommunity.com/profiles/{0}";

public const string STEAM_LOGIN_URL = "https://steamcommunity.com/login/home/?goto=my/profile";
public const string STEAM_BADGES_URL = "https://steamcommunity.com/profiles/{0}/badges/l=schinese&p={1}";
public const string STEAM_BADGES_URL = "https://steamcommunity.com/profiles/{0}/badges/l=schinese&sort=p&p={1}";
public const string STEAM_GAMECARDS_URL = "https://steamcommunity.com/profiles/{0}/gamecards/{1}?l=english";
public const string STEAMAPP_LIST_URL = "https://api.steampowered.com/ISteamApps/GetAppList/v2";
public const string STEAMAPP_LOGO_URL = "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/apps/{0}/{1}.jpg";
Expand Down
2 changes: 2 additions & 0 deletions src/BD.SteamClient/Models/Idle/UserIdleInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ namespace BD.SteamClient.Models.Idle;

public class UserIdleInfo
{
public ushort NextLevel => (ushort)(UserLevel + 1);

/// <summary>
/// 用户等级
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ public SteamIdleCardServiceImpl(

var userIdle = new UserIdleInfo();
userIdle.UserLevel = ushort.TryParse(document.QuerySelector(".friendPlayerLevelNum").TextContent, out var after_userLevel) ? after_userLevel : default;
userIdle.CurrentExp = int.TryParse(document.QuerySelector(".profile_xp_block_xp").TextContent, out var after_currentExp) ? after_currentExp : default;
var matchs = Regex.Matches(document.QuerySelector(".profile_xp_block_remaining").TextContent ?? string.Empty, @"[0-9]+");
userIdle.CurrentExp = int.TryParse(Regex.Match(document.QuerySelector(".profile_xp_block_xp").TextContent, @"\d{1,3}(,\d{3})*").Value, NumberStyles.Number, CultureInfo.CurrentCulture, out var after_currentExp) ? after_currentExp : default;
var matchs = Regex.Matches(document.QuerySelector(".profile_xp_block_remaining").TextContent ?? string.Empty, @"\d{1,3}(,\d{3})*");
if (matchs.Count >= 2)
userIdle.UpExp = int.TryParse(matchs[0].Value, out var after_upExp) ? after_upExp : default;
userIdle.UpExp = int.TryParse(matchs[1].Value, out var after_upExp) ? after_upExp : default;

return (userIdle, badges);
}
Expand Down Expand Up @@ -162,8 +162,6 @@ public async Task<IEnumerable<CardsMarketPrice>> GetCardsMarketPrice(int appId,
private async Task FetchBadgesOnPage(IHtmlDocument document, List<Badge> badges, Func<string, Task<string>> func, bool need_price)
{
var parser = new HtmlParser();
IHtmlDocument? card_document = null;
var card_page = string.Empty;
var badges_rows = document.QuerySelectorAll("div.badge_row.is_link");
foreach (var badge in badges_rows)
{
Expand Down Expand Up @@ -234,14 +232,13 @@ private async Task FetchBadgesOnPage(IHtmlDocument document, List<Badge> badges,

if (need_price)
{
card_page = await func(appid);
card_document = parser.ParseDocument(card_page);
var card_page = await func(appid);
var card_document = parser.ParseDocument(card_page);
var cards = FetchCardsOnPage(card_document);
badge_item.Cards = cards.ToList();
}

badges.Add(badge_item);

}
}

Expand Down

0 comments on commit f957a43

Please sign in to comment.