Added, but disabled icon dl impl. Player improvements
This commit is contained in:
@@ -1,5 +1,12 @@
|
||||
use std::{fmt::Display, path::PathBuf, str::FromStr};
|
||||
use std::{fmt::Display, str::FromStr};
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, PartialEq, PartialOrd, Default)]
|
||||
pub enum IconType {
|
||||
CustomUrl(url::Url),
|
||||
FromSource,
|
||||
#[default]
|
||||
None
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, PartialEq, PartialOrd)]
|
||||
@@ -7,7 +14,14 @@ pub struct Song {
|
||||
name: String,
|
||||
author: String,
|
||||
url: url::Url,
|
||||
source_type: SourceType,
|
||||
source_type: SourceType,
|
||||
#[serde(default)]
|
||||
icon_type: IconType,
|
||||
#[serde(default)]
|
||||
genres: Vec<String>,
|
||||
/// Seconds
|
||||
#[serde(default)]
|
||||
length: usize,
|
||||
}
|
||||
|
||||
impl Song {
|
||||
@@ -16,7 +30,10 @@ impl Song {
|
||||
name: String::default(),
|
||||
author: String::default(),
|
||||
source_type,
|
||||
url: url.clone()
|
||||
icon_type: IconType::None,
|
||||
url: url.clone(),
|
||||
genres: Vec::new(),
|
||||
length: 0
|
||||
})
|
||||
}
|
||||
pub fn new_from_str(url: &str, source_type: SourceType) -> crate::Result<Self> {
|
||||
@@ -34,6 +51,15 @@ impl Song {
|
||||
pub fn source_type(&self) -> &SourceType {
|
||||
&self.source_type
|
||||
}
|
||||
pub fn icon_type(&self) -> &IconType {
|
||||
&self.icon_type
|
||||
}
|
||||
pub fn genres(&self) -> &[String] {
|
||||
&self.genres
|
||||
}
|
||||
pub fn length(&self) -> usize {
|
||||
self.length
|
||||
}
|
||||
pub fn set_name(&mut self, v: &str) {
|
||||
self.name = v.to_string();
|
||||
}
|
||||
@@ -46,6 +72,15 @@ impl Song {
|
||||
pub fn set_source_type(&mut self, v: &SourceType) {
|
||||
self.source_type.clone_from(v);
|
||||
}
|
||||
pub fn set_icon_type(&mut self, v: &IconType) {
|
||||
self.icon_type.clone_from(v);
|
||||
}
|
||||
pub fn genres_mut(&mut self) -> &mut Vec<String> {
|
||||
&mut self.genres
|
||||
}
|
||||
pub fn set_length(&mut self, l: usize) {
|
||||
self.length = l;
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, serde::Serialize, serde::Deserialize, PartialEq, PartialOrd)]
|
||||
|
||||
Reference in New Issue
Block a user