···55use crate::{
66 auth::{AuthMethod, Authenticator, GenericSession},
77 error::OnyxError,
88- record::{Artist, Play},
88+ record::{Artist, Play, PlayView, Status},
99 scrobble::Scrobbler,
1010 status::StatusManager,
1111};
···171171 AudioScrobbler,
172172}
173173174174+#[allow(clippy::large_enum_variant)]
174175#[derive(Subcommand, Debug)]
175176enum StatusCommands {
176177 /// Display user playing status
···186187 /// Display all status fields
187188 #[arg(short, long, action)]
188189 full: bool,
190190+ },
191191+192192+ /// Set user playing status
193193+ Set {
194194+ /// The name of the track
195195+ track_name: String,
196196+197197+ /// The MusicBrainz ID of the track
198198+ #[arg(long)]
199199+ track_mb_id: Option<String>,
200200+201201+ /// The MusicBrainz ID of the recording
202202+ #[arg(long)]
203203+ recording_mb_id: Option<String>,
204204+205205+ /// The track duration in seconds
206206+ #[arg(short, long)]
207207+ duration: Option<i64>,
208208+209209+ /// A comma-separated list of artist name
210210+ #[arg(short, long)]
211211+ artist_names: Option<String>,
212212+213213+ /// A comma-separated list of artist MusicBrainz IDs
214214+ #[arg(long)]
215215+ artist_mb_ids: Option<String>,
216216+217217+ /// The name of the release/album
218218+ #[arg(short, long)]
219219+ release_name: Option<String>,
220220+221221+ /// The MusicBrainz ID of the release/album
222222+ #[arg(long)]
223223+ release_mb_id: Option<String>,
224224+225225+ /// The URL associated with the track
226226+ #[arg(short, long)]
227227+ origin_url: Option<String>,
228228+229229+ /// The ISRC accosiated with the recording
230230+ #[arg(long)]
231231+ isrc: Option<String>,
232232+233233+ /// Time the track was played (RFC 3339 format)
234234+ #[arg(short, long)]
235235+ played_time: Option<chrono::DateTime<chrono::FixedOffset>>,
236236+237237+ /// Time of status creation, defaults to current time
238238+ #[arg(short, long)]
239239+ time: Option<chrono::DateTime<chrono::FixedOffset>>,
240240+241241+ /// Time of status expiry, defaults to start time + 10 minutes
242242+ #[arg(short, long)]
243243+ expiry: Option<chrono::DateTime<chrono::FixedOffset>>,
189244 },
190245191246 /// Clear current playing status
···407462 let status_man = StatusManager::new(&ident);
408463 let status = status_man.get_status().await?;
409464 status.display(raw, full);
465465+ }
466466+ StatusCommands::Set {
467467+ track_name,
468468+ track_mb_id,
469469+ recording_mb_id,
470470+ duration,
471471+ artist_names,
472472+ artist_mb_ids,
473473+ release_name,
474474+ release_mb_id,
475475+ origin_url,
476476+ isrc,
477477+ played_time,
478478+ time,
479479+ expiry,
480480+ } => {
481481+ let artists = parse_artist_list(artist_names, artist_mb_ids)?.unwrap_or(Vec::new());
482482+483483+ let play = PlayView {
484484+ track_name,
485485+ track_mb_id,
486486+ recording_mb_id,
487487+ duration,
488488+ artists,
489489+ release_name,
490490+ release_mb_id,
491491+ origin_url,
492492+ isrc,
493493+ played_time,
494494+ music_service_base_domain: None,
495495+ submission_client_agent: None,
496496+ };
497497+498498+ let time = time.unwrap_or(chrono::Local::now().into());
499499+500500+ let status = Status {
501501+ time,
502502+ expiry: Some(expiry.unwrap_or(time + std::time::Duration::from_mins(10))),
503503+ item: play,
504504+ };
505505+506506+ let auth = get_auth()?;
507507+ let session_info = auth.get_session_info()?;
508508+ let session = auth.restore().await?;
509509+510510+ let status_man = StatusManager::new(&session_info.did);
511511+ status_man.set_status(session, status).await?;
512512+513513+ println!(
514514+ "{}: set status for {}, {}",
515515+ "success".green().bold(),
516516+ (session_info
517517+ .handles
518518+ .first()
519519+ .unwrap_or(&"(no handle)".red().to_string())),
520520+ session_info.did
521521+ );
410522 }
411523 StatusCommands::Clear => {
412524 let auth = get_auth()?;