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
use num_format::ToFormattedString;
use serde::Deserialize;
use crate::utils;
#[derive(Deserialize)]
pub struct UserResponse {
pub user: User,
}
#[derive(Deserialize)]
pub struct Registered {
pub unixtime: String,
}
#[derive(Deserialize)]
pub struct User {
playlists: String,
#[serde(rename = "playcount")]
play_count: String,
pub gender: String,
pub name: String,
pub subscriber: String,
pub url: String,
pub country: String,
pub registered: Registered,
#[serde(rename = "type")]
pub user_type: String,
pub age: String,
#[serde(rename = "realname")]
pub real_name: String,
}
impl User {
pub fn playlists(&self) -> i32 {
self.playlists.parse().unwrap()
}
pub fn playlists_formatted(&self) -> String {
self.playlists().to_formatted_string(&utils::get_locale())
}
pub fn play_count(&self) -> i32 {
self.play_count.parse().unwrap()
}
pub fn play_count_formatted(&self) -> String {
let locale = utils::get_locale();
self.play_count().to_formatted_string(&locale)
}
}