-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from rithik-b/dev/downloader-remake
1.3.0
- Loading branch information
Showing
47 changed files
with
997 additions
and
1,343 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -18,12 +18,11 @@ jobs: | |
uses: actions/setup-dotnet@v1 | ||
with: | ||
dotnet-version: 5.0.x | ||
- name: GetStrippedRefs | ||
env: | ||
FILES_URL: ${{ secrets.BSFILES_URL }} | ||
run: wget --no-check-certificate "$FILES_URL" -q -O bsfiles.zip | ||
- name: ExtractRefs | ||
run: unzip -q -n bsfiles.zip -d ${{github.workspace}}/Refs | ||
- name: Download SIRA References | ||
uses: ProjectSIRA/[email protected] | ||
with: | ||
manifest: ${{github.workspace}}/MorePlaylists/manifest.json | ||
sira-server-code: ${{ secrets.SIRA_SERVER_CODE }} | ||
- name: Download Mod Dependencies | ||
uses: Goobwabber/[email protected] | ||
with: | ||
|
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 |
---|---|---|
|
@@ -16,12 +16,11 @@ jobs: | |
uses: actions/setup-dotnet@v1 | ||
with: | ||
dotnet-version: 5.0.x | ||
- name: GetStrippedRefs | ||
env: | ||
FILES_URL: ${{ secrets.BSFILES_URL }} | ||
run: wget --no-check-certificate "$FILES_URL" -q -O bsfiles.zip | ||
- name: ExtractRefs | ||
run: unzip -q -n bsfiles.zip -d ${{github.workspace}}/Refs | ||
- name: Download SIRA References | ||
uses: ProjectSIRA/[email protected] | ||
with: | ||
manifest: ${{github.workspace}}/MorePlaylists/manifest.json | ||
sira-server-code: ${{ secrets.SIRA_SERVER_CODE }} | ||
- name: Download Mod Dependencies | ||
uses: Goobwabber/[email protected] | ||
with: | ||
|
This file was deleted.
Oops, something went wrong.
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 System.Threading.Tasks; | ||
using SiraUtil.Web; | ||
|
||
namespace MorePlaylists.Entries | ||
{ | ||
internal class AccSaberEntry : SongDetailsEntry | ||
{ | ||
public override string Title { get; protected set; } | ||
public override string Author { get; protected set; } | ||
public override string Description { get; protected set; } | ||
public override string PlaylistURL { get; protected set; } | ||
public override string SpriteString { get; protected set; } | ||
public override SpriteType SpriteType => SpriteType.Playlist; | ||
|
||
public static async Task<AccSaberEntry> GetAccSaberPlaylist(string playlistURL, IHttpService siraHttpService) | ||
{ | ||
AccSaberEntry accSaberEntry = new AccSaberEntry(); | ||
accSaberEntry.PlaylistURL = playlistURL; | ||
await accSaberEntry.DownloadPlaylist(siraHttpService); | ||
if (accSaberEntry.RemotePlaylist != null) | ||
{ | ||
accSaberEntry.Title = accSaberEntry.RemotePlaylist.Title; | ||
accSaberEntry.Author = accSaberEntry.RemotePlaylist.Author; | ||
accSaberEntry.Description = accSaberEntry.RemotePlaylist.Description; | ||
return accSaberEntry; | ||
} | ||
return null; | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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
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,113 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using BeatSaverSharp.Models; | ||
using Newtonsoft.Json; | ||
using SiraUtil.Web; | ||
|
||
namespace MorePlaylists.Entries | ||
{ | ||
internal class BeatSaverResponse | ||
{ | ||
[JsonProperty("docs")] | ||
public List<BeatSaverEntry> Entries { get; protected set; } | ||
} | ||
|
||
internal class BeatSaverEntry : GenericEntry | ||
{ | ||
[JsonProperty("name")] | ||
public override string Title { get; protected set; } | ||
|
||
[JsonProperty("owner")] | ||
public BeatSaverAuthor Owner { get; protected set; } | ||
|
||
[JsonProperty("description")] | ||
public override string Description { get; protected set; } | ||
|
||
[JsonProperty("playlistId")] | ||
public string PlaylistID { get; protected set; } | ||
|
||
[JsonProperty("playlistImage")] | ||
public override string SpriteString { get; protected set; } | ||
|
||
public override SpriteType SpriteType => SpriteType.URL; | ||
|
||
public override string Author | ||
{ | ||
get => Owner.Name; | ||
protected set { } | ||
} | ||
|
||
public override string PlaylistURL | ||
{ | ||
get => $"https://api.beatsaver.com/playlists/id/{PlaylistID}/download"; | ||
protected set { } | ||
} | ||
|
||
private List<Song> songs; | ||
|
||
public override async Task<List<Song>> GetSongs(IHttpService siraHttpService) | ||
{ | ||
if (songs == null) | ||
{ | ||
songs = new List<Song>(); | ||
int page = 0; | ||
bool limitReached = false; | ||
while (!limitReached) | ||
{ | ||
try | ||
{ | ||
IHttpResponse webResponse = await siraHttpService.GetAsync($"https://api.beatsaver.com/playlists/id/{PlaylistID}/{page}", cancellationToken: CancellationToken.None); | ||
if (webResponse.Successful) | ||
{ | ||
BeatSaverDetailEntry detailEntry = JsonConvert.DeserializeObject<BeatSaverDetailEntry>(await webResponse.ReadAsStringAsync()); | ||
if (detailEntry.maps.Count != 0) | ||
{ | ||
foreach (BeatSaverMapDetailWithOrder map in detailEntry.maps) | ||
{ | ||
songs.Add(new Song(map.map.Metadata.SongName, $"{map.map.Metadata.SongAuthorName} [{map.map.Metadata.LevelAuthorName}]", map.map.LatestVersion.CoverURL)); | ||
} | ||
} | ||
else | ||
{ | ||
limitReached = true; | ||
} | ||
page++; | ||
} | ||
else | ||
{ | ||
limitReached = true; | ||
} | ||
} | ||
catch (Exception) | ||
{ | ||
limitReached = true; | ||
} | ||
} | ||
} | ||
return songs; | ||
} | ||
} | ||
|
||
internal class BeatSaverAuthor | ||
{ | ||
[JsonProperty("name")] | ||
public string Name { get; protected set; } | ||
} | ||
|
||
internal class BeatSaverDetailEntry | ||
{ | ||
[JsonProperty("maps")] | ||
public List<BeatSaverMapDetailWithOrder> maps { get; protected set; } | ||
} | ||
|
||
internal class BeatSaverMapDetailWithOrder | ||
{ | ||
[JsonProperty("map")] | ||
public Beatmap map { get; protected set; } | ||
|
||
[JsonProperty("order")] | ||
public float order { get; protected set; } | ||
} | ||
} |
Oops, something went wrong.