You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
984 B
37 lines
984 B
15 years ago
|
#!/usr/bin/env ruby
|
||
|
#
|
||
|
# Amarok Script for custom scoring
|
||
|
#
|
||
|
# (c) 2006 Gábor Lehel <illissius@gmail.com>
|
||
|
#
|
||
|
# License: GNU General Public License V2
|
||
|
|
||
|
require 'uri'
|
||
|
|
||
|
loop do
|
||
|
args = gets.chomp.split(" ")
|
||
|
|
||
|
case args[0]
|
||
|
when "configure"
|
||
|
msg = 'This script does not require any configuration.'
|
||
|
`dcop amarok playlist popupMessage "#{msg}"`
|
||
|
|
||
|
when "requestNewScore"
|
||
|
url = args[1]
|
||
|
prevscore = args[2].to_f
|
||
|
playcount = args[3].to_i
|
||
|
length = args[4].to_i
|
||
|
percentage = args[5].to_i
|
||
|
reason = args[6]
|
||
|
|
||
|
if( playcount <= 0 ) # not supposed to be less, but what the hell.
|
||
|
newscore = ( prevscore + percentage ) / 2
|
||
|
else
|
||
|
newscore = ( ( prevscore * playcount ) + percentage ) / ( playcount + 1 )
|
||
|
end
|
||
|
|
||
|
system( "dcop", "amarok", "player", "setScoreByPath", URI::decode( url ), newscore.to_s )
|
||
|
end
|
||
|
end
|
||
|
|