Spotify History storing from CLI and inclusion in the front end #50
@ -121,8 +121,8 @@ namespace Selector.CLI.Extensions
|
||||
services.AddTransient<IScrobbleRepository, ScrobbleRepository>()
|
||||
.AddTransient<ISpotifyListenRepository, SpotifyListenRepository>();
|
||||
|
||||
//services.AddTransient<IListenRepository, MetaListenRepository>();
|
||||
services.AddTransient<IListenRepository, SpotifyListenRepository>();
|
||||
services.AddTransient<IListenRepository, MetaListenRepository>();
|
||||
//services.AddTransient<IListenRepository, SpotifyListenRepository>();
|
||||
|
||||
services.AddTransient<IScrobbleMappingRepository, ScrobbleMappingRepository>();
|
||||
|
||||
|
@ -1,8 +1,6 @@
|
||||
using System;
|
||||
using System.Text.Json;
|
||||
using Selector.Model;
|
||||
using System.Text.Json;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Diagnostics.Metrics;
|
||||
using Selector.Model;
|
||||
|
||||
namespace Selector.Data;
|
||||
|
||||
@ -60,14 +58,16 @@ public class HistoryPersister
|
||||
{
|
||||
if (Config.InitialClear)
|
||||
{
|
||||
Db.SpotifyListen.RemoveRange(Db.SpotifyListen.Where(x => x.User.UserName == Config.Username));
|
||||
var latestTime = input.OrderBy(x => x.ts).Last().ts;
|
||||
var time = DateTime.Parse(latestTime).ToUniversalTime();
|
||||
Db.SpotifyListen.RemoveRange(Db.SpotifyListen.Where(x => x.User.UserName == Config.Username && x.Timestamp <= time));
|
||||
}
|
||||
|
||||
var user = Db.Users.Single(u => u.UserName == Config.Username);
|
||||
|
||||
var counter = 0;
|
||||
|
||||
var filtered = input.Where(x => x.ms_played > 20000)
|
||||
var filtered = input.Where(x => x.ms_played > 30000)
|
||||
.DistinctBy(x => (x.offline_timestamp, x.ts, x.spotify_track_uri))
|
||||
.ToArray();
|
||||
|
||||
|
@ -4,11 +4,6 @@ using System.Linq;
|
||||
|
||||
namespace Selector.Model;
|
||||
|
||||
public enum PreferenceMode
|
||||
{
|
||||
Greedy, LastFm, Spotify
|
||||
}
|
||||
|
||||
public class MetaListenRepository: IListenRepository
|
||||
{
|
||||
private readonly IScrobbleRepository scrobbleRepository;
|
||||
@ -27,10 +22,13 @@ public class MetaListenRepository: IListenRepository
|
||||
string albumName = null,
|
||||
string artistName = null,
|
||||
DateTime? from = null,
|
||||
DateTime? to = null)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
DateTime? to = null) => GetAll(userId: userId,
|
||||
username: username,
|
||||
trackName: trackName,
|
||||
albumName: albumName,
|
||||
artistName: artistName,
|
||||
from: from,
|
||||
to:to).Count();
|
||||
|
||||
public IEnumerable<IListen> GetAll(
|
||||
string includes = null,
|
||||
@ -62,14 +60,12 @@ public class MetaListenRepository: IListenRepository
|
||||
albumName: albumName,
|
||||
artistName: artistName,
|
||||
from: from,
|
||||
to: to)
|
||||
to: scrobbles.FirstOrDefault()?.Timestamp)
|
||||
.OrderBy(x => x.Timestamp)
|
||||
.ToArray();
|
||||
|
||||
var scrobbleIter = scrobbles.GetEnumerator();
|
||||
var spotIter = spotListens.GetEnumerator();
|
||||
|
||||
return scrobbles;
|
||||
return spotListens.Concat(scrobbles);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -67,8 +67,8 @@ namespace Selector.Web
|
||||
services.AddTransient<IScrobbleRepository, ScrobbleRepository>()
|
||||
.AddTransient<ISpotifyListenRepository, SpotifyListenRepository>();
|
||||
|
||||
//services.AddTransient<IListenRepository, MetaListenRepository>();
|
||||
services.AddTransient<IListenRepository, SpotifyListenRepository>();
|
||||
services.AddTransient<IListenRepository, MetaListenRepository>();
|
||||
//services.AddTransient<IListenRepository, SpotifyListenRepository>();
|
||||
|
||||
services.AddIdentity<ApplicationUser, IdentityRole>()
|
||||
.AddEntityFrameworkStores<ApplicationDbContext>()
|
||||
|
Loading…
Reference in New Issue
Block a user