Mercurial > audlegacy-plugins
comparison src/cdaudio/cdinfo.c @ 399:597c89a37d07 trunk
[svn] - add DYEAR and DGENRE support.
author | yaz |
---|---|
date | Thu, 28 Dec 2006 02:57:42 -0800 |
parents | d58221dfced1 |
children | d124034ebea3 |
comparison
equal
deleted
inserted
replaced
398:7e4e672de0dc | 399:597c89a37d07 |
---|---|
116 cdinfo->is_valid = TRUE; | 116 cdinfo->is_valid = TRUE; |
117 } | 117 } |
118 | 118 |
119 | 119 |
120 /* | 120 /* |
121 * Function cdda_cdinfo_cd_set (cdinfo, cdname, cdartist) | 121 * Function cdda_cdinfo_cd_set (cdinfo, cdname, cdartist, discid, |
122 * | 122 * genre, year) |
123 * Set name and artist for a cd. If CD is a multiartist disc, the | 123 * |
124 * `artist' should be set to NULL. | 124 * Set name, artist, discid, genre and year for a cd. If CD is a |
125 * | 125 * multiartist disc, the `artist' should be set to NULL. |
126 */ | 126 * |
127 void | 127 */ |
128 cdda_cdinfo_cd_set(cdinfo_t * cdinfo, gchar * cdname, gchar * cdartist) | 128 void |
129 { | 129 cdda_cdinfo_cd_set(cdinfo_t * cdinfo, gchar * cdname, gchar * cdartist, |
130 gchar * discid, gchar * genre, gchar *year) | |
131 { | |
132 cdinfo->is_valid = TRUE; | |
130 cdinfo->albname = cdname; | 133 cdinfo->albname = cdname; |
131 cdinfo->artname = cdartist; | 134 cdinfo->artname = cdartist; |
132 cdinfo->is_valid = TRUE; | 135 cdinfo->discid = discid ? atoi(discid) : 0; |
136 cdinfo->genre = genre; | |
137 cdinfo->year = year ? atoi(year) : 0; | |
133 } | 138 } |
134 | 139 |
135 | 140 |
136 /* | 141 /* |
137 * Function cdda_cdinfo_get (cdinfo, num, artist, album, title) | 142 * Function cdda_cdinfo_get (cdinfo, num, artist, album, title) |
186 if (cdinfo->albname) | 191 if (cdinfo->albname) |
187 bmp_rcfile_write_string(rcfile, sectionname, "Albumname", | 192 bmp_rcfile_write_string(rcfile, sectionname, "Albumname", |
188 cdinfo->albname); | 193 cdinfo->albname); |
189 else | 194 else |
190 bmp_rcfile_write_string(rcfile, sectionname, "Albumname", ""); | 195 bmp_rcfile_write_string(rcfile, sectionname, "Albumname", ""); |
196 | |
191 if (cdinfo->artname) | 197 if (cdinfo->artname) |
192 bmp_rcfile_write_string(rcfile, sectionname, "Artistname", | 198 bmp_rcfile_write_string(rcfile, sectionname, "Artistname", |
193 cdinfo->artname); | 199 cdinfo->artname); |
200 if (cdinfo->year) { | |
201 gchar *yearstr = g_strdup_printf("%4d", cdinfo->year); | |
202 bmp_rcfile_write_string(rcfile, sectionname, "Year", yearstr); | |
203 g_free(yearstr); | |
204 } | |
205 | |
206 if (cdinfo->genre) | |
207 bmp_rcfile_write_string(rcfile, sectionname, "Genre", cdinfo->genre); | |
208 | |
209 | |
194 for (i = 1; i <= numtracks; i++) { | 210 for (i = 1; i <= numtracks; i++) { |
195 if (cdinfo->tracks[i].artist) { | 211 if (cdinfo->tracks[i].artist) { |
196 sprintf(trackstr, "track_artist%d", i); | 212 sprintf(trackstr, "track_artist%d", i); |
197 bmp_rcfile_write_string(rcfile, sectionname, trackstr, | 213 bmp_rcfile_write_string(rcfile, sectionname, trackstr, |
198 cdinfo->tracks[i].artist); | 214 cdinfo->tracks[i].artist); |
222 gchar *filename; | 238 gchar *filename; |
223 RcFile *rcfile; | 239 RcFile *rcfile; |
224 gchar sectionname[10], trackstr[16]; | 240 gchar sectionname[10], trackstr[16]; |
225 gint i, numtracks = cddb_discid & 0xff; | 241 gint i, numtracks = cddb_discid & 0xff; |
226 gboolean track_found; | 242 gboolean track_found; |
243 gchar *yearstr = NULL; | |
227 | 244 |
228 sprintf(sectionname, "%08x", cddb_discid); | 245 sprintf(sectionname, "%08x", cddb_discid); |
229 | 246 |
230 filename = | 247 filename = |
231 g_strconcat(g_get_home_dir(), "/", BMP_RCPATH, "/cdinfo", NULL); | 248 g_strconcat(g_get_home_dir(), "/", BMP_RCPATH, "/cdinfo", NULL); |
239 (rcfile, sectionname, "Albumname", &cdinfo->albname)) | 256 (rcfile, sectionname, "Albumname", &cdinfo->albname)) |
240 return FALSE; | 257 return FALSE; |
241 | 258 |
242 bmp_rcfile_read_string(rcfile, sectionname, "Artistname", | 259 bmp_rcfile_read_string(rcfile, sectionname, "Artistname", |
243 &cdinfo->artname); | 260 &cdinfo->artname); |
261 | |
262 bmp_rcfile_read_string(rcfile, sectionname, "Year", &yearstr); | |
263 if (yearstr) { | |
264 cdinfo->year = atoi(yearstr); | |
265 g_free(yearstr); | |
266 yearstr = NULL; | |
267 } | |
268 | |
269 bmp_rcfile_read_string(rcfile, sectionname, "Genre", &cdinfo->genre); | |
244 | 270 |
245 for (i = 1; i <= numtracks; i++) { | 271 for (i = 1; i <= numtracks; i++) { |
246 track_found = FALSE; | 272 track_found = FALSE; |
247 sprintf(trackstr, "track_artist%d", i); | 273 sprintf(trackstr, "track_artist%d", i); |
248 if (bmp_rcfile_read_string | 274 if (bmp_rcfile_read_string |