aboutsummaryrefslogtreecommitdiff
path: root/lib/listenbrainz.atd
blob: ede37f5e52d97db9fe0f6833e43afaaa72ec569c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
type mbid = string <ocaml valid="Listenbrainz_util.validate_mbid">
type isrc = string <ocaml valid="Listenbrainz_util.validate_isrc">
type unixtime = float <json repr="int">
type tm = unixtime wrap <ocaml module="Unix" t="Unix.tm" wrap="Unix.gmtime" unwrap="Listenbrainz_util.tm_unwrap">

type additional_info = {
  ?artist_mbids : mbid list option;
  ?release_group_mbid : mbid option;
  ?release_mbid : mbid option;
  ?recording_mbid : mbid option;
  ?track_mbid : mbid option;
  ?work_mbids : mbid list option;
  ?tracknumber : int option;
  ?isrc : isrc option;
  ?spotify_id : string option;
  ?tags : string list option;
  ?listening_from : string option;
}

type track_metadata = {
  artist_name : string;
  track_name : string;
  ?listened_at : int option;
  ?additional_info : additional_info option;
  ?release_name : string option;
}

type listen_type = [
    Single <json name="single">
  | Playing_now <json name="playing_now">
  | Import <json name="import">
]

type similar_user = {
  user_name : string;
  similarity : float;
}

type payload_listen = {
  ?listened_at : tm option;
  track_metadata : track_metadata;
}

type payload_listens = {
  count : int;
  user_id : mbid;
  listens : payload_listen list;
}

type payload_listen_count = {
  count : int;
}

type post_submit_listens = {
  listen_type : listen_type;
  payload : payload_listen list;
} <ocaml valid="Listenbrainz_util.validate_post_submit_listens">

type get_validate_token = {
  code : int;
  message : string;
  valid : bool;
  ?user: string option;
} <ocaml valid="Listenbrainz_util.validate_get_validate_token">

type post_delete_listen = {
  listened_at : tm;
  recording_msid : mbid;
}

type get_user_similar_users = similar_user list

type get_user_listen_count = {
  payload : payload_listen_count;
}

type get_user_playing_now = {
  payload : payload_listens;
} <ocaml valid="Listenbrainz_util.validate_get_user_playing_now">

type get_user_similar_to = similar_user

type get_user_listens = {
  payload : payload_listens
} <ocaml valid="Listenbrainz_util.validate_get_user_listens">

type get_latest_import = {
  musicbrainz_id : mbid;
  latest_import : tm;
}

type post_latest_import = {
  ts : tm;
}