zuletzt/src/types.zig
mitteneer 5697f95355 Fix LastFM uploading errors
Not sure which of these actually made it work, will probably work backwards at some point to reverse engineer it
2025-05-15 20:23:53 -04:00

126 lines
3.3 KiB
Zig

pub const ImportedScrobble = struct {
track: []const u8,
artist: []const u8,
album: []const u8 = "",
date: i64,
};
pub const Scrobble = struct {
track: []const u8,
artists_track: []const []const u8,
album: []const u8 = "",
artists_album: []const []const u8,
date: i64,
};
// From lastfmstats.com
pub const LastFMStats = 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,
ms_played: u64,
//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,
//offline: bool,
offline_timestamp: u64,
//incognito_mode: ?bool,
};
pub const LastFMWeb = struct {
recenttracks: struct {
track: []struct {
artist: LastFMWebHyperlinkData,
album: ?LastFMWebHyperlinkData = null,
name: []const u8,
mbid: ?[]const u8 = null,
image: ?[]struct {
size: []const u8,
@"#text": []const u8,
} = null,
date: struct {
uts: []const u8,
@"#text": []const u8,
},
@"@attr": ?struct {
nowplaying: ?[]const u8 = null,
} = null,
url: ?[]const u8 = null,
},
@"@attr": LastFMWebAttr,
},
};
pub const LastFMWebAttr = struct {
perPage: ?[]const u8 = null,
totalPages: []const u8,
page: ?[]const u8 = null,
user: ?[]const u8 = null,
total: ?[]const u8 = null,
};
pub const LastFMWebHyperlinkData = struct {
mbid: ?[]const u8 = null,
@"#text": ?[]const u8 = null,
};
pub const Rule = struct {
name: []const u8,
cond_req: enum { any, all },
conditionals: []struct {
match_on: enum { artist, album, track },
match_cond: enum { is, contains },
match_txt: []const u8,
},
actions: []struct {
action: enum { replace, add },
action_on: enum { artists_album, album, artists_track, track },
action_txt: []const u8,
},
};
pub const Rules = struct {
rules: []const Rule,
};
// Can't import types in .zmpl files, so defining this here
// doesn't really do much (except maybe in the .zig file for views?)
//pub const HeaderTypes = []enum {
// song,
// album,
// artist,
// artistlist,
// scrobbles,
// date,
//};
//
pub const TableRow = struct {
song: ?HyperlinkData = null,
album: ?HyperlinkData = null,
artist: ?HyperlinkData = null,
artistlist: ?[]HyperlinkData = null,
scrobbles: ?i64 = null,
date: ?[]const u8 = null,
};
pub const HyperlinkData = struct {
name: []const u8,
id: i32,
};