-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
APE Format Support #190
base: master
Are you sure you want to change the base?
APE Format Support #190
Conversation
Thanks for your contribution! Support for APE files would be great. You can add sample files here: https://github.com/devsnd/tinytag/tree/master/tinytag/tests/samples Then add the metadata to the testfiles dictionary: https://github.com/devsnd/tinytag/blob/master/tinytag/tests/test_all.py Ideally, test files should be as small as possible, and either contain silence, or be truncated to the point that almost no audio data remains. If possible, try to use e.g. Audacity to generate silent audio files, and then add metadata to them. |
tinytag/tinytag.py
Outdated
self.channels = channels_num | ||
self.bitrate = self.filesize / self.duration * 8 / 1000 | ||
|
||
# start to parse metadatas |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If possible, please move any code before this to _determine_duration(), so tags aren't populated when tag parsing is disabled. If it's not possible, please check the _parse_tags
and _parse_duration
attributes for when to populate tags.
Alright I'll try to build some of them.
Ah okay, I wrote this part of the program with the reference to the And one further thing, I realize that the checks are failing due to |
Wrap the long lines so they don't exceed the limit (100 characters per line). Run |
I added one sample to the tests. Sadly I failed to find or build a sample with ape file format lower than version 3.98 (even with the offical encoder released in 2011), it's simply too old. |
No problem, I could see if I can find some sample files. If you fix the remaining linting error, we can get a coverage report showing how much of the code is covered by the tests. |
Hm doesn't look really fine (I mean the coverage) |
'comment': 'comment', | ||
'composer': 'composer', | ||
'disc': 'disc', | ||
'discnumber': 'disc', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also add mapping for disctotal -> disc_total
'discnumber': 'disc', | ||
'genre': 'genre', | ||
'track': 'track', | ||
'tracknumber': 'track', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also add mapping for tracktotal -> track_total
Here are audio files with both APEv1 and APEv2 tags. Could you add them to the sample files and ensure they are read properly? ape_tracks.zip I'll try to generate a file for fver < 3980 too. |
'title': 'title', | ||
'artist': 'artist', | ||
'album': 'album', | ||
'album artist': 'albumartist', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also add albumartist -> albumartists (used by taglib)
@@ -422,6 +422,16 @@ | |||
'duration': 2.176, 'filesize': 18532, 'bitrate': 64.0, 'samplerate': 8000, 'bitdepth': 8, | |||
'title': 'song title', 'artist': 'artist 1;artist 2', 'audio_offset': 46}), | |||
|
|||
# APE | |||
('samples/ape-44100-16-1.ape', | |||
{'extra': {'Copyright': 'nope'}, 'channels': 1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Convert all extra tag keys to lowercase
Please also add a
Ideally, we would have enough sample files so the tests cover every new line of code except |
Sorry for the really slow response, I was full buzy with something else in the past two weeks...
I see, I'll do that tomorrow morning.
Okay I'll try to do that. |
No worries, thank you for working on this. :) |
Hey there:
I forked this repo and added supports for ape format. I'm not sure if you're insterested in it.
The things I changed are:
add
.ape
tag inSUPPORTED_FILE_EXTENSIONS
listhttps://github.com/Ace-Radom/tinytag/blob/ef28a83e332a0ab5a51045defd940d72d0b7389d/tinytag/tinytag.py#L87
add
.ape
pointing to classAPE
undercls._file_extension_mapping
in function_get_parser_for_filename
https://github.com/Ace-Radom/tinytag/blob/ef28a83e332a0ab5a51045defd940d72d0b7389d/tinytag/tinytag.py#L149
add regex for ape format under
cls._magic_bytes_mapping
in function_get_parser_for_file_handle
https://github.com/Ace-Radom/tinytag/blob/ef28a83e332a0ab5a51045defd940d72d0b7389d/tinytag/tinytag.py#L181
then the
APE
classI didn't add any new tests because I don't know how to do it. But I tested it with my own samples and it worked as it should be.
The only thing is the keynames of apetag is not defined by the developers of the format. That means: there can be different keynames for one field (e.g.
artist
). I wrote a map like:This covered all situations I had with the samples created by foobar2k and mp3tag. But like I said, there can be different keynames for one field, and I don't know how efficient this solution is.