From 0b86408637409f76d001db36a8bfeecab248682f Mon Sep 17 00:00:00 2001 From: Martchus Date: Thu, 31 May 2018 00:32:30 +0200 Subject: [PATCH] Fix specifying track number The way to specify the track ID for setting meta-data on track-level conflicted with the way to specify the track number. The track ID is now specified via 'track-id='. This breaks the CLI, however I see it as a bug that 'track=' worked for specifying the track ID so it should be ok. --- README.md | 2 +- cli/helper.cpp | 19 +++++++++---------- cli/mainfeatures.cpp | 2 +- tests/cli.cpp | 14 +++++++------- 4 files changed, 18 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index d1618f7..3890ff4 100644 --- a/README.md +++ b/README.md @@ -201,7 +201,7 @@ Here are some Bash examples which illustrate getting and setting tag information * Removes the "forced" flag from all tracks, flags the track with the ID 2 as "default" and sets its language to "ger": ``` - tageditor set track=all forced=no track=2 default=yes language=ger + tageditor set track-id=all forced=no track-id=2 default=yes language=ger ``` - So modifying track attributes is possible as well and it works like setting tag fields. diff --git a/cli/helper.cpp b/cli/helper.cpp index f5c7890..efc1172 100644 --- a/cli/helper.cpp +++ b/cli/helper.cpp @@ -504,8 +504,8 @@ FieldDenotations parseFieldDenotations(const Argument &fieldsArg, bool readOnly) continue; } else if (applyTargetConfiguration(scope.tagTarget, fieldDenotationString)) { continue; - } else if (!strncmp(fieldDenotationString, "track=", 6)) { - const vector parts = splitString>(fieldDenotationString + 6, ",", EmptyPartsTreat::Omit); + } else if (!strncmp(fieldDenotationString, "track-id=", 9)) { + const vector parts = splitString>(fieldDenotationString + 9, ",", EmptyPartsTreat::Omit); bool allTracks = false; vector trackIds; trackIds.reserve(parts.size()); @@ -513,14 +513,13 @@ FieldDenotations parseFieldDenotations(const Argument &fieldsArg, bool readOnly) if (part == "all" || part == "any") { allTracks = true; break; - } else { - try { - trackIds.emplace_back(stringToNumber(part)); - } catch (const ConversionException &) { - cerr << Phrases::Error << "The value provided with the \"track\"-specifier is invalid." << Phrases::End - << "note: It must be a comma-separated list of track IDs." << endl; - exit(-1); - } + } + try { + trackIds.emplace_back(stringToNumber(part)); + } catch (const ConversionException &) { + cerr << Phrases::Error << "The value provided with the \"track\"-specifier is invalid." << Phrases::End + << "note: It must be a comma-separated list of track IDs." << endl; + exit(-1); } } scope.allTracks = allTracks; diff --git a/cli/mainfeatures.cpp b/cli/mainfeatures.cpp index c7f7dbc..e54b910 100644 --- a/cli/mainfeatures.cpp +++ b/cli/mainfeatures.cpp @@ -76,7 +76,7 @@ namespace Cli { #define TAG_MODIFIER "tag=id3v1 tag=id3v2 tag=id3 tag=itunes tag=vorbis tag=matroska tag=all" -#define TRACK_MODIFIER "track= track=all" +#define TRACK_MODIFIER "track-id= track=all" #define TARGET_MODIFIER \ "target-level target-levelname target-tracks target-tracks\n" \ diff --git a/tests/cli.cpp b/tests/cli.cpp index 4e82300..526ee47 100644 --- a/tests/cli.cpp +++ b/tests/cli.cpp @@ -356,8 +356,8 @@ void CliTests::testId3SpecificOptions() CPPUNIT_ASSERT_EQUAL(0, remove(mp3File1Backup.data())); // convert remaining ID3v2 tag to version 2, add an ID3v1 tag again and set a field with unicode char by the way - const char *const args3[] = { "tageditor", "set", "album=Dóuble Nickels On The Dime", "--id3v1-usage", "always", "--id3v2-version", "2", - "--id3-init-on-create", "-f", mp3File1.data(), nullptr }; + const char *const args3[] = { "tageditor", "set", "album=Dóuble Nickels On The Dime", "track=5/10", "--id3v1-usage", "always", "--id3v2-version", + "2", "--id3-init-on-create", "-f", mp3File1.data(), nullptr }; CPPUNIT_ASSERT_EQUAL(0, execApp(args3, stdout, stderr)); CPPUNIT_ASSERT_EQUAL(0, execApp(args1, stdout, stderr)); CPPUNIT_ASSERT(testContainsSubstrings(stdout, @@ -368,7 +368,7 @@ void CliTests::testId3SpecificOptions() " Genre Punk Rock\n" " Year 1984\n" " Comment ExactAudioCopy v0.95b4\n" - " Track 4\n", + " Track 5\n", " - \e[1mID3v2 tag (version 2.2.0)\e[0m\n" " Title Cohesion\n" " Album Dóuble Nickels On The Dime\n" @@ -376,7 +376,7 @@ void CliTests::testId3SpecificOptions() " Genre Punk Rock\n" " Year 1984\n" " Comment ExactAudioCopy v0.95b4\n" - " Track 4/43\n" + " Track 5/10\n" " Duration 00:00:00\n" " Encoder settings LAME 64bits version 3.99 (http://lame.sf.net)" })); CPPUNIT_ASSERT_EQUAL(0, remove(mp3File1.data())); @@ -737,9 +737,9 @@ void CliTests::testSettingTrackMetaData() // test Matroska file const string mkvFile(workingCopyPath("matroska_wave1/test2.mkv")); const string mp4File(workingCopyPath("mtx-test-data/aac/he-aacv2-ps.m4a")); - const char *const args1[] = { "tageditor", "set", "title=title of tag", "track=1863976627", "name=video track", "track=3134325680", - "name=audio track", "language=ger", "default=yes", "forced=yes", "tag=any", "artist=setting tag value again", "track=any", "name1=sbr and ps", - "language1=eng", "-f", mkvFile.data(), mp4File.data(), nullptr }; + const char *const args1[] = { "tageditor", "set", "title=title of tag", "track-id=1863976627", "name=video track", "track-id=3134325680", + "name=audio track", "language=ger", "default=yes", "forced=yes", "tag=any", "artist=setting tag value again", "track-id=any", + "name1=sbr and ps", "language1=eng", "-f", mkvFile.data(), mp4File.data(), nullptr }; const char *const args2[] = { "tageditor", "info", "-f", mkvFile.data(), nullptr }; const char *const args3[] = { "tageditor", "get", "-f", mkvFile.data(), nullptr }; TESTUTILS_ASSERT_EXEC(args1);