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

How do I get the database's url parameter in a convient way?

Tags: None
(comma "," separated)
imported-l3u
Registered Member
Posts
6
Karma
0
Hi :-)

I wrote a Python script that logs all songs listened to an SQLite database. See http://kde-apps.org/content/show.php?content=82041 . I fetch the url of the song just listened by doing
stdin = stdin.strip()
foo, url, prevscore, playcount, length, percentage, reason = stdin.split(" ")
Then I query the database via DCOP to get the data I want by
dcop amarok collection query ...
where I do something like
SELECT ... FROM ... WHERE tags.url="..."
I process the url parameter with
url = urllib.unquote(url)
url = url.replace('/home', '.')
That worked fine for me, I had all my music in ~/Musik/. To be able to also query music outside of ~, I added
if url[0] != ".":
url = ".%s" % url
and it worked for music in some subdirectory of /var. But it seems that this is still not working for all cases ... at least, a user posted an error on kde-apps (see above). I can't reproduce it and I did not find a howto to get that tag url parameter out of the url parameter passed to the scripts in a documentation or something like this.

It's a bit confusing what Amarok does ...

/home/tobias/Musik/Alben/Clawfinger/1993 Deaf Dumb Blind/07. Warfair.mp3 is stored as
./tobias/Musik/Alben/Clawfinger/1993 Deaf Dumb Blind/07. Warfair.mp3 ("/home" is replaced by ".", 5 subdirectories)

/var/vm/shared/Last.fm/Autopilot Off/Looking Up/Pivot.mp3 seems to referenced as
./var/vm/shared/Last.fm/Autopilot Off/Looking Up/Pivot.mp3 (here's just a "." put before the string -- 6 subdirectories)

and the user reporting the bug has a file named
/media/mp3/Singles/Alternative Electronic/St. Germain - Sure Thing.mp3 that is stored as
./Singles/Alternative Electronic/St. Germain - Sure Thing.mp3 in the database (the first two directories replaced by "." and just two subdirectories left -- Huh?!)

I just don't get it ;-)

So ... it would be very kind if anybody could explain it to me :-)

Greetings, Tobias

Last edited by imported-l3u on Mon Jun 30, 2008 9:57 pm, edited 1 time in total.
User avatar
dangle_wtf
Moderator
Posts
1252
Karma
0
Check how you have selected the directories in Amarok's collection config page - whether you have higher-level directories selected should correlate to how many directory levels are stored in the db.


"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"
imported-l3u
Registered Member
Posts
6
Karma
0
Okay, that sounds meaningful ... but how can my script know what the user has selected? I should not only work for me but for everybody ...

I think I soved the problem: there's a DCOP function collection relativePath that seems to do the trick. Thanks anyway :-)

Last edited by imported-l3u on Wed Jul 02, 2008 11:02 am, edited 1 time in total.


Bookmarks



Who is online

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