Image 01
profile-image

BoredByPolitics

Pete Jewell Peterborough, United Kingdom
Amarok Atom Syndication

Amarok 1.x Scripts by dpino 6 comments

Nice script!

I had to make a couple of changes to the script. The first was helping it find my cookies.txt file. Unfortunately there are two cookies.txt files findable from ~/.mozilla on my system, and it just happened to pick the one that isn't updated. I adjusted the start point to ~/.mozilla/firefox, which fixed the cookies problem.

Secondly, although the file amarok.xml was being generated, and it looked OK, RSS readers were not liking it, mostly refusing to render anything.

I made this change, to add the <? xml ...?> declaration to the head of the file:

Quote:
--- /home/pete/src/atomSyndication/atomSyndication.pl 2007-09-10 23:38:01.000000000 +0100
+++ ./atomSyndication.pl 2007-09-25 22:25:38.000000000 +0100
@@ -25,15 +25,21 @@
use LWP::UserAgent;
use File::Find;

-$username = '';
+$username = 'xxx';
$ATOM_FILE = 'amarok.xml';

$URL = "http://pages.google.com";
$URL_ATOM_FILE = "http://$username.googlepages.com/$ATOM_FILE";

+$XMLDECL = new XML::DOM::XMLDecl;
+$XMLDECL->setVersion("1.0");
+$XMLDECL->setEncoding("UTF-8");
+$XMLDECL->setStandalone("yes");
+
+
$uploadURL = $URL."/upload-file-simple/$username";

-find(\&handleFind, "$ENV{'HOME'}/.mozilla/");
+find(\&handleFind, "$ENV{'HOME'}/.mozilla/firefox/");

