pub struct LovedTracksRequestBuilder { /* private fields */ }Expand description
Builder for loved tracks requests
Implementations§
Source§impl LovedTracksRequestBuilder
impl LovedTracksRequestBuilder
Sourcepub const fn limit(self, limit: u32) -> Self
pub const fn limit(self, limit: u32) -> Self
Set the maximum number of tracks to fetch
§Arguments
limit- Maximum number of tracks to fetch. The Last.fm API supports fetching up to thousands of tracks. If you need all tracks, useunlimited()instead.
Sourcepub async fn fetch(self) -> Result<TrackList<LovedTrack>>
pub async fn fetch(self) -> Result<TrackList<LovedTrack>>
Fetch the tracks
§Errors
Returns an error if the HTTP request fails or the response cannot be parsed.
Sourcepub async fn fetch_and_save(
self,
format: FileFormat,
filename_prefix: &str,
) -> Result<String>
pub async fn fetch_and_save( self, format: FileFormat, filename_prefix: &str, ) -> Result<String>
Fetch tracks and save them to a file
§Arguments
format- The file format to save the tracks infilename_prefix- Prefix for the generated filename
§Errors
Returns an error if the HTTP request fails, response cannot be parsed, or file cannot be saved.
§Returns
Result<String>- The filename of the saved file
Sourcepub async fn fetch_and_update(self, file_path: &str) -> Result<usize>
pub async fn fetch_and_update(self, file_path: &str) -> Result<usize>
Fetch only tracks newer than the most recent entry in an existing JSON file and prepend them to it. If the file does not exist, all tracks are fetched and the file is created.
Unlike recent_tracks, the loved tracks API does not support a from timestamp filter,
so all tracks are fetched and those already present (by timestamp) are filtered out.
§Arguments
file_path- Path to the JSON file to update (or create)
§Errors
Returns an error if the HTTP request fails, the response cannot be parsed, or the file cannot be read or written.
§Returns
Result<usize>- Number of new tracks prepended
Sourcepub async fn analyze(self, threshold: usize) -> Result<TrackStats>
pub async fn analyze(self, threshold: usize) -> Result<TrackStats>
Analyze tracks and return statistics
§Arguments
threshold- Minimum play count threshold. Tracks with fewer plays than this value will be counted separately intracks_below_threshold. For example, use 5 to identify tracks played less than 5 times.
§Errors
Returns an error if the HTTP request fails or the response cannot be parsed.
§Returns
Result<crate::analytics::TrackStats>- Analysis results including play counts, most played tracks, etc.
Sourcepub async fn analyze_and_print(self, threshold: usize) -> Result<()>
pub async fn analyze_and_print(self, threshold: usize) -> Result<()>
Analyze tracks and print statistics
§Arguments
threshold- Minimum play count threshold. Tracks with fewer plays than this value will be counted separately. For example, use 5 to identify tracks played less than 5 times.
§Errors
Returns an error if the HTTP request fails or the response cannot be parsed.