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
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
//! Collection of serde-based data types for Lastfm API
//!
//! Source: https://www.last.fm/api
//!
//! ## Installation
//!
//! ## Example
//!
//! ```no-run
//! use lastfm_parse_rs::from_json_str;
//! use lastfm_parse_rs::structs::artist::GetInfo;
//!
//! let get_info = GetInfo::request(base_url, api_key, "iamthemorning", None, Some(1), None, None);
//! let url: Url = Into::into(get_info);
//! // Make an http request
//! let data: GetInfo = from_json_str(&raw_json_response).unwrap();
//! ```
//!
//! See examples/artist.rs for full listing.
//!
//! ## Tests
//!
//! To run deserialization tests:
//!
//! 1. Set your lastfm API key to \tests\common\mod.rs `LASTFM_API_KEY`.
//!
//! 2. Run `cargo test`. Use  `-- --nocapture` to dump raw json and deserialized objects to stdout.
//!
//! To run examples:
//!
//! 1. Set your lastfm API key to examples/*.rs
//!
//! 2. Run `cargo run --example <example name>`


extern crate serde;
extern crate serde_json;
extern crate url;
extern crate md5;

#[macro_use]
extern crate serde_derive;

// ----------------------------------------------------------------

/// Tools for defining common Lastfm data structures and corresponding requests
#[macro_use]
pub mod lastfm_type;
/// Tools for constructing API requests
#[macro_use]
pub mod request;

/// Serde-based API data structures
pub mod structs;
/// Common error type for serde/API fails
pub mod error;

// ----------------------------------------------------------------

pub use lastfm_type::{LastfmType, from_json_str, from_json_slice};
pub use request::{Request, RequestParams};
pub use error::Result;

// ----------------------------------------------------------------

/// Album data structures
pub mod album {
    pub use structs::album::Params;

    pub use structs::album::AddTags;
    pub use structs::album::GetInfo;
    pub use structs::album::GetTags;
    pub use structs::album::GetTopTags;
    pub use structs::album::RemoveTag;
    pub use structs::album::Search;
}

/// Artist data structures
pub mod artist {
    pub use structs::artist::Params;

    pub use structs::artist::AddTags;
    pub use structs::artist::GetCorrections;
    pub use structs::artist::GetInfo;
    pub use structs::artist::GetSimilar;
    pub use structs::artist::GetTags;
    pub use structs::artist::GetTopAlbums;
    pub use structs::artist::GetTopTags;
    pub use structs::artist::GetTopTracks;
    pub use structs::artist::RemoveTag;
    pub use structs::artist::Search;
}

/// Auth data structures
pub mod auth {
    pub use structs::auth::Params;

    pub use structs::auth::GetMobileSession;
    pub use structs::auth::GetSession;
    pub use structs::auth::GetToken;
}

/// Chart data structures
pub mod chart {
    pub use structs::chart::Params;

    pub use structs::chart::GetTopArtists;
    pub use structs::chart::GetTopTags;
    pub use structs::chart::GetTopTracks;
}

/// Geo data structures
pub mod geo {
    pub use structs::geo::Params;

    pub use structs::geo::GetTopArtists;
    pub use structs::geo::GetTopTracks;
}

/// Library data structures
pub mod library {
    pub use structs::library::Params;

    pub use structs::library::GetArtists;
}

/// Tag data structures
pub mod tag {
    pub use structs::tag::Params;

    pub use structs::tag::GetInfo;
    pub use structs::tag::GetSimilar;
    pub use structs::tag::GetTopAlbums;
    pub use structs::tag::GetTopArtists;
    pub use structs::tag::GetTopTags;
    pub use structs::tag::GetTopTracks;
    pub use structs::tag::GetWeeklyChartList;
}

/// Track data structures
pub mod track {
    pub use structs::track::Params;

    pub use structs::track::{ScrobbleTrack, ScrobbleBatch};

    pub use structs::track::AddTags;
    pub use structs::track::GetCorrections;
    pub use structs::track::GetInfo;
    pub use structs::track::GetSimilar;
    pub use structs::track::GetTags;
    pub use structs::track::GetTopTags;
    pub use structs::track::Love;
    pub use structs::track::RemoveTag;
    pub use structs::track::Scrobble;
    pub use structs::track::Search;
    pub use structs::track::Unlove;
    pub use structs::track::UpdateNowPlaying;
}

/// User data structures
pub mod user {
    pub use structs::user::Params;

    pub use structs::user::GetFriends;
    pub use structs::user::GetInfo;
    pub use structs::user::GetLovedTracks;
    pub use structs::user::GetTaggings;
    pub use structs::user::GetRecentTracks;
    pub use structs::user::GetTopAlbums;
    pub use structs::user::GetTopArtists;
    pub use structs::user::GetTopTags;
    pub use structs::user::GetTopTracks;
    pub use structs::user::GetWeeklyAlbumChart;
    pub use structs::user::GetWeeklyArtistChart;
    pub use structs::user::GetWeeklyTrackChart;
    pub use structs::user::GetWeeklyChartList;
}