X-Git-Url: https://git.cweiske.de/paste/456.git/blobdiff_plain/586948b102e7dbd95f608ee4cf305ffbbd0d1ab3..4ffe2835ff0bb834b50210f21a72b4c230941e95:/0-patch.diff diff --git a/0-patch.diff b/0-patch.diff index 92cd9ff..a03ea81 100644 --- a/0-patch.diff +++ b/0-patch.diff @@ -1,42 +1,53 @@ -diff --git plugins/lyrics/lyrics.py plugins/lyrics/lyrics.py -index 13124b3..6bff657 100644 ---- plugins/lyrics/lyrics.py -+++ plugins/lyrics/lyrics.py -@@ -32,6 +32,7 @@ import urllib.request - import rb - from gi.repository import Gtk, Gio, GObject, Peas - from gi.repository import RB -+from gi.repository import Gst, GstPbutils - - import LyricsParse - from LyricsConfigureDialog import LyricsConfigureDialog -@@ -146,6 +147,29 @@ class LyricGrabber(object): - def search_lyrics(self, callback, cache_only=False): - self.callback = callback - -+ #location = self.entry.get_string(RB.RhythmDBPropType.MOUNTPOINT) -+ location = self.entry.get_playback_uri() -+ print("discovering %s" % location) -+ self.discoverer = GstPbutils.Discoverer(timeout=Gst.SECOND*1) -+ info = self.discoverer.discover_uri(location) -+ tags = info.get_tags() -+ print("abc") -+ if tags is not None: -+ def fetags (list, tag): -+ print("tag: %s" % tag) -+ tags.foreach(fetags) -+ (found, text) = tags.get_string_index('lyrics', 0) -+ (found, text) = tags.get_string_index('extended-comment', 0) -+ if found: -+ print("found lyrics tag:\n%s" % text) -+ self.callback(text) -+ return -+ else: -+ print("no lyrics tag found") -+ else: -+ print("no tags found") -+ -+ print("abc") - status = self.verify_lyric() - - if status: +diff --git a/plugins/lyrics/lyrics.py b/plugins/lyrics/lyrics.py +index 13124b3..7333f2f 100644 +--- a/plugins/lyrics/lyrics.py ++++ b/plugins/lyrics/lyrics.py +@@ -32,6 +32,7 @@ import urllib.request + import rb + from gi.repository import Gtk, Gio, GObject, Peas + from gi.repository import RB ++from gi.repository import Gst, GstPbutils + + import LyricsParse + from LyricsConfigureDialog import LyricsConfigureDialog +@@ -142,10 +143,39 @@ class LyricGrabber(object): + + def verify_lyric(self): + return os.path.exists(self.cache_path) ++ ++ ++ def lyric_from_tag(self): ++ """ ++ Extract lyrics from the file meta data (tags) ++ Currently supported formats: ++ - ogg/vorbis files with "LYRICS" tag ++ """ ++ location = self.entry.get_playback_uri() ++ print("discovering %s" % location) ++ self.discoverer = GstPbutils.Discoverer(timeout=Gst.SECOND*1) ++ info = self.discoverer.discover_uri(location) ++ tags = info.get_tags() ++ if tags is None: ++ return ++ ++ def fetags (list, tag): ++ print("tag: %s" % tag) ++ tags.foreach(fetags) ++ for i in range(tags.get_tag_size("extended-comment")): ++ (exists, value) = tags.get_string_index("extended-comment", i) ++ if exists and value.startswith("LYRICS"): ++ text = value.replace("LYRICS=", "") ++ return text + + def search_lyrics(self, callback, cache_only=False): + self.callback = callback +- ++ ++ text = self.lyric_from_tag() ++ if text is not None: ++ self.callback(text) ++ return ++ + status = self.verify_lyric() + + if status: