DespotifyUtils: use class TagBuilder
This commit is contained in:
		| @@ -19,6 +19,7 @@ | |||||||
|  |  | ||||||
| #include "DespotifyUtils.hxx" | #include "DespotifyUtils.hxx" | ||||||
| #include "tag/Tag.hxx" | #include "tag/Tag.hxx" | ||||||
|  | #include "tag/TagBuilder.hxx" | ||||||
| #include "ConfigGlobal.hxx" | #include "ConfigGlobal.hxx" | ||||||
| #include "ConfigOption.hxx" | #include "ConfigOption.hxx" | ||||||
| #include "util/Domain.hxx" | #include "util/Domain.hxx" | ||||||
| @@ -90,25 +91,24 @@ mpd_despotify_tag_from_track(struct ds_track *track) | |||||||
| 	char comment[80]; | 	char comment[80]; | ||||||
| 	char date[20]; | 	char date[20]; | ||||||
|  |  | ||||||
| 	Tag *tag = new Tag(); |  | ||||||
|  |  | ||||||
| 	if (!track->has_meta_data) | 	if (!track->has_meta_data) | ||||||
| 		return tag; | 		return new Tag(); | ||||||
|  |  | ||||||
|  | 	TagBuilder tag; | ||||||
| 	snprintf(tracknum, sizeof(tracknum), "%d", track->tracknumber); | 	snprintf(tracknum, sizeof(tracknum), "%d", track->tracknumber); | ||||||
| 	snprintf(date, sizeof(date), "%d", track->year); | 	snprintf(date, sizeof(date), "%d", track->year); | ||||||
| 	snprintf(comment, sizeof(comment), "Bitrate %d Kbps, %sgeo restricted", | 	snprintf(comment, sizeof(comment), "Bitrate %d Kbps, %sgeo restricted", | ||||||
| 		 track->file_bitrate / 1000, | 		 track->file_bitrate / 1000, | ||||||
| 		 track->geo_restricted ? "" : "not "); | 		 track->geo_restricted ? "" : "not "); | ||||||
| 	tag->AddItem(TAG_TITLE, track->title); | 	tag.AddItem(TAG_TITLE, track->title); | ||||||
| 	tag->AddItem(TAG_ARTIST, track->artist->name); | 	tag.AddItem(TAG_ARTIST, track->artist->name); | ||||||
| 	tag->AddItem(TAG_TRACK, tracknum); | 	tag.AddItem(TAG_TRACK, tracknum); | ||||||
| 	tag->AddItem(TAG_ALBUM, track->album); | 	tag.AddItem(TAG_ALBUM, track->album); | ||||||
| 	tag->AddItem(TAG_DATE, date); | 	tag.AddItem(TAG_DATE, date); | ||||||
| 	tag->AddItem(TAG_COMMENT, comment); | 	tag.AddItem(TAG_COMMENT, comment); | ||||||
| 	tag->time = track->length / 1000; | 	tag.SetTime(track->length / 1000); | ||||||
|  |  | ||||||
| 	return tag; | 	return tag.Commit(); | ||||||
| } | } | ||||||
|  |  | ||||||
| struct despotify_session *mpd_despotify_get_session(void) | struct despotify_session *mpd_despotify_get_session(void) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Max Kellermann
					Max Kellermann