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

Read Lyrics from USLT ID3 tags if present #26

Closed
zaphodbb opened this issue Jul 23, 2013 · 4 comments
Closed

Read Lyrics from USLT ID3 tags if present #26

zaphodbb opened this issue Jul 23, 2013 · 4 comments

Comments

@zaphodbb
Copy link

Hi DMO60,
I am assuming your code only pulls from the internet, not from ID3 (If I'm mistaken there, sorry). I see you opened an issue to write Lyrics to ID3 which would be great. Here's the code I'd written to pull lyrics from ID3 tags using mutagen. I'd love to see an option where it pulls from id3 tags if they are present. Could be expanded to pull from the internet and write back to id3 tags if either USLT is not present or if you know they lyrics are not right and want to correct them (maybe a fix lyrics button). I started writing this then found your plugin which already has most of what I was trying to accomplish.

from mutagen.mp3 import MP3
from mutagen.id3 import ID3NoHeaderError
from mutagen.id3 import ID3, TIT2, TALB, TPE1, TPE2, COMM, USLT, TCOM, TCON, TDRC

def refresh_lyrics(self, sp, entry):
    shell = self.object
    file = ""
    try:
        file = entry.get_playback_uri()
    except:
        self.textbuffer.set_text("Nothing Playing")
        pass
    path = file
    path = re.sub("^file:\/\/","",path)
    path = re.sub("%20"," ",path)
    tags = ID3(path)
    lyrics = USLT()

    try:
        lyrics = tags.getall("USLT")
    except:
        self.textbuffer.set_text("No USLT Tag")

    try:
        self.textbuffer.set_text(lyrics[0].text)
    except:
        self.textbuffer.set_text("No Lyrics")
@timoloewe
Copy link
Owner

Hi,

great work, thank you very much! Writing and reading from audio tags (not only mp3, but also e.g. vorbis) is definitely one of the next things I will implement.

Unfortunately, I'm currently busy with writing university exams and thesis and I'm not sure, when I will find some time for doing that. Maybe not before October I fear, but we'll see...

If you don't want to wait that long, you can try to implement it yourself and send me a pull request. I would suggest to add it just as an additional lyrics source alongside the internet sites and the local cache file.

Otherwise, be patient :) I will definitely add this functionality and your code helps me to get started. Thanks!

@zaphodbb
Copy link
Author

Hi Timo,
I definitely understand the delay. I did download your source and start looking it over today. I did start to implement as a new lyric source. I'm rather new to python so it'll probably take a bit to get it all tied in. Will update you when I have progress worth mentioning. For me, it's the wife and kids taking all of the time.

Thanks,
Sean

On Jul 23, 2013, at 2:50 PM, Timo Loewe notifications@github.com wrote:

Hi,

great work, thank you very much! Writing and reading from audio tags (not only mp3, but also e.g. vorbis) is definitely one of the next things I will implement.

Unfortunately, I'm currently busy with writing university exams and thesis and I'm not sure, when I will find some time for doing that. Maybe not before October I fear, but we'll see...

If you don't want to wait that long, you can try to implement it yourself and send me a pull request. I would suggest to add it just as an additional lyrics source alongside the internet sites and the local cache file.

Otherwise, be patient :) I will definitely add this functionality and your code helps me to get started. Thanks!


Reply to this email directly or view it on GitHub.

@zaphodbb
Copy link
Author

Hi Timo,
I think I have it all working now. Added config options to allow saving
to cache, saving to id3 or both. All of the save options now check if it
should save to cache or Id3 or both. right now it's limited to English
language codes. There is also a menu option for "Save lyrics to ID3".
Everything seems to be working.

Playing a new song that has USLT ID3 tags loads the ID3 tags and stops.

Playing a song with no USLT tag searches until it finds lyrics. From
there, hitting Save lyrics to ID3 successfully writes to the file.

Playing a song with a bad USLT stops after loading the USLT but then
finding the correct lyrics and hitting "save lyrics to id3" erases the bad
lyrics and adds the new ones.

It's completely meeting my needs now. Thanks for all of your work on
the original plugin, you obviously put a lot into it.

Sean

On Wed, Jul 24, 2013 at 12:03 AM, Sean Mullen mullens101@gmail.com wrote:

One last thing for today, then I'll leave you alone for a while. I'm
happy to say that I have reading of ID3 USLT tags from MP3s working. My
entire collection is MP3 with ID3 and USLT so that's obviously what I'm
working on first. Tomorrow I'm going to try to add a menu option for "Save
Lyrics to ID3 Tag" and see if I can get that working.

Sean

On Tue, Jul 23, 2013 at 10:52 PM, Sean Mullen mullens101@gmail.comwrote:

OK, nevermind, I'm apparently an idiot. after wasting an hour or so, I
figured it out.

On Tue, Jul 23, 2013 at 10:45 PM, Sean Mullen mullens101@gmail.comwrote:

Timo, quick question, I'm going about nuts here on the most basic point
... I'm trying to edit "in place" in my
~/.local/share/rhythmbox/plugins/lLyrics folder. I've created
ID3LyricsParser.py (for now, just copied External.py to ID3LyricsParser.py)
and added "import ID3LyricsParser" into lLyrics.py.

When I run rhythmbox, all of the modules in this folder load except the
new one and I get "No module named ID3LyricsParser" ... the py file is
there, all other modules are loading ... any idea why the new module file
would not load?

On Tue, Jul 23, 2013 at 8:25 PM, Sean Mullen mullens101@gmail.comwrote:

Hi Timo,
I definitely understand the delay. I did download your source and
start looking it over today. I did start to implement as a new lyric
source. I'm rather new to python so it'll probably take a bit to get it
all tied in. Will update you when I have progress worth mentioning. For
me, it's the wife and kids taking all of the time.

Thanks,
Sean

On Jul 23, 2013, at 2:50 PM, Timo Loewe notifications@github.com
wrote:

Hi,

great work, thank you very much! Writing and reading from audio tags
(not only mp3, but also e.g. vorbis) is definitely one of the next things I
will implement.

Unfortunately, I'm currently busy with writing university exams and
thesis and I'm not sure, when I will find some time for doing that. Maybe
not before October I fear, but we'll see...

If you don't want to wait that long, you can try to implement it
yourself and send me a pull request. I would suggest to add it just as an
additional lyrics source alongside the internet sites and the local cache
file.

Otherwise, be patient :) I will definitely add this functionality and
your code helps me to get started. Thanks!


Reply to this email directly or view it on GitHubhttps://github.com//issues/26#issuecomment-21436978
.

@timoloewe
Copy link
Owner

See #23 for any updates please.

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

No branches or pull requests

2 participants