summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-01-02 13:05:52 +0100
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-01-02 13:05:52 +0100
commit40d3a5c66105914c1113bc7ef0649e13b3db690f (patch)
treed5ea22458282e5b6c7b93214b902114478735e73
parentd90852fcc0ce41ce30d39a7d50e8156863c4a7b9 (diff)
added junk_copy API to copy metadata from one track to a list of tracks
-rw-r--r--deadbeef.h1
-rw-r--r--junklib.c30
-rw-r--r--junklib.h3
-rw-r--r--plugins.c1
4 files changed, 35 insertions, 0 deletions
diff --git a/deadbeef.h b/deadbeef.h
index f0c81e35..68f781be 100644
--- a/deadbeef.h
+++ b/deadbeef.h
@@ -346,6 +346,7 @@ typedef struct {
int (*junk_read_id3v2) (DB_playItem_t *it, DB_FILE *fp);
int (*junk_read_ape) (DB_playItem_t *it, DB_FILE *fp);
int (*junk_get_leading_size) (DB_FILE *fp);
+ void (*junk_copy) (DB_playItem_t *from, DB_playItem_t *first, DB_playItem_t *last);
// vfs
DB_FILE* (*fopen) (const char *fname);
void (*fclose) (DB_FILE *f);
diff --git a/junklib.c b/junklib.c
index 53e07cc1..1983abee 100644
--- a/junklib.c
+++ b/junklib.c
@@ -1284,3 +1284,33 @@ junk_recode (const char *in, int inlen, char *out, int outlen, const char *cs) {
iconv_close (cd);
}
}
+
+void
+junk_copy (playItem_t *from, playItem_t *first, playItem_t *last) {
+ const char *year = pl_find_meta (from, "year");
+ const char *genre = pl_find_meta (from, "genre");
+ const char *copyright = pl_find_meta (from, "copyright");
+ const char *vendor = pl_find_meta (from, "vendor");
+ const char *comment = pl_find_meta (from, "comment");
+ playItem_t *i;
+ for (i = first; i; i = i->next[PL_MAIN]) {
+ if (year) {
+ pl_add_meta (i, "year", year);
+ }
+ if (genre) {
+ pl_add_meta (i, "genre", genre);
+ }
+ if (copyright) {
+ pl_add_meta (i, "copyright", copyright);
+ }
+ if (vendor) {
+ pl_add_meta (i, "vendor", vendor);
+ }
+ if (comment) {
+ pl_add_meta (i, "comment", comment);
+ }
+ if (i == last) {
+ break;
+ }
+ }
+}
diff --git a/junklib.h b/junklib.h
index 807c300d..26a104fa 100644
--- a/junklib.h
+++ b/junklib.h
@@ -40,4 +40,7 @@ junk_detect_charset (const char *s);
void
junk_recode (const char *in, int inlen, char *out, int outlen, const char *cs);
+void
+junk_copy (struct playItem_s *from, struct playItem_s *first, struct playItem_s *last);
+
#endif // __JUNKLIB_H
diff --git a/plugins.c b/plugins.c
index 70e4d652..c38eb1a9 100644
--- a/plugins.c
+++ b/plugins.c
@@ -146,6 +146,7 @@ static DB_functions_t deadbeef_api = {
.junk_read_id3v2 = (int (*)(DB_playItem_t *it, DB_FILE *fp))junk_read_id3v2,
.junk_read_ape = (int (*)(DB_playItem_t *it, DB_FILE *fp))junk_read_ape,
.junk_get_leading_size = junk_get_leading_size,
+ .junk_copy = (void (*)(DB_playItem_t *from, DB_playItem_t *first, DB_playItem_t *last))junk_copy,
// vfs
.fopen = vfs_fopen,
.fclose = vfs_fclose,