diff --git a/mopidy/audio/scan.py b/mopidy/audio/scan.py index 49e82182..b9750286 100644 --- a/mopidy/audio/scan.py +++ b/mopidy/audio/scan.py @@ -67,9 +67,11 @@ class Scanner(object): """ if uri[:4] == 'file': duration, seekable, mime = None, None, None + have_audio = False tags = {} try: + tags['tinytag'] = True fname = unquote(uri[7:]).encode('raw_unicode_escape').decode('utf-8') supported = False extensions = ['.mp3', '.oga', '.ogg', '.opus', '.wav', '.flac', '.wma', '.m4b', '.m4a', '.mp4'] @@ -79,19 +81,16 @@ class Scanner(object): break if supported: tag = TinyTag.get(fname, image=False) - if tag.album: tags['album'] = tag.album.rstrip('\0') # album as string - if tag.albumartist: tags['albumartist'] = tag.albumartist.rstrip('\0') # album artist as string - if tag.artist: tags['artist'] = tag.artist.rstrip('\0') # artist name as string - #if tag.audio_offset # number of bytes before audio data begins - if tag.bitrate: tags['bitrate'] = int(tag.bitrate) # bitrate in kBits/s - if tag.disc: tags['disc'] = int(tag.disc.rstrip('\0')) # disk number in album - if tag.disc_total: tags['disc_total'] = int(tag.disc_total.rstrip('\0')) # the total number of discs - duration=int(float(tag.duration) * 1000) # duration of the song in seconds - #if tag.filesize # file size in bytes - if tag.genre: tags['genre'] = tag.genre.rstrip('\0') # genre as string - #if tag.samplerate # samples per second - if tag.title: tags['title'] = tag.title.rstrip('\0') # title of the song - if tag.track: tags['track'] = int(tag.track.rstrip('\0')) # track number as string + if tag.album: tags['album'] = tag.album.rstrip('\0') # album as string + if tag.albumartist: tags['albumartist'] = tag.albumartist.rstrip('\0') # album artist as string + if tag.artist: tags['artist'] = tag.artist.rstrip('\0') # artist name as string + if tag.bitrate: tags['bitrate'] = int(tag.bitrate) # bitrate in kBits/s + if tag.disc: tags['disc'] = int(tag.disc.rstrip('\0')) # disk number in album + if tag.disc_total: tags['disc_total'] = int(tag.disc_total.rstrip('\0')) # the total number of discs + duration = int(float(tag.duration) * 1000) # duration of the song in seconds + if tag.genre: tags['genre'] = tag.genre.rstrip('\0') # genre as string + if tag.title: tags['title'] = tag.title.rstrip('\0') # title of the song + if tag.track: tags['track'] = int(tag.track.rstrip('\0')) # track number as string if tag.track_total: tags['track_total'] = int(tag.track_total.rstrip('\0')) # total number of tracks as string if tag.composer: tags['composer'] = tag.composer.rstrip('\0') #try: diff --git a/mopidy/audio/tags.py b/mopidy/audio/tags.py index 9dfe8ccb..29e6062e 100644 --- a/mopidy/audio/tags.py +++ b/mopidy/audio/tags.py @@ -90,7 +90,8 @@ def convert_tags_to_track(tags): album_kwargs = {} track_kwargs = {} - try: + if not 'tinytag' in tags: + # Using tags from gstreamer track_kwargs['composers'] = _artists(tags, Gst.TAG_COMPOSER) track_kwargs['performers'] = _artists(tags, Gst.TAG_PERFORMER) track_kwargs['artists'] = _artists(tags, Gst.TAG_ARTIST, @@ -135,8 +136,8 @@ def convert_tags_to_track(tags): if album_kwargs.get('name'): track_kwargs['album'] = Album(**album_kwargs) - except: - + else: + # Using tags from TinyTags if 'title' in tags: track_kwargs['name'] = tags['title'] if 'genre' in tags: track_kwargs['genre'] = tags['genre'] if 'track' in tags: track_kwargs['track_no'] = tags['track'] @@ -160,17 +161,10 @@ def convert_tags_to_track(tags): if album_kwargs.get('name'): track_kwargs['album'] = Album(**album_kwargs) - #if 'album' in tags: - # track_kwargs['album'] = Album(name=tags['album']) - if 'artist' in tags: track_kwargs['artists'] = [Artist(name=tags['artist'])] - #for i in track_kwargs: - # if not i == 'image' : print(i, track_kwargs[i]) - - finally: - return Track(**track_kwargs) + return Track(**track_kwargs) def _artists(tags, artist_name, artist_id=None, artist_sortname=None): # Name missing, don't set artist