-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
585 additions
and
0 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
OsuCollectionDownloader.Legacy/Extensions/StringExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using System.Runtime.CompilerServices; | ||
using System.Text; | ||
|
||
namespace OsuCollectionDownloader.Legacy.Extensions; | ||
|
||
internal static class StringExtensions | ||
{ | ||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
internal static string ReplaceInvalidPathChars(this string source) | ||
=> new StringBuilder(source) | ||
.Replace(":", "_") | ||
.Replace("\"", "'") | ||
.Replace("<", string.Empty) | ||
.Replace(">", string.Empty) | ||
.Replace("/", "-") | ||
.Replace("\\", string.Empty) | ||
.Replace("|", string.Empty) | ||
.Replace("?", string.Empty) | ||
.Replace("*", string.Empty) | ||
.ToString(); | ||
} |
30 changes: 30 additions & 0 deletions
30
OsuCollectionDownloader.Legacy/Logging/DownloadProcessorLogger.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace OsuCollectionDownloader.Legacy.Logging; | ||
|
||
internal static partial class DownloadProcessorLogger | ||
{ | ||
[LoggerMessage(EventId = 1, Level = LogLevel.Information, Message = "Attempting to fetch the metadata and beatmaps from the collection. This may take a while.")] | ||
public static partial void OngoingCollectionFetch(this ILogger logger); | ||
|
||
[LoggerMessage(EventId = 2, Level = LogLevel.Error, Message = "Could not fetch the metadata or beatmaps from the collection.")] | ||
public static partial void UnsuccessfulCollectionFetch(this ILogger logger); | ||
|
||
[LoggerMessage(EventId = 3, Level = LogLevel.Information, Message = "'{BeatmapName} already exists.'")] | ||
public static partial void AlreadyExists(this ILogger logger, string beatmapName); | ||
|
||
[LoggerMessage(EventId = 5, Level = LogLevel.Error, Message = "'{BeatmapName}' could not be extracted and has been deleted as such.")] | ||
public static partial void ExtractionFailure(this ILogger logger, string beatmapName); | ||
|
||
[LoggerMessage(EventId = 7, Level = LogLevel.Information, Message = "'{BeatmapName}' has been downloaded successfully.")] | ||
public static partial void SuccessfulDownload(this ILogger logger, string beatmapName); | ||
|
||
[LoggerMessage(EventId = 8, Level = LogLevel.Error, Message = "Could not download '{BeatmapName}'.")] | ||
public static partial void UnsuccessfulDownload(this ILogger logger, string beatmapName); | ||
|
||
[LoggerMessage(EventId = 9, Level = LogLevel.Information, Message = "Download finished.")] | ||
public static partial void DownloadFinished(this ILogger logger); | ||
|
||
[LoggerMessage(EventId = 10, Level = LogLevel.Information, Message = "Generated a .osdb collection at {OsdbFilePath}.")] | ||
public static partial void OsdbCollectionSuccessfulGeneration(this ILogger logger, string osdbFilePath); | ||
} |
112 changes: 112 additions & 0 deletions
112
OsuCollectionDownloader.Legacy/Objects/FetchedCollection.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
using System.Collections.Immutable; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace OsuCollectionDownloader.Legacy.Objects; | ||
|
||
internal sealed record Availability( | ||
[property: JsonPropertyName("more_information")] object MoreInformation, | ||
[property: JsonPropertyName("download_disabled")] bool DownloadDisabled | ||
); | ||
|
||
internal sealed record Beatmap( | ||
[property: JsonPropertyName("accuracy")] double Accuracy, | ||
[property: JsonPropertyName("ar")] double Ar, | ||
[property: JsonPropertyName("beatmapset")] Beatmapset Beatmapset, | ||
[property: JsonPropertyName("beatmapset_id")] int BeatmapsetId, | ||
[property: JsonPropertyName("bpm")] double Bpm, | ||
[property: JsonPropertyName("checksum")] string Checksum, | ||
[property: JsonPropertyName("convert")] bool? Convert, | ||
[property: JsonPropertyName("count_circles")] int CountCircles, | ||
[property: JsonPropertyName("count_sliders")] int CountSliders, | ||
[property: JsonPropertyName("count_spinners")] int CountSpinners, | ||
[property: JsonPropertyName("cs")] double Cs, | ||
[property: JsonPropertyName("deleted_at")] object DeletedAt, | ||
[property: JsonPropertyName("difficulty_rating")] double DifficultyRating, | ||
[property: JsonPropertyName("drain")] double Drain, | ||
[property: JsonPropertyName("failtimes")] Failtimes Failtimes, | ||
[property: JsonPropertyName("hit_length")] int HitLength, | ||
[property: JsonPropertyName("id")] int Id, | ||
[property: JsonPropertyName("is_scoreable")] bool? IsScoreable, | ||
[property: JsonPropertyName("last_updated")] DateTime LastUpdated, | ||
[property: JsonPropertyName("max_combo")] int? MaxCombo, | ||
[property: JsonPropertyName("mode")] string Mode, | ||
[property: JsonPropertyName("mode_int")] int ModeInt, | ||
[property: JsonPropertyName("passcount")] int? Passcount, | ||
[property: JsonPropertyName("playcount")] int? Playcount, | ||
[property: JsonPropertyName("ranked")] int Ranked, | ||
[property: JsonPropertyName("status")] string Status, | ||
[property: JsonPropertyName("total_length")] int TotalLength, | ||
[property: JsonPropertyName("url")] string Url, | ||
[property: JsonPropertyName("user_id")] int UserId, | ||
[property: JsonPropertyName("version")] string Version | ||
); | ||
|
||
internal sealed record Beatmapset( | ||
[property: JsonPropertyName("submitted_date")] DateTime SubmittedDate, | ||
[property: JsonPropertyName("nominations_summary")] NominationsSummary NominationsSummary, | ||
[property: JsonPropertyName("creator")] string Creator, | ||
[property: JsonPropertyName("offset")] int Offset, | ||
[property: JsonPropertyName("artist")] string Artist, | ||
[property: JsonPropertyName("artist_unicode")] string ArtistUnicode, | ||
[property: JsonPropertyName("video")] bool Video, | ||
[property: JsonPropertyName("title")] string Title, | ||
[property: JsonPropertyName("user_id")] int UserId, | ||
[property: JsonPropertyName("ratings")] IImmutableList<int> Ratings, | ||
[property: JsonPropertyName("preview_url")] string PreviewUrl, | ||
[property: JsonPropertyName("ranked_date")] DateTime? RankedDate, | ||
[property: JsonPropertyName("track_id")] int? TrackId, | ||
[property: JsonPropertyName("ranked")] int Ranked, | ||
[property: JsonPropertyName("title_unicode")] string TitleUnicode, | ||
[property: JsonPropertyName("id")] int Id, | ||
[property: JsonPropertyName("bpm")] double Bpm, | ||
[property: JsonPropertyName("spotlight")] bool Spotlight, | ||
[property: JsonPropertyName("covers")] Covers Covers, | ||
[property: JsonPropertyName("discussion_locked")] bool? DiscussionLocked, | ||
[property: JsonPropertyName("source")] string Source, | ||
[property: JsonPropertyName("availability")] Availability Availability, | ||
[property: JsonPropertyName("discussion_enabled")] bool? DiscussionEnabled, | ||
[property: JsonPropertyName("is_scoreable")] bool? IsScoreable, | ||
[property: JsonPropertyName("can_be_hyped")] bool? CanBeHyped, | ||
[property: JsonPropertyName("legacy_thread_url")] string LegacyThreadUrl, | ||
[property: JsonPropertyName("last_updated")] DateTime? LastUpdated, | ||
[property: JsonPropertyName("nsfw")] bool? Nsfw, | ||
[property: JsonPropertyName("play_count")] int? PlayCount, | ||
[property: JsonPropertyName("deleted_at")] object DeletedAt, | ||
[property: JsonPropertyName("storyboard")] bool? Storyboard, | ||
[property: JsonPropertyName("tags")] string Tags, | ||
[property: JsonPropertyName("favourite_count")] int? FavouriteCount, | ||
[property: JsonPropertyName("hype")] Hype Hype, | ||
[property: JsonPropertyName("status")] string Status | ||
); | ||
|
||
internal sealed record Covers( | ||
[property: JsonPropertyName("cover")] string Cover, | ||
[property: JsonPropertyName("list@2x")] string List2x, | ||
[property: JsonPropertyName("card@2x")] string Card2x, | ||
[property: JsonPropertyName("cover@2x")] string Cover2x, | ||
[property: JsonPropertyName("slimcover")] string Slimcover, | ||
[property: JsonPropertyName("list")] string List, | ||
[property: JsonPropertyName("card")] string Card, | ||
[property: JsonPropertyName("slimcover@2x")] string Slimcover2x | ||
); | ||
|
||
internal sealed record Failtimes( | ||
[property: JsonPropertyName("fail")] IImmutableList<int> Fail, | ||
[property: JsonPropertyName("exit")] IImmutableList<int> Exit | ||
); | ||
|
||
internal sealed record Hype( | ||
[property: JsonPropertyName("current")] int Current, | ||
[property: JsonPropertyName("required")] int Required | ||
); | ||
|
||
internal sealed record NominationsSummary( | ||
[property: JsonPropertyName("current")] int Current, | ||
[property: JsonPropertyName("required")] int Required | ||
); | ||
|
||
internal sealed record FetchedCollection( | ||
[property: JsonPropertyName("nextPageCursor")] int? NextPageCursor, | ||
[property: JsonPropertyName("hasMore")] bool HasMore, | ||
[property: JsonPropertyName("beatmaps")] IImmutableList<Beatmap> Beatmaps | ||
); |
98 changes: 98 additions & 0 deletions
98
OsuCollectionDownloader.Legacy/Objects/FetchedCollectionMetadata.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
using System.Collections.Immutable; | ||
using System.Text.Json.Serialization; | ||
|
||
|
||
namespace OsuCollectionDownloader.Legacy.Objects; | ||
|
||
internal sealed record PartialBeatmapset( | ||
[property: JsonPropertyName("beatmaps")] IImmutableList<Beatmap> Beatmaps, | ||
[property: JsonPropertyName("id")] int Id | ||
); | ||
|
||
internal sealed record BpmSpread( | ||
[property: JsonPropertyName("150")] int _150, | ||
[property: JsonPropertyName("160")] int _160, | ||
[property: JsonPropertyName("170")] int _170, | ||
[property: JsonPropertyName("180")] int _180, | ||
[property: JsonPropertyName("190")] int _190, | ||
[property: JsonPropertyName("200")] int _200, | ||
[property: JsonPropertyName("210")] int _210, | ||
[property: JsonPropertyName("220")] int _220, | ||
[property: JsonPropertyName("230")] int _230, | ||
[property: JsonPropertyName("240")] int _240, | ||
[property: JsonPropertyName("250")] int _250, | ||
[property: JsonPropertyName("260")] int _260, | ||
[property: JsonPropertyName("270")] int _270, | ||
[property: JsonPropertyName("280")] int _280, | ||
[property: JsonPropertyName("290")] int _290, | ||
[property: JsonPropertyName("300")] int _300 | ||
); | ||
|
||
internal sealed record Comment( | ||
[property: JsonPropertyName("date")] Date Date, | ||
[property: JsonPropertyName("upvotes")] IImmutableList<int> Upvotes, | ||
[property: JsonPropertyName("userAvatar")] int UserAvatar, | ||
[property: JsonPropertyName("id")] string Id, | ||
[property: JsonPropertyName("message")] string Message, | ||
[property: JsonPropertyName("userId")] int UserId, | ||
[property: JsonPropertyName("username")] string Username | ||
); | ||
|
||
internal sealed record Date( | ||
[property: JsonPropertyName("_seconds")] int Seconds, | ||
[property: JsonPropertyName("_nanoseconds")] int Nanoseconds | ||
); | ||
|
||
internal sealed record DateLastModified( | ||
[property: JsonPropertyName("_seconds")] int Seconds, | ||
[property: JsonPropertyName("_nanoseconds")] int Nanoseconds | ||
); | ||
|
||
internal sealed record DateUploaded( | ||
[property: JsonPropertyName("_seconds")] int Seconds, | ||
[property: JsonPropertyName("_nanoseconds")] int Nanoseconds | ||
); | ||
|
||
internal sealed record DifficultySpread( | ||
[property: JsonPropertyName("1")] int _1, | ||
[property: JsonPropertyName("2")] int _2, | ||
[property: JsonPropertyName("3")] int _3, | ||
[property: JsonPropertyName("4")] int _4, | ||
[property: JsonPropertyName("5")] int _5, | ||
[property: JsonPropertyName("6")] int _6, | ||
[property: JsonPropertyName("7")] int _7, | ||
[property: JsonPropertyName("8")] int _8, | ||
[property: JsonPropertyName("9")] int _9, | ||
[property: JsonPropertyName("10")] int _10 | ||
); | ||
|
||
internal sealed record Modes( | ||
[property: JsonPropertyName("osu")] int Osu | ||
); | ||
|
||
internal sealed record FetchedCollectionMetadata( | ||
[property: JsonPropertyName("dateUploaded")] DateUploaded DateUploaded, | ||
[property: JsonPropertyName("uploader")] Uploader Uploader, | ||
[property: JsonPropertyName("name")] string Name, | ||
[property: JsonPropertyName("id")] int Id, | ||
[property: JsonPropertyName("unknownIds")] IImmutableList<object> UnknownIds, | ||
[property: JsonPropertyName("description")] string Description, | ||
[property: JsonPropertyName("dateLastModified")] DateLastModified DateLastModified, | ||
[property: JsonPropertyName("modes")] Modes Modes, | ||
[property: JsonPropertyName("beatmapCount")] int BeatmapCount, | ||
[property: JsonPropertyName("unsubmittedBeatmapCount")] int UnsubmittedBeatmapCount, | ||
[property: JsonPropertyName("difficultySpread")] DifficultySpread DifficultySpread, | ||
[property: JsonPropertyName("bpmSpread")] BpmSpread BpmSpread, | ||
[property: JsonPropertyName("beatmapsets")] IImmutableList<PartialBeatmapset> Beatmapsets, | ||
[property: JsonPropertyName("unknownChecksums")] IImmutableList<object> UnknownChecksums, | ||
[property: JsonPropertyName("favouritedBy")] IImmutableList<int> FavouritedBy, | ||
[property: JsonPropertyName("favourites")] int Favourites, | ||
[property: JsonPropertyName("comments")] IImmutableList<Comment> Comments | ||
); | ||
|
||
internal sealed record Uploader( | ||
[property: JsonPropertyName("avatarURL")] string AvatarURL, | ||
[property: JsonPropertyName("rank")] int Rank, | ||
[property: JsonPropertyName("id")] int Id, | ||
[property: JsonPropertyName("username")] string Username | ||
); |
19 changes: 19 additions & 0 deletions
19
OsuCollectionDownloader.Legacy/OsuCollectionDownloader.Legacy.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<PublishAot>false</PublishAot> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Karambolo.Extensions.Logging.File" Version="3.5.0" /> | ||
<PackageReference Include="Microsoft.Extensions.http" Version="8.0.0" /> | ||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" /> | ||
<PackageReference Include="System.CommandLine" Version="2.0.0-beta4.22272.1" /> | ||
<PackageReference Include="System.Net.http.Json" Version="8.0.0" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Oops, something went wrong.