Work on add artist action in rules

Really close to having it work, but there seems to be an error when uploading files, which causes particularly annoying problems on WSL when testing, so I'm commiting and trying on my desktop.
This commit is contained in:
mitteneer 2025-04-23 19:32:32 -04:00
parent e9c72041a5
commit 0631ded115
7 changed files with 300 additions and 145 deletions

View file

@ -1,51 +1,59 @@
pub const LastFMScrobble = struct {
pub const ImportedScrobble = struct {
track: []const u8,
artist: []const u8,
album: []const u8 = "",
date: i128,
};
pub const Scrobble = struct {
track: []const u8,
artists_track: []const []const u8,
album: []const u8 = "",
artists_album: []const []const u8,
date: i128,
};
// From lastfmstats.com
pub const LastFM = struct { username: []const u8, scrobbles: []LastFMScrobble };
pub const LastFM = struct { username: []const u8, scrobbles: []ImportedScrobble };
// 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: []const u8,
username: []const u8,
platform: []const u8,
//username: []const u8,
//platform: []const u8,
ms_played: u64,
conn_country: []const u8,
ip_addr_decrypted: ?[]const u8,
user_agent_decrypted: ?[]const 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,
//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,
//shuffle: bool,
skipped: ?bool,
offline: bool,
//offline: bool,
offline_timestamp: u64,
incognito_mode: ?bool,
//incognito_mode: ?bool,
};
pub const Rule = struct {
name: []const u8,
cond_req: enum { any, all },
conditionals: []struct {
match_on: ScrobbleFields,
match_on: enum { artist, album, track },
match_cond: enum { is, contains },
match_txt: []const u8,
},
actions: []struct {
action: enum { replace, add },
action_on: ScrobbleFields,
action_on: enum { artists_album, album, artists_track, track },
action_txt: []const u8,
},
};
@ -53,9 +61,3 @@ pub const Rule = struct {
pub const Rules = struct {
rules: []const Rule,
};
pub const ScrobbleFields = enum {
artist,
album,
track,
};