adding recommendations to playlist generation, trying aot
This commit is contained in:
parent
97cf1839c0
commit
3882771ddd
@ -4,6 +4,7 @@
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<LangVersion>default</LangVersion>
|
||||
<PublishAot>true</PublishAot>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -54,6 +54,7 @@ public class RunUserPlaylistStartup : FunctionsStartup
|
||||
|
||||
services.AddTransient<SpotifyNetworkProvider>()
|
||||
.AddTransient<PlaylistGenerator>()
|
||||
.AddTransient<PartTreeWalker>()
|
||||
.AddSingleton<UserRepo>();
|
||||
}
|
||||
}
|
@ -57,10 +57,10 @@ public class PlaylistGenerator
|
||||
|
||||
var combinedTracks = CollapseContextToCommonTracks(context);
|
||||
|
||||
// var recommender = new SpotifyRecommender(spotifyClient);
|
||||
// var recommendations = await recommender.GetRecommendations(dbPlaylist, combinedTracks);
|
||||
//
|
||||
// combinedTracks = combinedTracks.Concat(recommendations);
|
||||
var recommender = new SpotifyRecommender(spotifyClient);
|
||||
var recommendations = await recommender.GetRecommendations(dbPlaylist, combinedTracks);
|
||||
|
||||
combinedTracks = combinedTracks.Concat(recommendations);
|
||||
|
||||
// combinedTracks = combinedTracks.DistinctBy(x => (x.TrackName, string.Join(':', x.ArtistNames.Order())));
|
||||
// combinedTracks = combinedTracks.DistinctBy(x => x.TrackUri);
|
||||
|
@ -5,14 +5,14 @@ public static class SortExtensions
|
||||
private static Random _rng = new Random();
|
||||
|
||||
public static IOrderedEnumerable<CommonTrack> OrderByArtistAlbumTrackNumber(this IEnumerable<CommonTrack> input) =>
|
||||
input.OrderBy(x => x.AlbumArtistNames.First())
|
||||
input.OrderBy(x => x.AlbumArtistNames.FirstOrDefault())
|
||||
.ThenBy(x => x.AlbumName)
|
||||
.ThenBy(x => x.DiscNumber)
|
||||
.ThenBy(x => x.TrackNumber);
|
||||
|
||||
public static IOrderedEnumerable<CommonTrack> OrderByReleaseDate(this IEnumerable<CommonTrack> input) =>
|
||||
input.OrderByDescending(x => x.ReleaseDate)
|
||||
.ThenBy(x => x.AlbumArtistNames.First())
|
||||
.ThenBy(x => x.AlbumArtistNames.FirstOrDefault())
|
||||
.ThenBy(x => x.AlbumName)
|
||||
.ThenBy(x => x.DiscNumber)
|
||||
.ThenBy(x => x.TrackNumber);
|
||||
|
@ -1,3 +1,4 @@
|
||||
using Mixonomer.Extensions;
|
||||
using Mixonomer.Playlist;
|
||||
using Mixonomer.Playlist.Sort;
|
||||
using SpotifyAPI.Web;
|
||||
@ -23,11 +24,16 @@ public class SpotifyRecommender: IRecommend
|
||||
Limit = playlist.recommendation_sample
|
||||
};
|
||||
|
||||
foreach (var track in currentTrackList.Shuffle().Take(5))
|
||||
{
|
||||
request.SeedTracks.Add(track.TrackUri.UriToId());
|
||||
}
|
||||
|
||||
var response = await _client.Browse.GetRecommendations(request);
|
||||
|
||||
return response.Tracks.Select(x => (CommonTrack) x);
|
||||
}
|
||||
|
||||
return Enumerable.Empty<CommonTrack>();
|
||||
return [];
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user