(no commit message)
[paste/456.git] / 0-patch.diff
index 92cd9ff4dae5a165c360976c02f9ee03909dc7dd..a03ea811030fd9737c4113abcc25c03a73ddd2d0 100644 (file)
@@ -1,42 +1,53 @@
-diff --git plugins/lyrics/lyrics.py plugins/lyrics/lyrics.py\r
-index 13124b3..6bff657 100644\r
---- plugins/lyrics/lyrics.py\r
-+++ plugins/lyrics/lyrics.py\r
-@@ -32,6 +32,7 @@ import urllib.request\r
- import rb\r
- from gi.repository import Gtk, Gio, GObject, Peas\r
- from gi.repository import RB\r
-+from gi.repository import Gst, GstPbutils\r
\r
- import LyricsParse\r
- from LyricsConfigureDialog import LyricsConfigureDialog\r
-@@ -146,6 +147,29 @@ class LyricGrabber(object):\r
-        def search_lyrics(self, callback, cache_only=False):\r
-                self.callback = callback\r
\r
-+               #location = self.entry.get_string(RB.RhythmDBPropType.MOUNTPOINT)\r
-+               location = self.entry.get_playback_uri()\r
-+               print("discovering %s" % location)\r
-+               self.discoverer = GstPbutils.Discoverer(timeout=Gst.SECOND*1)\r
-+               info = self.discoverer.discover_uri(location)\r
-+               tags = info.get_tags()\r
-+               print("abc")\r
-+               if tags is not None:\r
-+                       def fetags (list, tag):\r
-+                               print("tag: %s" % tag)\r
-+                       tags.foreach(fetags)\r
-+                       (found, text) = tags.get_string_index('lyrics', 0)\r
-+                       (found, text) = tags.get_string_index('extended-comment', 0)\r
-+                       if found:\r
-+                               print("found lyrics tag:\n%s" % text)\r
-+                               self.callback(text)\r
-+                               return\r
-+                       else:\r
-+                               print("no lyrics tag found")\r
-+               else:\r
-+                       print("no tags found")\r
-+\r
-+               print("abc")\r
-                status = self.verify_lyric()\r
\r
-                if status:\r
+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: