i'm using a git snapshot of amarok and when this script is enabled, the currently playing song gets deleted.
since the script is really short, i guess the bug lies within amarok, but you should be careful as long as this bug exists.
https://bugs.kde.org/show_bug.cgi?id=238584
Wow, this is unexpected.
The only files related stuff is checking for file existence and running moodbar...
So I guess it's either in the amarok or in moodbar...
Do you have the latest dev. ver. of moodbar too?
I'm one of the Amarok bug triagers.
I tried hard to reproduce the bug, but I was not able to. So I have no idea what is causing this or if it's an false alarm.
Two other things:
1. That script implements functionality which most users want to see in Amarok. You should really move it to Amarok Git. I would then also help to add a "create all .mood files for the collection" tool.
2. It fails if the file name contains more than one dot. The regexp to determine the name of the mood file cuts the path at the very first dot.
Thanks for the bug report - fixed.
I don't think it's good enough solution to move it to amarok src, it's more like a hack. The mood files should be in .kde4 dir somewhere in my taste, and mood files generation shouldn't happen when a track starts to play but on collection update. So there is some work to do...
We want to encourage all script authors to move the sources to our git. There is a special playground directory for stuff that is not part of the default distribution.
Apart from that: your script is already as good as Amarok 1.4 was in the area of creating .mood files. And it is definitely an improvement of the current situation in Amarok 2.
If it was in git I would help to create a "calculate moods for all files in collection" tool with it. ^^
i think i found the cause.
path.replace(/^(.*)\/(.*?)\.(.*?)$/, "$1\/.$2.mood");
just returns the original path causing moodbar to overwrite/delete the input file.
so why am i the only one this is happening to?
Very weird...
I don't think it's qt version issue.
Can you post the filename that is being deleted, I think it might be something escaping related... Hard to believe though.
it happens to pretty every file, but here are two examples:
/home/daniel/Musik/Sammlung/Trance/Verschiedene Interpreten/Bravo Hits Zima 2007/1 - 07 - Starting Rock - Don't Go.mp3
/home/daniel/Musik/Neu/Amy MacDonald - This Is The Life/09 A Wish for Something More.mp3
i had a closer look at the regex and the use of a * followed by a ? doesn't make sense to me, i tested the regex with kwrite (if it also couldn't handle it) and here the replace buttons are grayed out as long as *? is in the search field.
^(.*)\/(.*)\.(.*)$
does the job.
? after * is making sure this is not greedy selection, it's just to make sure the extension part of the filename is taken right. It should work without it too...
Not sure why regex doesn't work for you there.
Can you add this line:
Amarok.alert(mood);
after the line with regex and check what it shows?
what do you mean by greedy?
your regex reads like you want to also catch files without extensions, but that would be ^(.*)\/(.*)(\.(.*))?$
i might be wrong, but i think that *? is simply invalid and that newer qt versions can handle this error while older versions can't.
an alert in moodbar generator is unnecessary, i catched all parameters by a wrapper script to moodbar, this is how i figured out, that the regex replace failed.
it works fine with the regex, i wrote in the last post. and if you can explain what you wanted to do with the ? we should be able to add this, too.
ok.
What amarok expects is the mood file for 'filename.ext' as '.filename.mood'.
So what that line does is return the mood filename.
This regex can't return the same filename as it always appends the original filename with 'mood' and prepends with '.', even if it doesn't parse the filename right for some reason.
For reference on greedy and lazy '*' take a look here:
http://www.regular-expressions.info/reference.html
search for 'lazy star', one before it is the greedy star.
It's not a bug, it's a part of regex, and I really don't think QT removed support for it :)
Hi,
i had change a little bit your code, in this way if a .mood file exists the script doesn't recreate it.
here is the code:
if (!QFile.exists(mood)) {
args = ["-o", mood, path];
QProcess.startDetached("moodbar",args);
}
Ratings & Comments
20 Comments
Please use this one: http://kde-apps.org/content/show.php?action=content&content=135625&PHPSESSID=69aa9cc0c1c0dd1cb15cbe6a1047a00d
Any news on the file deletion issue? I really don't dare to use this as long as that is not clearly out of the way.
i'm using a git snapshot of amarok and when this script is enabled, the currently playing song gets deleted. since the script is really short, i guess the bug lies within amarok, but you should be careful as long as this bug exists. https://bugs.kde.org/show_bug.cgi?id=238584
Wow, this is unexpected. The only files related stuff is checking for file existence and running moodbar... So I guess it's either in the amarok or in moodbar... Do you have the latest dev. ver. of moodbar too?
no, moodbar is version 0.1.2 and it works without problems. it must be an amarok bug. but whoever's fault it is, it's causing damage.
I'm one of the Amarok bug triagers. I tried hard to reproduce the bug, but I was not able to. So I have no idea what is causing this or if it's an false alarm. Two other things: 1. That script implements functionality which most users want to see in Amarok. You should really move it to Amarok Git. I would then also help to add a "create all .mood files for the collection" tool. 2. It fails if the file name contains more than one dot. The regexp to determine the name of the mood file cuts the path at the very first dot.
Thanks for the bug report - fixed. I don't think it's good enough solution to move it to amarok src, it's more like a hack. The mood files should be in .kde4 dir somewhere in my taste, and mood files generation shouldn't happen when a track starts to play but on collection update. So there is some work to do...
We want to encourage all script authors to move the sources to our git. There is a special playground directory for stuff that is not part of the default distribution. Apart from that: your script is already as good as Amarok 1.4 was in the area of creating .mood files. And it is definitely an improvement of the current situation in Amarok 2. If it was in git I would help to create a "calculate moods for all files in collection" tool with it. ^^
I'll try to find time to move it there soon, seems like a lot of fun anyway :)
Enjoy :) http://gitorious.org/~devenv/amarok/devenvs-moodbar_generator_script Added you as collaborator, I guessed it's the same username...
i think i found the cause. path.replace(/^(.*)\/(.*?)\.(.*?)$/, "$1\/.$2.mood"); just returns the original path causing moodbar to overwrite/delete the input file. so why am i the only one this is happening to?
Interesting. I added a lot of debug and it works here... Different Qt versions? 4.6.2 here.
i have qt 4.5.3
Very weird... I don't think it's qt version issue. Can you post the filename that is being deleted, I think it might be something escaping related... Hard to believe though.
it happens to pretty every file, but here are two examples: /home/daniel/Musik/Sammlung/Trance/Verschiedene Interpreten/Bravo Hits Zima 2007/1 - 07 - Starting Rock - Don't Go.mp3 /home/daniel/Musik/Neu/Amy MacDonald - This Is The Life/09 A Wish for Something More.mp3 i had a closer look at the regex and the use of a * followed by a ? doesn't make sense to me, i tested the regex with kwrite (if it also couldn't handle it) and here the replace buttons are grayed out as long as *? is in the search field. ^(.*)\/(.*)\.(.*)$ does the job.
? after * is making sure this is not greedy selection, it's just to make sure the extension part of the filename is taken right. It should work without it too... Not sure why regex doesn't work for you there. Can you add this line: Amarok.alert(mood); after the line with regex and check what it shows?
what do you mean by greedy? your regex reads like you want to also catch files without extensions, but that would be ^(.*)\/(.*)(\.(.*))?$ i might be wrong, but i think that *? is simply invalid and that newer qt versions can handle this error while older versions can't. an alert in moodbar generator is unnecessary, i catched all parameters by a wrapper script to moodbar, this is how i figured out, that the regex replace failed. it works fine with the regex, i wrote in the last post. and if you can explain what you wanted to do with the ? we should be able to add this, too.
ok. What amarok expects is the mood file for 'filename.ext' as '.filename.mood'. So what that line does is return the mood filename. This regex can't return the same filename as it always appends the original filename with 'mood' and prepends with '.', even if it doesn't parse the filename right for some reason. For reference on greedy and lazy '*' take a look here: http://www.regular-expressions.info/reference.html search for 'lazy star', one before it is the greedy star. It's not a bug, it's a part of regex, and I really don't think QT removed support for it :)
Hi, i had change a little bit your code, in this way if a .mood file exists the script doesn't recreate it. here is the code: if (!QFile.exists(mood)) { args = ["-o", mood, path]; QProcess.startDetached("moodbar",args); }
Nice one, updated. Any idea how to make it update mood files before the next track? I don't think it always works for new tracks.