Post your last.fm now playing to your Bluesky followers
1use serde::{Deserialize, Serialize};
2
3#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
4#[serde(rename_all = "camelCase")]
5pub struct Root {
6 pub recenttracks: Recenttracks,
7}
8
9#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
10#[serde(rename_all = "camelCase")]
11pub struct Recenttracks {
12 pub track: Vec<Track>,
13}
14
15#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
16#[serde(rename_all = "camelCase")]
17pub struct Track {
18 pub artist: Artist,
19 pub album: Album,
20 pub name: String,
21 pub image: Vec<Image>,
22 #[serde(rename = "@attr")]
23 pub attr: Option<Attr>,
24 pub url: String,
25}
26
27#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
28#[serde(rename_all = "camelCase")]
29pub struct Artist {
30 pub mbid: String,
31 #[serde(rename = "#text")]
32 pub text: String,
33}
34
35#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
36#[serde(rename_all = "camelCase")]
37pub struct Album {
38 pub mbid: String,
39 #[serde(rename = "#text")]
40 pub text: String,
41}
42
43#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
44#[serde(rename_all = "camelCase")]
45pub struct Attr {
46 pub nowplaying: String,
47}
48
49#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
50#[serde(rename_all = "camelCase")]
51pub struct Image {
52 pub size: String,
53 #[serde(rename = "#text")]
54 pub text: String,
55}
56
57pub struct NowPlaying {
58 pub artist: String,
59 pub title: String,
60 pub image: String,
61 pub url: String,
62}
63
64impl std::fmt::Display for NowPlaying {
65 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
66 write!(f, "{}, {}", self.title, self.artist)
67 }
68}