Skip to content
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

application/x-font-gdos is sometimes returned as a .mp3 mime-type and it not in the list of acceptable types #338

Closed
Nathoufresh opened this issue Aug 22, 2019 · 6 comments

Comments

@Nathoufresh
Copy link

Nathoufresh commented Aug 22, 2019

I have directory of songs, they all look like " Noisia-Tommy+s_Theme.mp3". I wrote a script to automatically tag the artist and the title for each of them.

#!/usr/bin/env python3

import eyed3
import os

os.chdir("./")
for filename in os.listdir('./'):
    for c, s in enumerate(filename):
            if s=="-":
                artist=filename[:(c)]
                title=filename[(c+1):-4]
                audiofile=eyed3.load(filename)
                audiofile.initTag()
                artist=artist.replace("+", "'")
                artist=artist.replace("_", " ")
                title=title.replace("+", "'")
                title=title.replace("_", " ")
                print(title)
                print(artist)
                audiofile.tag.artist=artist
                audiofile.tag.title=title
                audiofile.tag.save()
                break 

When I run it I get this error : Traceback (most recent call last): File "./tag.py", line 14, in <module> audiofile.initTag() AttributeError: 'NoneType' object has no attribute 'initTag'
But it happens only with 1/3 of the files. It works for some songs, but not for all of them. Any advices? ``

@nicfit
Copy link
Owner

nicfit commented Aug 23, 2019

audiofile=eyed3.load(filename) is returning None. What does running eyeD3 on those files show?

@Nathoufresh
Copy link
Author

Nathoufresh commented Aug 23, 2019

eyeD3 Damian_Marley-Road_To_Zion_\(Feat._Nas\).mp3 gives me

eyed3.plugins:WARNING: Plugin '('lastfm.py', '/usr/lib/python3.7/site-packages/eyed3/plugins')' requires packages that are not installed: cannot import name 'COVER_EXTRA_LARGE' from 'pylast' (/usr/lib/python3.7/site-packages/pylast/__init__.py)
Nothing to do 

I then istalled pylast-2.4.0 and the output is now Nothing to do even with eyeD3 -a "Damian Marley" -t "Road .. " Damian_Marley-Road_To_Zion_\(Feat._Nas\).mp3

eyeD3 -l debug -a "Damian Marley" -t "Road to Zion (Feat. Nas)" Damian_Marley-Road_To_Zion_\(Feat._Nas\).mp3

eyed3:DEBUG: command line args: Namespace(album=None, album_artist=None, artist='Damian Marley', backup=False, bpm=None, comments=[], composer=None, config=None, convert_version=None, debug_pdb=False, debug_profile=False, disc_num=None, disc_total=None, encoding_date=None, excludes=None, force_update=False, fs_encoding='utf-8', genre=None, images=[], list_plugins=False, log_level=[['debug']], lyrics=[], max_padding=True, no_color=False, no_config=False, non_std_genres=False, objects=[], orig_release_date=None, paths=['Damian_Marley-Road_To_Zion_(Feat._Nas).mp3'], play_count=None, plugin=<classic.ClassicPlugin object at 0x7f3523168910>, popularities=[], preserve_file_time=False, publisher=None, quiet=False, recording_date=None, release_date=None, release_year=None, remove_all=False, remove_all_comments=False, remove_all_images=False, remove_all_lyrics=False, remove_all_objects=False, remove_comment=[], remove_fids=[], remove_image=[], remove_lyrics=[], remove_object=[], remove_popularity=[], remove_v1=False, remove_v2=False, rename_pattern=None, simple_comment=None, tag_version=(3, None, None), tagging_date=None, text_encoding=None, text_frames=[], title='Road to Zion (Feat. Nas)', track=None, track_offset=None, track_total=None, unique_file_ids=[], url_frames=[], user_text_frames=[], user_url_frames=[], verbose=False, write_images_dir=None, write_objects_dir=None)
eyed3:DEBUG: plugin is: <classic.ClassicPlugin object at 0x7f3523168910>
eyed3.core:DEBUG: Loading file: /home/nathan/Data/Music/Rap/Damian_Marley-Road_To_Zion_(Feat._Nas).mp3
eyed3.core:DEBUG: File mime-type: application/x-font-gdos
Nothing to do

The hard drive is in NTFS, shared with Windows and mounted with ntfs-3g

Thanks for the help!

@nicfit
Copy link
Owner

nicfit commented Aug 23, 2019

Thanks for the additional info.

I have encountered files just like this, and I'm not sure why, but the gist of it is that "eyed3.core:DEBUG: File mime-type: application/x-font-gdos" is not in the list of mp3 mime-types, so eyeD3 does not even try to parse this file. If you add that mimetype to the list of mp3 types it will work, but I've not done that yet because I'd rather understand this problem with mp3 detection.

@Nathoufresh
Copy link
Author

Yeah that works! Thanks a lot, your app is awesome.

@nicfit nicfit changed the title AttributeError: 'NoneType' object has no attribute 'initTag' application/x-font-gdos is sometimes returned as a .mp3 mime-type and it not in the list of acceptable types Aug 24, 2019
@nicfit nicfit reopened this Aug 24, 2019
@globau
Copy link

globau commented Sep 15, 2019

eyeD3 calls libmagic without the MAGIC_CONTINUE (keep_going) flag set, so it only sees one of the mime types libmagic detects. The problem is libmagic can return multiple possible mime types.

An mp3 I have is reported as Audio file with ID3 version 2.3.0, contains:GEM GDOS font 1200, ID 0xfbff. With keep_going=False only the mime type for the font is returned - application/x-font-gdos.

eyeD3 should set keep_going=True, split the result on \012- , and check if any of the mime types are supported.

For the file I have which triggers this error, with keep_going=True, self.from_file() returns application/x-font-gdos\012- audio/mpeg\012- application/octet-stream.

http://strike2.org/Techno-Trance-House/ID-T%20-%20Top%20500%20-%20my%20Best%20Of/330%20-%20Moloko%20-%20Sing%20It%20Back.mp3 triggers this issue.

@nicfit
Copy link
Owner

nicfit commented Sep 17, 2019

Thanks for the info @globau . I committed your idea in 4fe25b3 if you want to git it a shot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants