pub struct LastFmEditClientImpl { /* private fields */ }Expand description
Main implementation for interacting with Last.fm’s web interface.
This implementation provides methods for browsing user libraries and editing scrobble data through web scraping. It requires a valid authenticated session to function.
Implementations§
Source§impl LastFmEditClientImpl
impl LastFmEditClientImpl
Sourcepub fn from_session(
client: Box<dyn HttpClient + Send + Sync>,
session: LastFmEditSession,
) -> Self
pub fn from_session( client: Box<dyn HttpClient + Send + Sync>, session: LastFmEditSession, ) -> Self
Create a new LastFmEditClient from an authenticated session.
This is the primary constructor for creating a client. You must obtain a valid
session first using the login function.
§Arguments
client- Any HTTP client implementation that implementsHttpClientsession- A valid authenticated session
Sourcepub fn from_session_with_rate_limit_patterns(
client: Box<dyn HttpClient + Send + Sync>,
session: LastFmEditSession,
rate_limit_patterns: Vec<String>,
) -> Self
pub fn from_session_with_rate_limit_patterns( client: Box<dyn HttpClient + Send + Sync>, session: LastFmEditSession, rate_limit_patterns: Vec<String>, ) -> Self
Create a new LastFmEditClient from an authenticated session with custom rate limit patterns.
This is useful for testing or customizing rate limit detection.
§Arguments
client- Any HTTP client implementationsession- A valid authenticated sessionrate_limit_patterns- Text patterns that indicate rate limiting in responses
Sourcepub async fn login_with_credentials(
client: Box<dyn HttpClient + Send + Sync>,
username: &str,
password: &str,
) -> Result<Self>
pub async fn login_with_credentials( client: Box<dyn HttpClient + Send + Sync>, username: &str, password: &str, ) -> Result<Self>
Create a new authenticated LastFmEditClient by logging in with username and password.
This is a convenience method that combines login and client creation into one step.
§Arguments
client- Any HTTP client implementationusername- Last.fm username or emailpassword- Last.fm password
§Returns
Returns an authenticated client on success, or LastFmError::Auth on failure.
Sourcepub fn get_session(&self) -> LastFmEditSession
pub fn get_session(&self) -> LastFmEditSession
Extract the current session state for persistence.
Sourcepub fn restore_session(&self, session: LastFmEditSession)
pub fn restore_session(&self, session: LastFmEditSession)
Restore session state from a previously saved session.
Create a new client that shares the same session and event broadcaster.
This is useful when you want multiple HTTP client instances but want them to share the same authentication state and event broadcasting system.
§Arguments
client- A new HTTP client implementation
§Returns
Returns a new client that shares the session and broadcaster with this client.
Sourcepub fn username(&self) -> String
pub fn username(&self) -> String
Get the currently authenticated username.
Returns an empty string if not logged in.
pub async fn validate_session(&self) -> bool
Sourcepub async fn delete_scrobble(
&self,
artist_name: &str,
track_name: &str,
timestamp: u64,
) -> Result<bool>
pub async fn delete_scrobble( &self, artist_name: &str, track_name: &str, timestamp: u64, ) -> Result<bool>
Delete a scrobble by its identifying information.
Sourcepub fn subscribe(&self) -> ClientEventReceiver
pub fn subscribe(&self) -> ClientEventReceiver
Subscribe to internal client events.
Sourcepub fn latest_event(&self) -> Option<ClientEvent>
pub fn latest_event(&self) -> Option<ClientEvent>
Get the latest client event without subscribing to future events.
Sourcepub async fn get_recent_scrobbles(&self, page: u32) -> Result<Vec<Track>>
pub async fn get_recent_scrobbles(&self, page: u32) -> Result<Vec<Track>>
Fetch recent scrobbles from the user’s listening history This gives us real scrobble data with timestamps for editing
Sourcepub async fn get_recent_tracks_page(&self, page: u32) -> Result<TrackPage>
pub async fn get_recent_tracks_page(&self, page: u32) -> Result<TrackPage>
Get a page of tracks from the user’s recent listening history.
Sourcepub async fn find_recent_scrobble_for_track(
&self,
track_name: &str,
artist_name: &str,
max_pages: u32,
) -> Result<Option<Track>>
pub async fn find_recent_scrobble_for_track( &self, track_name: &str, artist_name: &str, max_pages: u32, ) -> Result<Option<Track>>
Find the most recent scrobble for a specific track This searches through recent listening history to find real scrobble data
pub async fn edit_scrobble(&self, edit: &ScrobbleEdit) -> Result<EditResponse>
Sourcepub async fn edit_scrobble_single(
&self,
exact_edit: &ExactScrobbleEdit,
max_retries: u32,
) -> Result<EditResponse>
pub async fn edit_scrobble_single( &self, exact_edit: &ExactScrobbleEdit, max_retries: u32, ) -> Result<EditResponse>
Edit a single scrobble with retry logic, returning a single-result EditResponse.
This method takes a fully-specified ExactScrobbleEdit and performs a single
edit operation. Unlike edit_scrobble, this method does not perform enrichment
or multiple edits - it edits exactly one scrobble instance.
§Arguments
exact_edit- A fully-specified edit with all required fields populatedmax_retries- Maximum number of retry attempts for rate limiting
Sourcepub async fn load_edit_form_values_internal(
&self,
track_name: &str,
artist_name: &str,
) -> Result<Vec<ExactScrobbleEdit>>
pub async fn load_edit_form_values_internal( &self, track_name: &str, artist_name: &str, ) -> Result<Vec<ExactScrobbleEdit>>
Load prepopulated form values for editing a specific track This extracts scrobble data directly from the track page forms
pub async fn get_artist_tracks_page( &self, artist: &str, page: u32, ) -> Result<TrackPage>
Sourcepub fn extract_tracks_from_document(
&self,
document: &Html,
artist: &str,
album: Option<&str>,
) -> Result<Vec<Track>>
pub fn extract_tracks_from_document( &self, document: &Html, artist: &str, album: Option<&str>, ) -> Result<Vec<Track>>
Extract tracks from HTML document (delegates to parser)
Sourcepub fn parse_tracks_page(
&self,
document: &Html,
page_number: u32,
artist: &str,
album: Option<&str>,
) -> Result<TrackPage>
pub fn parse_tracks_page( &self, document: &Html, page_number: u32, artist: &str, album: Option<&str>, ) -> Result<TrackPage>
Parse tracks page (delegates to parser)
Sourcepub fn parse_recent_scrobbles(&self, document: &Html) -> Result<Vec<Track>>
pub fn parse_recent_scrobbles(&self, document: &Html) -> Result<Vec<Track>>
Parse recent scrobbles from HTML document (for testing)
Sourcepub async fn get(&self, url: &str) -> Result<Response>
pub async fn get(&self, url: &str) -> Result<Response>
Make an HTTP GET request with authentication and retry logic
pub async fn get_artist_albums_page( &self, artist: &str, page: u32, ) -> Result<AlbumPage>
Trait Implementations§
Source§impl Clone for LastFmEditClientImpl
impl Clone for LastFmEditClientImpl
Source§fn clone(&self) -> LastFmEditClientImpl
fn clone(&self) -> LastFmEditClientImpl
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more