Skip to content

Commit fd15ce6

Browse files
authored
Merge pull request kstep#33 from oberien/master
Add artist to currentsong
2 parents ffa92d0 + df2bc67 commit fd15ce6

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/song.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ pub struct Song {
102102
pub title: Option<String>,
103103
/// last modification time
104104
pub last_mod: Option<Tm>,
105+
/// artist
106+
pub artist: Option<String>,
105107
/// duration (in seconds resolution)
106108
pub duration: Option<Duration>,
107109
/// place in the queue (if queued for playback)
@@ -124,15 +126,16 @@ impl Encodable for Song {
124126
None => e.emit_option_none(),
125127
})
126128
})?;
127-
e.emit_struct_field("duration", 4, |e| {
129+
e.emit_struct_field("artist", 4, |e| self.artist.encode(e))?;
130+
e.emit_struct_field("duration", 5, |e| {
128131
e.emit_option(|e| match self.duration {
129132
Some(d) => e.emit_option_some(|e| d.num_seconds().encode(e)),
130133
None => e.emit_option_none(),
131134
})
132135
})?;
133-
e.emit_struct_field("place", 5, |e| self.place.encode(e))?;
134-
e.emit_struct_field("range", 6, |e| self.range.encode(e))?;
135-
e.emit_struct_field("tags", 7, |e| self.tags.encode(e))?;
136+
e.emit_struct_field("place", 6, |e| self.place.encode(e))?;
137+
e.emit_struct_field("range", 7, |e| self.range.encode(e))?;
138+
e.emit_struct_field("tags", 8, |e| self.tags.encode(e))?;
136139
Ok(())
137140
})
138141
}
@@ -149,6 +152,7 @@ impl FromIter for Song {
149152
"file" => result.file = line.1.to_owned(),
150153
"Title" => result.title = Some(line.1.to_owned()),
151154
"Last-Modified" => result.last_mod = try!(strptime(&*line.1, "%Y-%m-%dT%H:%M:%S%Z").map_err(ParseError::BadTime).map(Some)),
155+
"Artist" => result.artist = Some(line.1.to_owned()),
152156
"Name" => result.name = Some(line.1.to_owned()),
153157
"Time" => result.duration = Some(Duration::seconds(try!(line.1.parse()))),
154158
"Range" => result.range = Some(try!(line.1.parse())),

0 commit comments

Comments
 (0)