Begin Spotify uploading
This commit is contained in:
parent
7957345057
commit
e2ff66ea50
4 changed files with 36 additions and 21 deletions
|
|
@ -1,17 +1,12 @@
|
|||
const zeit = @import("zeit");
|
||||
|
||||
pub const LastFMScrobble = struct {
|
||||
track: []const u8,
|
||||
artist: []const u8,
|
||||
album: ?[]const u8 = "",
|
||||
album: []const u8 = "",
|
||||
date: i128,
|
||||
};
|
||||
|
||||
pub const SafeLastFMScrobble = struct {
|
||||
track: []const u8,
|
||||
artist: []const u8,
|
||||
album: []const u8,
|
||||
date: u64,
|
||||
};
|
||||
|
||||
// From lastfmstats.com
|
||||
pub const LastFM = struct { username: []const u8, scrobbles: []LastFMScrobble };
|
||||
|
||||
|
|
@ -35,6 +30,14 @@ pub const SpotifyScrobble = struct {
|
|||
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() };
|
||||
}
|
||||
};
|
||||
|
||||
pub const Spotify = struct { scrobbles: []SpotifyScrobble };
|
||||
|
||||
const UploadDataTag = enum { spotify, lastfm };
|
||||
|
||||
pub const UploadData = union(UploadDataTag) { spotify: Spotify, lastfm: LastFM };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue