Replies: 6 comments 4 replies
-
Well, the problem is not only having an enum for each (simple) property. The main problem that I see here is, that track.AdditionalFields["TIT1"] = "an id3 group";
track.AdditionalFields["©grp"] = "an mp4 group";
track.Save(); What is gonna be saved? You just don't know without the context or the mapping. Pro:
Con:
Removing So what I would suggest is basically having no class AdvancedTrack {
// all mapped values are stored here
public IDictionary<Field, object?> Fields = new();
public int? Bpm
{
get => GetField<int?>(Field.BPM);
set => SetField(Field.BPM, value);
}
private T? GetField<T>(Field field) {
// return casted Fields[field];
}
public Field? SetAdditionalField(Format f, string key, object? value) {
// this should be chained somehow
// all unmapped values go the the according container, depending on the format and the key
// you could even validate, if this key is ok for the chosen format.
if(f.Name = "id3v2" && key == "TBPM") {
Bpm = value;
return Field.BPM;
}
return null; // means not mapped
}
// maybe with Generics?
public object? GetAdditionalField(string key, Format? f = null) {
if(f != null) {
return MetadataFormats[f].Get(key);
}
foreach(var mf in MetadataFormats) {
if(mf.ContainsKey(key)) {
return mf[key];
}
}
return null;
}
// ...
} This way it would be possible to abstract |
Beta Was this translation helpful? Give feedback.
-
So, after trying some things out, I would like to mention a few things first: Internal classesThe following classes / values are
Is that intended? API For
|
Beta Was this translation helpful? Give feedback.
-
@Zeugma440 Hey, did you find the time to look into this idea? Don't feel pushed but since there is a new release I remembered that there was something on my list :-) |
Beta Was this translation helpful? Give feedback.
-
@Zeugma440 However, I did not mean the whole API suggestion I made but only the internal classes in
If you would make these public in the next release, I could try to implement something myself, otherwise I have to go for a pull request which would just put even more work on your shoulders or fork the repo with a completely separate build process, which would make me feel uncomfortable in many ways :-) Maybe there is a good reason to NOT make these classes public, but if you are ok with it, I would definitely appreciate it and could write my own |
Beta Was this translation helpful? Give feedback.
-
@Zeugma440
I ask this, because having interface IAdvancedTrack
{
// ...
// T? does not work on C# 8.0 or lower
public T? GetField<T>(Field field);
// ...
} |
Beta Was this translation helpful? Give feedback.
-
Ok, great.
Ok, then I have to solve this differently (I'm totally fine with this).
Yeah for the first PR (if it ever happens) I will not touch these and just copy over the unit tests for Thanks, I'll try to push this forward, but it may take a while. |
Beta Was this translation helpful? Give feedback.
-
Continued from #121 (comment) @sandreas
ATL actually uses a map of all "simple" properties (e.g. non chapters, non pictures, non lyrics) internally, so that shouldn't be a problem to do that. What would be your ideal API ?
You've said it all... and ATL does intend on supporting multiple formats on the same file, so what you suggest is an actual problem for me too.
The upper level (public API) of ATL is user-oriented and has no clue about which property is mapped to which technical ID. So when you say "Track, please store A into
SortAlbum
and B intoAdditionalFields["TSOA"]
", Track has no clue that you're asking for something contradictory. Plus what might be contradictory for ID3v2 is absolutely fine for APEtag 🤦Part of what you describe seems awfully close to what I've already done on TagData and MetaDataHolder. It would be a kind of waste if you reinvented the wheel beside ATL. Imho, we should converge together towards a unique solution - maybe an "advanced API" to ATL for coders who are knowledgeable about audio metadata ?
Beta Was this translation helpful? Give feedback.
All reactions