CopyCover (amaroK Script)

Amarok 1.x Scripts

Source (link to git-repo or to original if based on someone elses unmodified work): Add the source-code for this project on opencode.net

2
5 .0
Description:

Copy the cover of current playing track to the song's dir. Does not overwrite
existing images in this folder. The filenames can be configured with the
"Configure" dialog. By default, it's the album's name, with spaces replaced
by underscores.

An "offline" version is also included. If you have amaroK >= 1.2.3,
launch it and run the script on the command line. It will find all the downloaded covers and copy them in the right directory, just as the amarok plugin would have done. It also creates the desktop files.
Make sure you first run the script with the "-d" option (debug mode), in which
the actions will only be printed, not commited. A --help option is available.
AmaroK >= 1.2.3 and python >= 2.3 are required for this offline version.

The copycover-offline.py and addcoverdirs.sh scripts are NOT meant to be run through Amarok's script manager.
Last changelog:

12 years ago

ChangeLog:
Version: 1.9 Date: 2007/10/21
- fix queries when the database is in MySQL
- tell the session manager not to restart the script on login

Version: 1.8 Date: 2007/02/17
- fix the copycover-offline.py script to use the new device path feature of
Amarok. Thanks to all those who sent me a patch.

Version: 1.7 Date: 2006/10/19
- fixes for Amarok 1.4
- progress bar on the offline version
- use large images when available

Version: 1.6 Date: 2005/05/31
- bugfixes for the "remove covers" option
Thanks a lot to Gleb Litvjak and KNT for that.
- write debuginfo to ~/.xsession-errors by default

fernandosanchezmunoz

12 years ago

Hi all,

I'm running Amarok 1.4 with MySQL in an Ubuntu Gutsy and can't get the offline script to work. I see the "processing artist" messages but nothing is copied in the album folder.

I've seen in previous posts that this was supposed to be related to a change required in the script to CONCAT from || but the version I've downloaded has this changed already and still doesn't work.

Any hints? anyone got it working with this configuration?

thanks a lot

Report

fernandosanchezmunoz

12 years ago

UPDATE:

reinstalled amarok with a fresh MySQL database and worked like a charm. Problems were probably due to a corrupted dB.

Thanks to the developer and congratulations for an extremely useful peace of software.

Anyone for a script embedding the cover into the tag of the mp3 file? :-)

Report

Shortie

12 years ago

I'm getting this while running the offline script (the same as running in normal mode)

Running in debug mode. No change will be done.

Traceback (most recent call last):
File "copycover-offline.py", line 105, in <module>
artists = associateResults2(dcop_artists)
File "copycover-offline.py", line 73, in associateResults2
results.append( (output_list[i], output_list[i+1]) )
IndexError: list index out of range

Report

Shortie

12 years ago

I GOT IT (no phyton knowledge to me^^ and very few bout programming and linux)

The problem was in the dcop command reporting an error bout a different program.

Now it works good!!

Report

DASGiB

12 years ago

To make the "copycover-offline.py" script work with AmaroK 1.4.7 and SQLite you need to modify the script a bit. The SQL CONCAT() function is not supported in SQLite, so you have to use the || operator:

Open the script (~/.kde/share/apps/amarok/scripts/copycover/copycover-offline.py) in your favorite editor , go to line 124 and change:

SELECT DISTINCT album.name, CONCAT(devices.lastmountpoint,'/',tags.dir) FROM

to:

SELECT DISTINCT album.name, devices.lastmountpoint || '/' || tags.dir AS dir FROM

That's it. Now start AmaroK and run the script in debug mode (no files will be copied):

python copycover-offline.py -d -v -c cover.png

This would create a file called "cover.png" in every album directory (of course only if you have set a album in AmaroK ;-).

When the result is fine run the script again, but without the -d switch:

python copycover-offline.py -v -c cover.png

Report

zerqent

12 years ago

Confirming this fix with PostgreSQL 8.2 on Ubuntu Hardy as well. Amarok 1.4.9.1


Although there is no point in selecting AS dir though.

SELECT DISTINCT album.name, devices.lastmountpoint||'/'||tags.dir FROM

is enough =)

Report

nxt

12 years ago

thanks, perfect script. Just one minor suggestion: maybe you could add an option for one time run through the whole collection, instead of copying just the cover of currently played song...

Report

richlv

12 years ago

well, it is there already :)
script archive contains :
copycover-offline.py
this will run through your collection and copy everything.
whether it works with the latest amarok version i'm not sure.

Report

sevrx

12 years ago

seems like it does not work with amarok 1.4.7 and sqlite.
i see the "processing artist" strings, but covers are not copied to folders or deleted from cache.

Report

dunnix20

12 years ago

While running the script from within amarok I get:

[AmaroK CopyCover Script] Started.
TypeError: saveState() takes exactly 1 argument (2 given)


any Ideas on what might be causing this?
I'm using SQLlite

Report

xhorder

12 years ago

I love this script, but with one comment: Would it be possible to KEEP the spaces in the filenames?
That's the only thing keeping this from being perfect.

Report

wishmechaos

12 years ago

Hi. The script version works great, but I can't get the offline version to work.

$ ./copycover-offline.py -d
Running in debug mode. No change will be done.

-Traceback (most recent call last):
File "./copycover-offline.py", line 129, in <module>
for file in os.listdir(album_path):
OSError: [Errno 2] No such file or directory: '0'

running Ubuntu Feisty, Python 2.5.1

cheers

Report

wolfundschaf

12 years ago

Hi,

I had the same problem and found a solution. Apparently, one of the SQL queries does not work correctly, at least not with MySQL

You have to change line 112 to this:

