Replaced eyed3 for mutagen for tag parsing

This commit is contained in:
Manuel Cortez 2018-12-24 08:52:48 -06:00
parent 527d4670d4
commit b4adf42644
2 changed files with 11 additions and 6 deletions

View File

@ -9,8 +9,7 @@ requests-oauthlib
future
arrow
yandex.translate
eyed3
python-magic-bin
mutagen
# forked repositories previously found at http://q-continuum.net
git+https://code.manuelcortez.net/manuelcortez/libloader
git+https://code.manuelcortez.net/manuelcortez/platform_utils

View File

@ -4,8 +4,8 @@ this controller will take care of preparing data structures to be uploaded later
"""
import os
import logging
import eyed3
import widgetUtils
from mutagen.id3 import ID3
from wxUI.dialogs import attach as gui
from wxUI.dialogs import selector
from wxUI.menus import attachMenu
@ -69,9 +69,15 @@ class attach(object):
if audio != None:
# Define data structure for this attachment, as will be required by VK API later.
# Let's extract the ID3 tags to show them in the list and send them to VK, too.
audio_tags = eyed3.load(audio)
title = audio_tags.tag.title
artist = audio_tags.tag.artist
audio_tags = ID3(audio)
if "TIT2" in audio_tags:
title = audio_tags["TIT2"].text[0]
else:
title = _(u"Untitled")
if "TPE1" in audio_tags:
artist = audio_tags["TPE1"].text[0]
else:
artist = _(u"Unknown artist")
audioInfo = {"type": "audio", "file": audio, "from": "local", "title": title, "artist": artist}
self.attachments.append(audioInfo)
# Translators: This is the text displayed in the attachments dialog, when the user adds an audio file.