Ubuntu Forums ubuntu.com - launchpad.net - ubuntu help  

Go Back   Ubuntu Forums > The Ubuntu Forum Community > Other Community Discussions > Development & Programming > Programming Talk
Register Reset Password Forum Help Forum Council Search Today's Posts Mark Forums Read

Programming Talk
This forum is for all programming questions.
The questions do not have to be directly related to Ubuntu and any programming language is allowed.

 
Thread Tools Display Modes
Old January 27th, 2006   #1
otey
Just Give Me the Beans!
 
otey's Avatar
 
Join Date: Aug 2005
Location: Herning, Denmark
Beans: 55
Ubuntu Breezy 5.10
Export covers from amarok to album dirs (to ipod)

Hi to all

I'm using amarok for my music, and gtkpod for my iPod. My iPod is 5th generation, and supports coverimages. But my coverimages is stored via amarok, in the folder ~/.kde/share/apps/amarok/albumcovers/large using names like 0a04f8d1a982b56a6ac8950abaab78a0. (some md5-hash, i guess)

I would like to export the pictures from the amarok folder to the album dir. I only know a tiny bit of shell script, but i was hoping that somebody would help me.

My idea was to access the ~/.kde/share/apps/amarok/collection.db to get information on which cover belong to which album. And where the album is located. Then copy it to "album_folder_path/cover.png".

Then I can use gtkpod to upload the covers..

If somebody would give me a clue how to get going, maybe how to view the content of the collection.db, i would apreciate it.

Thanks in advance
otey is offline   Reply With Quote
Old January 27th, 2006   #2
otey
Just Give Me the Beans!
 
otey's Avatar
 
Join Date: Aug 2005
Location: Herning, Denmark
Beans: 55
Ubuntu Breezy 5.10
Re: Export covers from amarok to album dirs (to ipod)

after looking at the amarok wiki pages I wrote a script to copy the coverimage (set in amarok) to the direktory of the playing song (in amarok)
Code:
#/bin/bash

## Settings
cover_filename="cover.png"

