Skip to content

Commit

Permalink
[server] [ingest] implement sort artists
Browse files Browse the repository at this point in the history
  • Loading branch information
yellowsink committed Jun 2, 2024
1 parent 62fabc4 commit 6ed51cc
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 14 deletions.
2 changes: 1 addition & 1 deletion UwuRadio.Server/Services/PickerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private static void FisherYatesShuffle<T>(IList<T> arr)
// https://engineering.atspotify.com/2014/02/how-to-shuffle-songs
// https://codegolf.stackexchange.com/questions/198094
private static IEnumerable<Song> SpotifyShuffle(IEnumerable<Song> arr) => arr
.GroupBy(song => song.Submitter + song.Artist)
.GroupBy(song => song.SortOrArtist.ToLowerInvariant())
.SelectMany(
group =>
{
Expand Down
11 changes: 7 additions & 4 deletions UwuRadio.Server/Song.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
namespace UwuRadio.Server;

public record Song(string Name, string Artist, string StreamUrl, string? ArtUrl, string? Album, string Submitter)
public record Song(string Name, string Artist, string? SortArtist, string StreamUrl, string? ArtUrl, string? Album, string Submitter)
{
private string? _Id;
public string Id => _Id ??= Helpers.ComputeSongId(this);
private string? _id;
public string Id => _id ??= Helpers.ComputeSongId(this);

public string SortOrArtist => SortArtist ?? Artist;
}

public record TransitSong(string Name, string Artist, string? DlUrl, string? SourceUrl, string? ArtUrl, string? Album, string Submitter)
public record TransitSong(string Name, string Artist, string? SortArtist, string? DlUrl, string? SourceUrl, string? ArtUrl, string? Album, string Submitter)
{
public TransitSong(Song song) : this(song.Name,
song.Artist,
song.SortArtist,
Constants.C.ServerDlUrl + song.Id,
song.StreamUrl,
song.ArtUrl,
Expand Down
5 changes: 3 additions & 2 deletions docs/STORAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ It should have the following structure:
- `Quotes`: string[] - a list of quotes you want to show while your tracks play
- `Songs`: object[] - the songs to submit
* `Name`: string - the name of the song
* `Artist`: string - the artist
* `Artist`: string - the artist displayed to the user
* `SortArtist`: optional string - an alternate artist field not displayed but used for shuffling and sorting purposes
* `StreamUrl`: string - a URL where the song can be found (youtube, soundcloud, bandcamp, etc.)
* `ArtUrl`: optional string - a URL to the album art (coverartarchive, etc.)
* `Album`: optional string - the album the song is off

If a non-optional value is missing or whitespace from the ingest or a song, the server fails.
If a non-optional value is missing or whitespace from the ingest or a song, the server fails.
3 changes: 2 additions & 1 deletion docs/TRANSPORT.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Object:

- string name
- string artist
- string? sortArtist
- string? dlUrl
- string? sourceUrl
- string? artUrl
Expand Down Expand Up @@ -55,4 +56,4 @@ Client Methods:
|----------------|-----------------------------------------------------------------------------------------|------------------------------------|
| BroadcastNext | Receive the data of the next song for pre-loading. Enables seamless playback | [Song, Timestamp] |
| ReceiveState | Receive the data of the current current state. Used for joining part-way through a song | [Song, Timestamp, Song, Timestamp] |
| ReceiveSeekPos | Receive the time the current song started. Used for resyncing | Timestamp |
| ReceiveSeekPos | Receive the time the current song started. Used for resyncing | Timestamp |
12 changes: 6 additions & 6 deletions ingest/ioj4.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
{
"Name": "Strangers (Hundaes Edit)",
"Artist": "Seven Lions, Myon & Shane 54, Tove Lo",
"SortArtist": "hundaes",
"StreamUrl": "https://soundcloud.com/hundaes/seven-lions-myon-and-shane-54-tove-lo-strangers-hundaes-edit",
"ArtUrl": "https://i1.sndcdn.com/artworks-9IPMXDJsRaNWSX1m-tcBY5A-t500x500.jpg"
},
Expand All @@ -18,15 +19,10 @@
{
"Name": "We Are Never Getting Back Together (Hundaes Edit)",
"Artist": "Taylor Swift",
"SortArtist": "hundaes",
"StreamUrl": "https://soundcloud.com/hundaes/taylor-swift-we-are-never-getting-back-together-hundaes-edit",
"ArtUrl": "https://i1.sndcdn.com/artworks-TBXyWTGvZQSlM2vs-mCNJ7g-t500x500.jpg"
},
{
"Name": "Strangers (Hundaes Edit)",
"Artist": "Seven Lions, Myon and Shane 54 & Tove Lo",
"StreamUrl": "https://soundcloud.com/hundaes/seven-lions-myon-and-shane-54-tove-lo-strangers-hundaes-edit",
"ArtUrl": "https://i1.sndcdn.com/artworks-9IPMXDJsRaNWSX1m-tcBY5A-t500x500.jpg"
},
{
"Name": "EON BREAK (4AM Remix by MANIFOLD HOME)",
"Artist": "Virtual Self",
Expand Down Expand Up @@ -124,6 +120,7 @@
{
"Name": "claws (Hundaes 'scared in my dreams' Edit)",
"Artist": "Charli XCX",
"SortArtist": "hundaes",
"StreamUrl": "https://soundcloud.com/hundaes/charli-xcx-claws-hundaes-edit-2",
"ArtUrl": "https://i1.sndcdn.com/artworks-enmZcUGGpc266Vcb-z3GuHw-t500x500.jpg"
},
Expand All @@ -148,12 +145,14 @@
{
"Name": "Hard Times (Hundaes Edit)",
"Artist": "Duskus",
"SortArtist": "hundaes",
"StreamUrl": "https://soundcloud.com/hundaes/duskus-hard-times-hundaes-edit",
"ArtUrl": "https://i1.sndcdn.com/artworks-Dk81FUMCMhnIyE1t-mLRyEg-t500x500.jpg"
},
{
"Name": "Something Comforting ft. Lil B (Hundaes Edit)",
"Artist": "Porter Robinson",
"SortArtist": "hundaes",
"StreamUrl": "https://soundcloud.com/hundaes/porter-robinson-something-comforting-ft-lil-b-hundaes-edit",
"ArtUrl": "https://i1.sndcdn.com/artworks-vCMgKd6y9Up0eUL1-Lccf8Q-t500x500.jpg"
},
Expand Down Expand Up @@ -208,6 +207,7 @@
{
"Name": "class of 2021",
"Artist": "dobi but its a second account",
"SortArtist": "dobi",
"StreamUrl": "https://soundcloud.com/dobitwo/class-of-2021",
"ArtUrl": "https://i1.sndcdn.com/artworks-nOAjfSSWXZbL0fZh-T3iNkw-t500x500.jpg"
},
Expand Down
Loading

0 comments on commit 6ed51cc

Please sign in to comment.