sub handleFind {
my $foundFile = $File::Find::name;
@@ -194,11 +200,15 @@
sub GetXML
{
local($url) = @_;
- local($parser, $xmldoc);
+ local($parser, $xmldoc, $xmldecl);

eval {
$parser = XML::DOM::Parser->new();
$xmldoc = $parser->parsefile($url);
+ $xmldecl = $xmldoc->getXMLDecl();
+ if ( $xmldecl == undef ) {
+ $xmldoc->setXMLDecl($XMLDECL);
+ }
};

if ($@) {
@@ -247,10 +257,11 @@
{
local($node);
my $xmldoc = new XML::DOM::Document;
-
+ my $xmldecl= new XML::DOM::XMLDecl;
$feed{'updated'} = &GetTime;
$feed{'id'} = 'urn:uuid:'.Data::UUID->new->create_str;
$node = &ArrayToXML($xmldoc, 'feed', %feed);
+ $xmldoc->setXMLDecl($XMLDECL);
$xmldoc->appendChild($node);

return $xmldoc;
- Sep 25 2007
amarokEspeak

Amarok 1.x Scripts by BoredByPolitics 8 comments

I had a look at that method on my system this evening, but unfortunately all that happens is that espeak pushes the CPU usage to 100% without actually producing any speech (probably a misconfiguration on my Ubuntu 7.04 system). In the end I give up waiting for it to complete, and terminate the process.

Thanks for the suggestion though! - Aug 30 2007
amarokEspeak

Amarok 1.x Scripts by BoredByPolitics 8 comments

I use espeak to generate a .wav file in the /tmp directory, then use aplay to play it, as by default espeak tries to open the /dev/dsp device (which of course is locked when amarok is playing).

I don't have espeak running all the time, just start it to generate the wav file, after which it exits. - Aug 28 2007
amarokEspeak

Amarok 1.x Scripts by BoredByPolitics 8 comments

I've tried a quite a few tracks now, and I think you're right, that Espeak is clearer than festival.

I'm toying with the idea of rewriting the script in python, along with the inclusion of configuration options, so watch this space!

- Aug 28 2007
amarokTalker

Amarok 1.x Scripts by arlindo 1 comment

Good idea! So good that I've pinched it and adapted the script to use espeak instead of festival (which runs fairly slowly on my laptop) - http://www.kde-apps.org/content/show.php?content=65142.

I did wonder about caching the wav files to speed things up. - Aug 27 2007
Amakode

Amarok 1.x Scripts by tobydickenson 48 comments

Great script (after discovering and fixing the lame encoder typo bug).

However, on my system (Ubuntu 7.04) I found that the dcop transcodingFinished message wasn't being picked up correctly by Amarok - it was assuming that the transcoding had failed.

To resolve this I've made a few changes to incorporate the adjusted dcopext.py script, so that shelling out to execute dcop isn't required. Here's the patch (not including dcopext.py - you can get that from http://www.kde-apps.org/content/show.php/Local+Lyrics?content=37981)

Quote:
diff -uN -x '*.pyc' ./amakode/amakode.py /home/pete/.kde/share/apps/amarok/scripts/amakode/amakode.py
--- ./amakode/amakode.py 2007-08-20 03:47:19.000000000 +0100
+++ /home/pete/.kde/share/apps/amarok/scripts/amakode/amakode.py 2007-08-23 22:30:40.000000000 +0100
@@ -2,6 +2,10 @@

############################################################################
# Transcoder for Amarok
+# v1.2 (Pete Jewell boredbypolitics@gmail.com)
+# - Refixed typo in lame encoder (missing a comma)
+# - Added dcopext.py and associated code to replace
+# existing dcop code.
# v1.1
# - Fixed typo in lame encoder (tcuya from kde-apps.org)
# - Made setting maxjobs easier, although Amarok doesn't appear to issue
@@ -52,6 +56,7 @@
import urllib
import urlparse
import re
+from dcopext import DCOPClient, DCOPApp

class QueueMgr:
queuedjobs = []
@@ -103,7 +108,7 @@

# Programs used to encode (from a wav stream)
encode = {}
- encode["mp3"] = ["lame", "--abr", "128", "-" "-"]
+ encode["mp3"] = ["lame", "--abr", "128", "-", "-"]
encode["ogg"] = ["oggenc", "-q", "2", "-"]
encode["mp4"] = ["faac", "-o", "/dev/stdout", "-"]
encode["m4a"] = encode["mp4"]
@@ -228,7 +233,7 @@
newjob = TranscodeJob(args[1], args[2])
except:
log.debug("Can't create transcoding job")
- os.system("dcop amarok mediabrowser transcodingFinished " + re.escape(args[1]) + "\"\"")
+ ok, void = transcodingFinished(re.escape(args[1]), "")

self.queue.add(newjob)

@@ -236,10 +241,10 @@
""" Report to amarok that the job is done """
if (job.errormsg == None):
log.debug("Job " + job.inurl + " completed successfully")
- os.system("dcop amarok mediabrowser transcodingFinished " + re.escape(job.inurl) + " " + re.escape(job.outurl))
+ ok, void = transcodingFinished(job.inurl, job.outurl)
else:
log.debug("Job " + job.inurl + " failed - " + job.errormsg)
- os.system("dcop amarok mediabrowser transcodingFinished " + re.escape(job.inurl) + "\"\"")
+ ok, void = transcodingFinished(job.inurl, "")

def quit(self):
log.debug("quitting")
@@ -284,11 +289,23 @@
""" Report to amarok that the job is done """
if (job.errormsg == None):
log.debug("Job " + job.inurl + " completed successfully")
- log.debug("dcop amarok mediabrowser transcodingFinished " + job.inurl + " " + job.outurl)
+ ok, void = transcodingFinished(job.inurl, job.outurl)
else:
log.debug("Job " + job.inurl + " failed - " + job.errormsg)
- log.debug("dcop amarok mediabrowser transcodingFinished " + job.inurl + "\"\"")
+ ok, void = transcodingFinished(job.inurl, "")
+
+def initDCOP(dcopClient=None):
+ if dcopClient is None:
+ dcopClient = DCOPClient()
+ dcopClient.attach()
+
+ return DCOPApp('amarok',dcopClient)

+# Global Variables
+
+amarok = initDCOP()
+transcodingFinished = amarok.mediabrowser.transcodingFinished
+
if __name__ == "__main__":
initLog()
signal.signal(signal.SIGINT, onStop)
- Aug 26 2007