Add LastFM scrobble type
In preparation for importing via LastFM api
This commit is contained in:
parent
c42b8d24dd
commit
4991bac9a4
2 changed files with 33 additions and 2 deletions
|
|
@ -37,7 +37,7 @@ pub fn post(request: *jetzig.Request) !jetzig.View {
|
||||||
|
|
||||||
switch (source) {
|
switch (source) {
|
||||||
0 => {
|
0 => {
|
||||||
const content: Data.LastFM = try std.json.parseFromSliceLeaky(Data.LastFM, request.allocator, file.content, .{});
|
const content: Data.LastFMStats = try std.json.parseFromSliceLeaky(Data.LastFMStats, request.allocator, file.content, .{});
|
||||||
const before_limiting_date = if (before_limiter and params.get("b") != null) (try zeit.instant(.{ .source = .{ .iso8601 = params.get("b").?.string.value } })).unixTimestamp() * 1000 else 0;
|
const before_limiting_date = if (before_limiter and params.get("b") != null) (try zeit.instant(.{ .source = .{ .iso8601 = params.get("b").?.string.value } })).unixTimestamp() * 1000 else 0;
|
||||||
const after_limiting_date = if (after_limiter and params.get("a") != null) (try zeit.instant(.{ .source = .{ .iso8601 = params.get("a").?.string.value } })).unixTimestamp() * 1000 else 9_223_372_036_854_775_807;
|
const after_limiting_date = if (after_limiter and params.get("a") != null) (try zeit.instant(.{ .source = .{ .iso8601 = params.get("a").?.string.value } })).unixTimestamp() * 1000 else 9_223_372_036_854_775_807;
|
||||||
appends: for (content.scrobbles) |scrobble| {
|
appends: for (content.scrobbles) |scrobble| {
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ pub const Scrobble = struct {
|
||||||
};
|
};
|
||||||
|
|
||||||
// From lastfmstats.com
|
// From lastfmstats.com
|
||||||
pub const LastFM = struct { username: []const u8, scrobbles: []ImportedScrobble };
|
pub const LastFMStats = struct { username: []const u8, scrobbles: []ImportedScrobble };
|
||||||
|
|
||||||
// I derived whether or not these values were optional from searching
|
// I derived whether or not these values were optional from searching
|
||||||
// the respective fields for null in Vim, so there may be some fields
|
// the respective fields for null in Vim, so there may be some fields
|
||||||
|
|
@ -43,6 +43,37 @@ pub const SpotifyScrobble = struct {
|
||||||
//incognito_mode: ?bool,
|
//incognito_mode: ?bool,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub const LastFMWeb = struct {
|
||||||
|
track: []struct {
|
||||||
|
artist: LastFMWebHyperlinkData,
|
||||||
|
album: LastFMWebHyperlinkData,
|
||||||
|
name: []const u8,
|
||||||
|
mbid: []const u8,
|
||||||
|
image: struct {
|
||||||
|
size: []const u8,
|
||||||
|
@"#text": []const u8,
|
||||||
|
},
|
||||||
|
date: struct {
|
||||||
|
uts: []const u8,
|
||||||
|
@"#text": []const u8,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
@"@attr": LastFMWebAttr,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub const LastFMWebAttr = struct {
|
||||||
|
perPage: u32,
|
||||||
|
totalPages: u32,
|
||||||
|
page: u32,
|
||||||
|
user: []const u8,
|
||||||
|
total: u32,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub const LastFMWebHyperlinkData = struct {
|
||||||
|
mbid: []const u8,
|
||||||
|
@"#text": []const u8,
|
||||||
|
};
|
||||||
|
|
||||||
pub const Rule = struct {
|
pub const Rule = struct {
|
||||||
name: []const u8,
|
name: []const u8,
|
||||||
cond_req: enum { any, all },
|
cond_req: enum { any, all },
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue