Bug 141885

Summary: [PATCH] support for meta lyrics scripts
Product: [Applications] amarok Reporter: Sergio Pistone <sergio_pistone>
Component: Context ViewAssignee: Amarok Developers <amarok-bugs-dist>
Status: RESOLVED FIXED    
Severity: wishlist    
Priority: NOR    
Version: 1.4.5   
Target Milestone: ---   
Platform: Gentoo Packages   
OS: Linux   
Latest Commit: Version Fixed In:
Attachments: mentioned patch
patch against amarok-1.4.5; fixes bug in the previous one

Description Sergio Pistone 2007-02-18 20:33:54 UTC
Version:           1.4.5 (using KDE KDE 3.5.6)
Installed from:    Gentoo Packages

Currently, the site, site_url and add_url parameters are all read from the script spec file. this doesn't allow a script invoking different sites to provide valid values since they are all site dependant. I've attached a patch that makes Amarok first search this parameters in the received XML and fallback to the current method for any not found. This way current script can still run without problems, and "meta" lyrics script can do it as well.
Next version of Wiki-Lyrics would work as one script that can handle different sites (instead of listing multiple scripts), but won't work correctly without this.
Comment 1 Sergio Pistone 2007-02-18 20:34:54 UTC
Created attachment 19732 [details]
mentioned patch
Comment 2 Sergio Pistone 2007-02-19 00:14:18 UTC
Created attachment 19738 [details]
patch against amarok-1.4.5; fixes bug in the previous one
Comment 3 Dan Meltzer 2007-03-05 17:52:42 UTC
SVN commit 639672 by dmeltzer:

Allow for lyrics scripts to work as meta_lyrics scripts, with the ability to specify site, site_url, and add_url as returned paramaters in the fetched lyrics.  Still falls back to parameters set in the .spec file.
Patch by Sergio pistone. <sergio_pistone@yahoo.co.ar>
BUG: 141885


 M  +3 -0      ChangeLog  
 M  +14 -10    src/contextbrowser.cpp  


--- branches/stable/extragear/multimedia/amarok/ChangeLog #639671:639672
@@ -7,6 +7,9 @@
   CHANGES:
     * First rating star now lets you toggle between no rating, half a star,
       and one full star.
+    * Allow for lyrics scripts to specifiy site, site_url, and add_url from
+    within the script.  This will allow for "meta lyrics" scripts. .Patch by
+    Sergio Pistone <sergio_pistone@yahoo.com.ar> (BR 141885)
 
   BUGFIXES:
     * Fix detection of vfat devices on FreeBSD. (BR 141614)
--- branches/stable/extragear/multimedia/amarok/src/contextbrowser.cpp #639671:639672
@@ -3372,13 +3372,17 @@
     KConfig spec( sm->specForScript( sm->lyricsScriptRunning() ), true, false );
     spec.setGroup( "Lyrics" );
 
-    m_lyricAddUrl = spec.readPathEntry( "add_url" );
-    m_lyricAddUrl.replace( "MAGIC_ARTIST", KURL::encode_string_no_slash( EngineController::instance()->bundle().artist() ) );
-    m_lyricAddUrl.replace( "MAGIC_TITLE", KURL::encode_string_no_slash( EngineController::instance()->bundle().title() ) );
-    m_lyricAddUrl.replace( "MAGIC_ALBUM", KURL::encode_string_no_slash( EngineController::instance()->bundle().album() ) );
-    m_lyricAddUrl.replace( "MAGIC_YEAR", KURL::encode_string_no_slash( QString::number( EngineController::instance()->bundle().year() ) ) );
+    if ( el.attribute( "add_url" ).isEmpty() )
+    {
+        m_lyricAddUrl = spec.readPathEntry( "add_url" );
+        m_lyricAddUrl.replace( "MAGIC_ARTIST", KURL::encode_string_no_slash( EngineController::instance()->bundle().artist() ) );
+        m_lyricAddUrl.replace( "MAGIC_TITLE", KURL::encode_string_no_slash( EngineController::instance()->bundle().title() ) );
+        m_lyricAddUrl.replace( "MAGIC_ALBUM", KURL::encode_string_no_slash( EngineController::instance()->bundle().album() ) );
+        m_lyricAddUrl.replace( "MAGIC_YEAR", KURL::encode_string_no_slash( QString::number( EngineController::instance()->bundle().year() ) ) );
+    }
+    else
+        m_lyricAddUrl = el.attribute( "add_url" );
 
-
     if ( el.tagName() == "suggestions" )
     {
 
@@ -3408,10 +3412,10 @@
         lyrics = el.text();
         lyrics.replace( "\n", "<br/>\n" ); // Plaintext -> HTML
 
-        const QString title      = el.attribute( "title" );
-        const QString artist     = el.attribute( "artist" );
-        const QString site       = spec.readEntry( "site" );
-        const QString site_url   = spec.readEntry( "site_url" );
+        const QString title    = el.attribute( "title" );
+        const QString artist   = el.attribute( "artist" );
+        const QString site     = el.attribute( "site" ).isEmpty() ? spec.readEntry( "site" ) : el.attribute( "site" );
+        const QString site_url = el.attribute( "site_url" ).isEmpty() ? spec.readEntry( "site_url" ) : el.attribute( "site_url" );
 
         lyrics.prepend( "<font size='2'><b>\n" + title + "</b><br/><u>\n" + artist+ "</font></u></font><br/>\n" );