Bug 188813 - Now playing scripts don't work
Summary: Now playing scripts don't work
Status: RESOLVED FIXED
Alias: None
Product: konversation
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Ubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: Konversation Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-04-04 17:03 UTC by hyper_ch
Modified: 2009-12-23 10:33 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Ruby Script (1.67 KB, application/octet-stream)
2009-04-04 17:22 UTC, hyper_ch
Details

Note You need to log in before you can comment on or make changes to this bug.
Description hyper_ch 2009-04-04 17:03:31 UTC
Version:           1.1 (KDE 3.5.10) (using KDE 4.2.2)
OS:                Linux
Installed from:    Ubuntu Packages

I have a strange problem.

I had until yesterday Kubuntu Intrepid 8.10 with KDE 4.2. Then I made a clean install with Kubuntu Jaunty 9.04 and upgraded to KDE 4.2.2 by the PPA packages.

So, on Intrepid I used a ruby script that I used as now playing script because of Amarok 2 [SVN]. This script stopped working for no apparent reason.

However I found an old bash script that could just submit info to konversation fine. I made a simple script that will run inside the ruby script and then post it.

Neither approach worked, although when called each script from the cli (and entered static info for server and channel) they worked fine.

I even downloaded the media script as announced on the konversation portal page. I can say that the media script and ruby script both worked at some stage, but after a restart of konversation they ceased working.

I have no explanation for this, especially when they run from the shell.

Below is the script:






#!/usr/bin/ruby

#appid  = $*[0]
#server  = $*[1]
#target = $*[2]

appid = "konversation"
server = "0"
target = "#konversation"

metadata  = `qdbus org.mpris.amarok /Player GetMetadata 2> /dev/null`.chomp

hash = Hash.new
metadata = metadata.split("\n")
metadata.each do |line|
  key = line.split(": ")[0]
  value = line.split(": ")[1]
  if value.nil?
    value = ""
  end
  hash[key] = value
end

title  = hash["title"]
artist = hash["artist"]
album  = hash["album"]
year   = hash["year"]
streamName = "" #CGI.unescape(`qdbus org.mpris.amarok /Player streamName`.chomp)
version = "" #`qdbus org.mpris.amarok /Player version`.chomp
version = `amarok --version`.match(/^Amarok\:(.+)/i).captures

output = ""

if title.empty?
    output += `qdbus org.mpris.amarok /Player nowPlaying`.chomp
else
    # Strip file extension
    extensions = ".ogg", ".mp3", ".wav", ".flac", ".fla", ".wma", ".mpc", ".oga"
    ext = File.extname( title ).downcase

    if extensions.include?( ext )
        title = title[0, title.length - ext.length]
    end

    if artist.empty?
        output += "'#{title}'"
    else
        output += "'#{title}' by '#{artist}'"
    end

    unless album.empty?
        output += " on '#{album}'"
        output += " (anno: #{year})" unless year == "0" or year.empty?
#        output += "]"
    end

    unless streamName.empty?
        output += " (#{streamName})"
    end

    unless version.empty?
        output += " - [Amarok#{version}]"
    end
end


info = "appid:  #{appid} - server: #{server} - target: #{target}"

f = File.open("ruby.txt", 'w')
f.write(info)
f.close

#puts output
#puts "#{output}"

`dcop konversation irc say #{server} "#{target}" "/me is listening to #{output}"`
Comment 1 hyper_ch 2009-04-04 17:22:14 UTC
Created attachment 32589 [details]
Ruby Script

that's the ruby script as download
Comment 2 hyper_ch 2009-04-04 18:07:55 UTC
In line 67-71 there should be a text file created - I used this to check what happens. The text file gets created when invoked from the cli. However there is no text file created when I try to run this script with alias / exec in konversation.
Comment 3 hyper_ch 2009-04-04 21:28:50 UTC
Ok, I found the culprit.

Konversation does suddenly not like this line anymore:


version = `amarok --version`.match(/^Amarok\:(.+)/i).captures


I commented it out and now it works. However it's still unclear why Kubuntu 8.10 with KDE 4.2 and Amarok 1.1 for KDE 3.5 had no problem with it but Kubuntu 9.04 with KDE 4.2.2 and Amarok 1.1 for KDE 3.5 refuses that one.

IMHO this can be closed.
Comment 4 hyper_ch 2009-12-23 10:12:46 UTC
This can be closed and marked as resolved :)