## script
if [ "$(dcop amarok player status)" == "2" ]; then

	current_song="$(dcop amarok player path)"
	album_dir=${current_song%/*.mp3}
	picture_source="$(dcop amarok player coverImage)"
	picture_target=$album_dir"/"$cover_filename
	album_name="$(dcop amarok player album)"
	artist_name="$(dcop amarok player artist)"

	if [ "$picture_source" != "$picture_target" ]; then 
		if [ "${picture_source%%/*nocover.png}" != "" ]; then
			cp "$picture_source" "$picture_target"
			echo -e "Cover copied: $artist_name - $album_name"
		else
			echo "No cover set!"	
		fi
	fi
fi

Last edited by otey; February 5th, 2006 at 06:46 PM..
otey is offline   Reply With Quote
Old January 28th, 2006   #3
otey
Just Give Me the Beans!
 
otey's Avatar
 
Join Date: Aug 2005
Location: Herning, Denmark
Beans: 55
Ubuntu Breezy 5.10
Re: Export covers from amarok to album dirs (to ipod)

Ok.. Made the script go trough the whole playlist, copy covers.

Don't run it, with all files in the playlist. What i did was to add all my albums, then mark them all, and while holding ctrl I picked one song from every album. Then removed the other songs from the playlist.

the script:
Code:
#/bin/bash

## Settings
cover_filename="cover.png"


## script
while [ "$(dcop amarok player status)" == "2" ]; do
	current_song="$(dcop amarok player path)"
	album_dir=${current_song%/*.mp3}
	picture_source="$(dcop amarok player coverImage)"
	picture_target=$album_dir"/"$cover_filename
	album_name="$(dcop amarok player album)"
	
	if [ -f "$picture_target" ]; then
	  dcop amarok player next
	else
		if [ ${picture_source%%/*nocover.png} != "" ]; then
			cp "$picture_source" "$picture_target"
			echo "Cover copied: \"$album_name\""
		fi
	fi
done

Last edited by otey; February 5th, 2006 at 06:47 PM..
otey is offline   Reply With Quote
Old November 5th, 2007   #4
TheIrishGuy
5 Cups of Ubuntu
 
Join Date: Jul 2007
Beans: 24
Re: Export covers from amarok to album dirs (to ipod)

nice script guys, thumbs up here

i made a few minor changes

first off i have a hell of a lot of mp3s(50k+), and i dont really want to click anything other than "go" and walk away.

At the same time i want to be able to see some sort of progress so i added a number increment so i can actually see its doing something.
Number increment may seem unnecessary but is kinda handy. kind of like a progress bar as amarok will be left minimized

also added some inverted commas to avoid any dirty things like

line 21: [: !=: unary operator expected


Code:
#/bin/bash


## Settings
cover_filename="cover.png"
cover_number=0



## script
while [ "$(dcop amarok player status)" == "2" ]; do
	current_song="$(dcop amarok player path)"
	album_dir=${current_song%/*.mp3}
	picture_source="$(dcop amarok player coverImage)"
	picture_target=$album_dir"/"$cover_filename
	album_name="$(dcop amarok player album)"
	cover_number=$((cover_number+1))
	
	if [ -f "$picture_target" ]; then
	  	dcop amarok player next
	else
		if [ "${picture_source%%/*nocover.png}" != "" ]; then
			cp "$picture_source" "$picture_target"
			echo $cover_number " Cover copied: \"$album_name\""
			dcop amarok player next
		else
			echo $cover_number " No cover set!"
			dcop amarok player next	
		fi
		
	fi
done
i wreckon it will take a couple of hours, but its worth it!

Last edited by TheIrishGuy; November 5th, 2007 at 12:16 PM..
TheIrishGuy is offline   Reply With Quote
Old November 5th, 2007   #5
smartbei
Has an Ubuntu Drip
 
smartbei's Avatar
 
Join Date: Nov 2006
Location: Israel
Beans: 703
Ubuntu 9.04 Jaunty Jackalope
Re: Export covers from amarok to album dirs (to ipod)

Many thanks guys! I was looking for something just like this.
__________________
Intel E6300 / MSI P4M890M / 2GB DDR2 677 / 80GB SATA2 / GeForce 6200TC / DL DVD+-RW / ViewCom 17" LCD
smartbei is offline   Reply With Quote
Old November 5th, 2007   #6
geirha
I Ubuntu, Therefore, I Am
 
Join Date: Feb 2007
Beans: 3,453
Ubuntu 9.04 Jaunty Jackalope
Re: Export covers from amarok to album dirs (to ipod)

I made a script to do this myself, but I can't seem to find it again. I managed to put together the query I used to query the amarok database with though:
Code:
SELECT DISTINCT CONCAT('~/.kde/share/apps/amarok/albumcovers/large/',MD5(LOWER(CONCAT(artist.name,album.name)))), tags.dir
FROM album, artist, tags WHERE album.id=tags.album AND artist.id=tags.artist
while amarok is running, you can run the query through dcop:
Code:
 dcop amarok collection query "SELECT DISTINCT CONCAT('~/.kde/share/apps/amarok/albumcovers/large/',MD5(LOWER(CONCAT(artist.name,album.name)))), tags.dir
FROM album, artist, tags WHERE album.id=tags.album AND artist.id=tags.artist"
As you probably see, if you know a little sql, the covers are stored to a file in ~/.kde/share/apps/amarok/albumcovers/large/ with the md5sum of artist name+album name in lower case. So if you have the album David Bowie - Aladdin Sane, the cover will be stored as
Code:
$ echo -n "david bowiealaddin sane"|md5sum
f73bc66afee49e43fffdea0e194cc2fc  -
There's a special case for albums which have several (various) artists though, if I remember correctly, the cover names are only made from the md5sum of the album name in such cases.

Hope this helps.
geirha is offline   Reply With Quote
Old November 5th, 2007   #7
TheIrishGuy
5 Cups of Ubuntu
 
Join Date: Jul 2007
Beans: 24
Re: Export covers from amarok to album dirs (to ipod)

latest copycover script now works

you can download it from here

http://www.kde-apps.org/content/show...?content=22517

once it has copied the images into the destination folders you can use the below script to apply album covers to the folders in Nautilus


http://ubuntuforums.org/showpost.php...6&postcount=18

in order to use this script you need to either change the script or rename the png files to folder.png

i got this from a nice person in #bash in irc.ubuntu.com

test it first (echo)
Code:
find . -name "*.png" | while read file; do echo mv "$file" "${file%/*}/cover.png"; done
once your sure
Code:
find . -name "*.png" | while read file; do mv "$file" "${file%/*}/cover.png"; done

Last edited by TheIrishGuy; November 5th, 2007 at 10:11 PM..
TheIrishGuy is offline   Reply With Quote
Old July 14th, 2009   #8
dannyboy79
Ubuntu addict and loving it
 
dannyboy79's Avatar
 
Join Date: May 2006
Location: Milwaukee,WI
Beans: 4,179
Ubuntu 7.04 Feisty Fawn
Send a message via AIM to dannyboy79
Re: Export covers from amarok to album dirs (to ipod)

Quote:
Originally Posted by TheIrishGuy View Post
latest copycover script now works

you can download it from here

http://www.kde-apps.org/content/show...?content=22517

once it has copied the images into the destination folders you can use the below script to apply album covers to the folders in Nautilus


http://ubuntuforums.org/showpost.php...6&postcount=18

in order to use this script you need to either change the script or rename the png files to folder.png

i got this from a nice person in #bash in irc.ubuntu.com

test it first (echo)
Code:
find . -name "*.png" | while read file; do echo mv "$file" "${file%/*}/cover.png"; done
once your sure
Code:
find . -name "*.png" | while read file; do mv "$file" "${file%/*}/cover.png"; done
i had luck with this website instruction here: http://www.64bitjungle.com/ubuntu/ba...ing-directory/
__________________
Check out my Blog about my life and computer software and hardware. http://danielscomps.blogspot.com/
dannyboy79 is offline   Reply With Quote

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 09:07 PM.


vBulletin ©2000 - 2010, Jelsoft Enterprises Ltd. Ubuntu Logo, Ubuntu and Canonical © Canonical Ltd. Tango Icons © Tango Desktop Project. bilberry