dcop_albums = commands.getoutput('''dcop amarok collection query "SELECT DISTINCT album.name, CONCAT(devices.lastmountpoint,'/',tags.dir) FROM tags, album, devices ''' \

Now, CONCAT is used instead of the || operator.

This works with Ubuntu 7.04, Pyhton 5.2.1 and Amarok 1.4.7 using MySQL 5.0.38-Ubuntu_0ubuntu1.1-log as database.

I hope this helps,
Wolf

Report

KimBisgaard

12 years ago

Unfortunately PostgreSQL does not have a CONCAT function, but uses '||' as the string concat operator :-(

Report

xxmel0nxx

12 years ago

It didn't work for me, the query that did work was SELECT DISTINCT album.name, tags.dir FROM album JOIN tags ON album.id = tags.album WHERE tags.artist = %s I'm using Python 2.4.4, Mysql 5.0.44.

Report

sdyson

12 years ago

Cheers! Worked for me.

Report

jassuncao

12 years ago

Same for me. Using the 'devices' table in the query seems to exclude all the albums stored in my root partition

Report

wishmechaos

12 years ago

Thanks, that worked perfectly. Now I'm trying to modify it so it copies every album art to a single folder, named %Album%Artist.%ext, so my mp3 player recognises it. If anyone has done anything similar, please post :)

Cheers.

Report

cewanf

12 years ago

How can I schedule copycover-offline.py to run at a certain time every night?
I tried crontab, but it only produces the error:
"AmaroK must be running. Please launch it and restart this script."
Even though Amarok is running...

Report

C

gauret

12 years ago

You have to set your DISPLAY variable. Add "DISPLAY=:0" in front of the command call, that should do it (it's a common problem: using cron with graphical apps. I'm sure you favorite search engine will help you)

Report

cewanf

12 years ago

Wohoo!
Thanks a lot for helping!!

Now I have scheduled Amarok to scan its collection for changes every night, and two hours later to run the copycover offline script :-)

Report

enaut

12 years ago

Hi
my Laptop seemed recently incredibly slow. So I checked what process it is that slows the system down and I discovered about 80 python processes that all use exactly 3.3MB of Ram space. by indicating them with ps -x I discovered that they are all rutines of your copycover script.
While researching how they get started I discovered that each time Amarok is running in the system tray while I shut down or Amarok is not closed correctly there is a remaining process. and cute KDE restarts all of them every time again when I start my computer atempting to restore the last session. even if amarok is not started.

so please include in your script:
# a way to test wether amarok is running
# a way to test wether another rutine of the script is already running

Report

chrisKA

12 years ago

If you have an instance of a QApplication all you need to insert is the following method:
Quote:
def saveState(self, sessionmanager):
# script is started by amarok, not by KDE's session manager
sessionmanager.setRestartHint(QSessionManager.RestartNever)

HTH

Report

Zeeuw

13 years ago

Hi,

I really like your script, though i probably use it for something else then the rest of you guys do. I guess you use this script to set the album cover as the folder icon?
I use it for my mp3 player (Cowon iAudio A2), which can display album covers. This mp3 player detects whether you have a cover.jpg in the folder of the song you are playing. If it is, it displays this image, else, it displays the default empty cd icon. The problem of using this script for that purpose is that my mp3 player only supports jpg's as album cover, no png's. Just renaming cover.png to cover.jpg doesn't fool my mp3 player.
So i had to think of another solution: change the script. I editted addcoverdirs.sh, and replaced all png's with jpg's and all jpg's by png's. It didn't work though, because the python script doesn't use addcoverdirs.sh. (I needed some time to find that out :P)
Now i got it working, but i have to run the script each time an cover has been added. Is there a possibility to implent this feature in the python script?

By the way: i had to change musicdirs="awk command" to musicdirs="/path/to/music", because "awk -F "=" '/^Collection Folders/ {print $2}' ~/.kde/share/config/amarokrc" doesn't give any results. (amarokrc does exist)

Then something else: is it, or will it be, possible for amarok to copy the cover.jpg automatically to my mp3 player, that would be great. (you can just drag and drop files to the iaudio a2, it doesn't use any database)
Maybe this would be a nice feature for amarok 2.0? Please let me know if you would like that feature too. (maybe i will submit a mockup for amarok)

Report

miguel2

12 years ago

I've seen a little script to convert the png to jpg here: http://www.anythingbutipod.com/forum/showpost.php?p=30263&postcount=18

You could run it after the sync.
I think an option in CopyCover to choose if the cover should saved as png or jpg would be nice.

Report

12 years ago

ChangeLog:
Version: 1.9 Date: 2007/10/21
- fix queries when the database is in MySQL
- tell the session manager not to restart the script on login

Version: 1.8 Date: 2007/02/17
- fix the copycover-offline.py script to use the new device path feature of
Amarok. Thanks to all those who sent me a patch.

Version: 1.7 Date: 2006/10/19
- fixes for Amarok 1.4
- progress bar on the offline version
- use large images when available

Version: 1.6 Date: 2005/05/31
- bugfixes for the "remove covers" option
Thanks a lot to Gleb Litvjak and KNT for that.
- write debuginfo to ~/.xsession-errors by default

12345678910
product-maker Base: 4 x 5.0 Ratings
Be the first to comment
DaiVied
Dec 30 2009
thoughtcrime
Jul 20 2009
File (click to download) Version Description Downloads Date Filesize DL OCS-Install MD5SUM
*Needs pling-store or ocs-url to install things
Pling
0 Affiliates
Details
license
version
1.9
updated Oct 21 2007
added Mar 31 2005
downloads 24h
0
mediaviews 24h 0
pageviews 24h 2
System Tags addon