Allow Spotify history uploads

It works B) Just need to fix date filtering, and I should be able to start writing views for this kind of stuff. After that, editing the data in the browser.
This commit is contained in:
mitteneer 2025-02-24 19:19:37 -05:00
parent e2ff66ea50
commit 16f5b8bdba
5 changed files with 106 additions and 86 deletions

View file

@ -10,34 +10,29 @@ pub const LastFMScrobble = struct {
// From lastfmstats.com
pub const LastFM = struct { username: []const u8, scrobbles: []LastFMScrobble };
// I derived whether or not these values were optional from searching
// the respective fields for null in Vim, so there may be some fields
// that can be optional that I haven't run into yet
pub const SpotifyScrobble = struct {
ts: []u8,
username: []u8,
platform: []u8,
ts: []const u8,
username: []const u8,
platform: []const u8,
ms_played: u64,
conn_country: []u8,
ip_addr_decrypted: []u8,
user_agent_decrypted: []u8,
master_metadata_track_name: []u8,
master_metadata_artist_name: []u8,
master_metadata_album_name: []u8,
spotify_track_uri: []u8,
episode_name: []u8,
reason_start: []u8,
reason_end: []u8,
conn_country: []const u8,
ip_addr_decrypted: ?[]const u8,
user_agent_decrypted: ?[]const u8,
master_metadata_track_name: ?[]const u8,
master_metadata_album_artist_name: ?[]const u8,
master_metadata_album_album_name: ?[]const u8,
spotify_track_uri: ?[]const u8,
episode_name: ?[]const u8,
episode_show_name: ?[]const u8,
spotify_episode_uri: ?[]const u8,
reason_start: []const u8,
reason_end: ?[]const u8,
shuffle: bool,
skipped: bool,
skipped: ?bool,
offline: bool,
offline_timestamp: u64,
incognito_mode: bool,
pub fn scrobblize(self: *SpotifyScrobble) LastFMScrobble {
return LastFMScrobble{ .track = self.master_metadata_track_name, .artist = self.master_metadata_artist_name, .album = self.master_metadata_album_name, .date = try zeit.instant(.{ .source = .{ .iso8601 = self.ts } }).unixTimestamp() };
}
incognito_mode: ?bool,
};
pub const Spotify = struct { scrobbles: []SpotifyScrobble };
const UploadDataTag = enum { spotify, lastfm };
pub const UploadData = union(UploadDataTag) { spotify: Spotify, lastfm: LastFM };