diff options
Diffstat (limited to 'src/queue.rs')
| -rw-r--r-- | src/queue.rs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/queue.rs b/src/queue.rs index 2c20356..d42203f 100644 --- a/src/queue.rs +++ b/src/queue.rs | |||
| @@ -117,6 +117,22 @@ impl Track { | |||
| 117 | format!("{:0width$}. {} - {}", index + 1, album_artist, title) | 117 | format!("{:0width$}. {} - {}", index + 1, album_artist, title) |
| 118 | } | 118 | } |
| 119 | } | 119 | } |
| 120 | |||
| 121 | pub fn format(&self, format_str: &str) -> String { | ||
| 122 | let artist = self.artist.clone().unwrap_or_default(); | ||
| 123 | let album = self.album.clone().unwrap_or_default(); | ||
| 124 | let title = self.title.clone().unwrap_or_else(|| { | ||
| 125 | self.path | ||
| 126 | .file_name() | ||
| 127 | .and_then(|n| n.to_str()) | ||
| 128 | .unwrap_or("Unknown") | ||
| 129 | .to_string() | ||
| 130 | }); | ||
| 131 | format_str | ||
| 132 | .replace("$ARTIST", &artist) | ||
| 133 | .replace("$ALBUM", &album) | ||
| 134 | .replace("$TRACK", &title) | ||
| 135 | } | ||
| 120 | } | 136 | } |
| 121 | 137 | ||
| 122 | pub struct Queue { | 138 | pub struct Queue { |
