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.
This commit is contained in:
Martchus 2018-05-31 00:32:30 +02:00
parent 95ac0d6aa7
commit 0b86408637
4 changed files with 18 additions and 19 deletions

View File

@ -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.

View File

@ -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<string> parts = splitString<vector<string>>(fieldDenotationString + 6, ",", EmptyPartsTreat::Omit);
} else if (!strncmp(fieldDenotationString, "track-id=", 9)) {
const vector<string> parts = splitString<vector<string>>(fieldDenotationString + 9, ",", EmptyPartsTreat::Omit);
bool allTracks = false;
vector<uint64> 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<uint64>(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<uint64>(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;

View File

@ -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" \

View File

@ -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);