This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Need help creating a script for extended statistics

Tags: None
(comma "," separated)
Nukm
Registered Member
Posts
5
Karma
0
i like the collection statistics, but imho they miss some interesting things. so i thought, why not just extend them...
as i learned java/c at university i thought it couldnt be so hard to just use the current statistics functions as a template and change some things in them. for all i know so far its not going to be so easy...
first thing is: as i dont know ruby or python, i wondered if i could also use java/c ? the wiki states "This makes it possible to write scripts in almost any programming language, like Ruby, Python or bash scripting." so could i use java/c ? i didnt find any scripts / templates for these languages, so guess its either not possible or its just not suited at all. so learning some ruby is the best solution?
can i use the c++ code i found in src/statistics.cpp as a basis for my script? (though i dont understand much of the interesting parts from first view)
btw, is it even possible to just add another entry in the collection statistics window?
are there any templates or simple scripts that do something similar? because the provided script templates almost dont help at all :(
thinking about it, i also need a good documentation for the database stuff, any recommendationsare welcome

all in all what i want to do i quite simple, but i need to learn so much new stuff, and tbh i dont know where to start and there is no guide to help me out. so please tell me, what is the the best way to start with scripting? how did you learn to do so?
User avatar
markey
KDE Developer
Posts
2286
Karma
3
OS
We strongly recommend to use a scripting language instead of compiled languages, especially if you plan to publish your Amarok Script. This is because scripted programs are automatically portable on almost any platform, while compiled binaries are not.

Also, Ruby is a fantastic language and really easy to learn. Shouldn't hurt to broaded your horizon a bit ;)

Last edited by Anonymous on Thu Jan 17, 2008 1:48 pm, edited 1 time in total.


--
Mark Kretschmann - Amarok Developer
User avatar
dangle_wtf
Moderator
Posts
1252
Karma
0
plus it's already a dependancy of Amarok anyway :D


"There are two theories to arguing with women. Neither one works."
.
If men could get pregnant, we'd learn the true meaning of "screaming nancyboy wuss"
thomas
Registered Member
Posts
4
Karma
0
Hi,

It's fairly easy with just a simple bash script and some dcop calls.

Here are some amarokscripts I made myself. Maybe this could help you.

Collection Statistics
Code: Select all
#!/bin/sh

# Prints the amaroK collection statistics , by Thomas Decoster.


COLLECTION_TRACKS=$(dcop amarok collection totalTracks);
COLLECTION_ALBUMS=$(dcop amarok collection totalAlbums);
COLLECTION_ARTISTS=$(dcop amarok collection totalArtists);
COLLECTION_GENRES=$(dcop amarok collection totalGenres);

echo "Thomas has ${COLLECTION_TRACKS} tracks on ${COLLECTION_ALBUMS} albums by ${COLLECTION_ARTISTS} artists over ${COLLECTION_GENRES} genres in his music collection! [amaroK collection statistics]"


Now playing
Code: Select all
#!/bin/sh

# Prints the currently playing song.



TITLE=$(dcop amarok player title);
ALBUM=$(dcop amarok player album);
ARTIST=$(dcop amarok player artist);
YEAR=$(dcop amarok player year);
GENRE=$(dcop amarok player genre);
TYPE=$(dcop amarok player type);
BITRATE=$(dcop amarok player bitrate);
TIME=$(dcop amarok player totalTime);
CURTIME=$(dcop amarok player currentTime);

echo "np: ${TITLE} [${CURTIME}/${TIME}] - ${ALBUM} - ${YEAR} by ${ARTIST} | ${GENRE} | ${TYPE} | ${BITRATE}" kbps


And there are many other examples to look at, have a look at kde-apps.org ;-)

Greetz

Thomas
Nukm
Registered Member
Posts
5
Karma
0
Mark Kretschmann wrote:Also, Ruby is a fantastic language and really easy to learn. Shouldn't hurt to broaded your horizon a bit ;)

you may be right, ruby is used for so many project anyway, cant hurt to learn something new. just hope i an find the time... but i`ll have a look

thomas wrote:It's fairly easy with just a simple bash script and some dcop calls.
Here are some amarokscripts I made myself. Maybe this could help you.
[..]
And there are many other examples to look at, have a look at kde-apps.org ;-)


well thanks, although this looks simply, it isn exactly anything i can use. i wan to create some _new_ statistics, you just read out the statistics amarok already created, thats a big difference... i already had a look at kde-apps but except maybe music-diary (or whatever it was exactly called) i couldnt find anything usefull. i wanna have things like 'total lenght of unplayed songs' and so on. but well, i will have to start with something ssimpler anyway, will try to convert your code to some working ruby scritpt and then get on with something more complex

Last edited by Nukm on Sat Jan 19, 2008 1:40 pm, edited 1 time in total.


Bookmarks



Who is online

Registered users: abc72656, Bing [Bot], daret, Google [Bot], Sogou [Bot], Yahoo [Bot]