@@ -118,6 +118,7 @@ pub struct Track {
118118 pub album : Option < Album > ,
119119 #[ serde( serialize_with = "serialize_duration" ) ]
120120 pub duration : chrono:: Duration ,
121+ pub explicit : bool ,
121122 #[ serde( skip) ]
122123 pub added_at : u64 ,
123124}
@@ -240,6 +241,15 @@ impl Track {
240241 . unwrap_or_default ( )
241242 }
242243
244+ /// gets the track's name, including an explicit label
245+ pub fn display_name ( & self ) -> String {
246+ let mut name = self . name . clone ( ) ;
247+ if self . explicit {
248+ name. push_str ( " (Explicit)" ) ;
249+ }
250+ name
251+ }
252+
243253 /// tries to convert from a `rspotify_model::SimplifiedTrack` into `Track`
244254 pub fn try_from_simplified_track ( track : rspotify_model:: SimplifiedTrack ) -> Option < Self > {
245255 if track. is_playable . unwrap_or ( true ) {
@@ -249,6 +259,7 @@ impl Track {
249259 artists : from_simplified_artists_to_artists ( track. artists ) ,
250260 album : None ,
251261 duration : track. duration ,
262+ explicit : track. explicit ,
252263 added_at : 0 ,
253264 } )
254265 } else {
@@ -265,6 +276,7 @@ impl Track {
265276 artists : from_simplified_artists_to_artists ( track. artists ) ,
266277 album : Album :: try_from_simplified_album ( track. album ) ,
267278 duration : track. duration ,
279+ explicit : track. explicit ,
268280 added_at : 0 ,
269281 } )
270282 } else {
@@ -278,7 +290,7 @@ impl std::fmt::Display for Track {
278290 write ! (
279291 f,
280292 "{} • {} ▎ {}" ,
281- self . name ,
293+ self . display_name ( ) ,
282294 self . artists_info( ) ,
283295 self . album_info( ) ,
284296 )
0 commit comments