aboutsummaryrefslogtreecommitdiff
path: root/src/idop.c
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2009-03-17 11:59:19 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2009-03-17 11:59:19 +0200
commite25a44d9bdc40ca8bf2efcd12ed73e2104fdb360 (patch)
treeb805996c317f299b5421d6f48c9528664da00981 /src/idop.c
parenta0a067bde62b828a09f165524dc993580ac7e450 (diff)
downloadidest-e25a44d9bdc40ca8bf2efcd12ed73e2104fdb360.tar.gz
idest-e25a44d9bdc40ca8bf2efcd12ed73e2104fdb360.tar.bz2
Improve scripting, implement v1->v2 conversion, implement --delete command.
* libid3tag/file.c (v2_write): Change for make it possible to convert v1 to v2. * src/.gitignore: Add guile.x. * src/Makefile.am (idest_SOURCES): Add guile.x (BUILT_SOURCES): Add guile.x (SUFFIXES): Add .x (.c.x): New rule * src/cmdline.opt: New option: --trace. * src/guile.c: Rewrite. * src/idest.h (MODE_QUERY, MODE_MOD, MODE_DELETE): New defines (from main.c). (guile_transform, guile_list): New protos. (guile_apply): Remove. * src/idop.c (set_tags): Handle convert_version == 2. (del_tags): New function. * src/main.c (del_id3): Call del_tags
Diffstat (limited to 'src/idop.c')
-rw-r--r--src/idop.c39
1 files changed, 34 insertions, 5 deletions
diff --git a/src/idop.c b/src/idop.c
index fb62e98..547edc8 100644
--- a/src/idop.c
+++ b/src/idop.c
@@ -105,14 +105,22 @@ set_tags(const char *name)
}
/* FIXME */
- modified |= guile_apply(name, tag);
-
- if (convert_version == 1) {
+ modified |= guile_transform(name, tag);
+
+ switch (convert_version) {
+ case 1:
id3_tag_options(tag,
ID3_TAG_OPTION_NO_ID3V2,
ID3_TAG_OPTION_NO_ID3V2);
version_option = 1;
modified |= 1;
+ break;
+
+ case 2:
+ id3_tag_options(tag, ID3_TAG_OPTION_ID3V1, 0);
+ version_option = 0;
+ modified |= 1;
+ break;
}
if (version_option == 1) {
@@ -125,6 +133,25 @@ set_tags(const char *name)
id3_file_close(file);
}
+void
+del_tags(const char *name)
+{
+ struct id3_file *file;
+ struct id3_tag *tag;
+
+ file = id3_file_open(name, ID3_FILE_MODE_READWRITE);
+ if (!file)
+ error(1, errno, "cannot open file %s", name);
+ tag = id3_file_tag(file);
+ if (!tag)
+ abort(); /* FIXME */
+ id3_tag_options(tag,
+ ID3_TAG_OPTION_ID3V1|ID3_TAG_OPTION_NO_ID3V2,
+ ID3_TAG_OPTION_NO_ID3V2);
+ id3_file_update(file);
+ id3_file_close(file);
+}
+
char *
idest_ucs4_cvt(id3_ucs4_t const *ucs4)
@@ -230,8 +257,10 @@ query_tags(const char *name)
error(1, errno, "cannot open file %s", name);
tag = id3_file_tag(file);
- if (tag)
- show_tags(tag);
+ if (tag) {
+ if (guile_list(name, tag) == 0)
+ show_tags(tag);
+ }
id3_file_close(file);
}

Return to:

Send suggestions and report system problems to the System administrator.