LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
LinkBack Search this Thread
Old 08-22-2004, 01:50 PM   #1
kzar
Member
 
Registered: Oct 2003
Posts: 66

Rep: Reputation: 15
how to do a freedb query?


Im trying to bodge a shell script to rip a cd to mp3. Im sick of trying to get other wrappers to do exactly what i want and also i wouldnt mind learning a bit. Problem is im having problems finding a way of getting freedb info about a cd.
 
Old 08-22-2004, 03:28 PM   #2
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,903
Blog Entries: 10

Rep: Reputation: 847Reputation: 847Reputation: 847Reputation: 847Reputation: 847Reputation: 847Reputation: 847
I'm sure that some of these will disclose
(in their source ;}) how they did it...


Cheers,
Tink
 
Old 08-22-2004, 04:20 PM   #3
kzar
Member
 
Registered: Oct 2003
Posts: 66

Original Poster
Rep: Reputation: 15
looks like cd-discid and cddb-tool is the way to do it. this is going to take some head scratching though im new to shell script
 
Old 08-22-2004, 04:38 PM   #4
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,903
Blog Entries: 10

Rep: Reputation: 847Reputation: 847Reputation: 847Reputation: 847Reputation: 847Reputation: 847Reputation: 847
http://www.tldp.org/LDP/Bash-Beginne...tml/index.html

http://www.tldp.org/LDP/abs/html/index.html


Cheers,
Tink
 
Old 08-22-2004, 05:51 PM   #5
kzar
Member
 
Registered: Oct 2003
Posts: 66

Original Poster
Rep: Reputation: 15
thanks for all the links. i was right about the head scratching though. to get the freedb info it has to do all these steps...

get hostname and username (not hard)
cd-discid /dev/cdrom > sometempfile
cddb-tool query on that file > someothertempfile

some cleaver magic to get the genre of the album it found out of the someothertempfile but if it finds more than one entry just go for the first one and if it doesnt find any entrys for the cd throw an error or somthing

cddb-tool read using the genre we got earlier > anothertempfile

and hopefully then you will have information about the cd. no clue how to do the bit which finds the genre from inside that text file though!

im going to bed for now , too tired to do anything this confusing

Last edited by kzar; 08-22-2004 at 05:52 PM.
 
Old 08-22-2004, 07:39 PM   #6
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,903
Blog Entries: 10

Rep: Reputation: 847Reputation: 847Reputation: 847Reputation: 847Reputation: 847Reputation: 847Reputation: 847
Quote:
Originally posted by kzar

cddb-tool query on that file > someothertempfile
Can you post some demo-output?


Cheers,
Tink
 
Old 08-23-2004, 03:11 AM   #7
kzar
Member
 
Registered: Oct 2003
Posts: 66

Original Poster
Rep: Reputation: 15
Code:
#!/bin/bash

# Change these options
# Most arnt used yet ovbiously
cdrom="/dev/cdrom"
ripcommand="cdparanoia %track %out"
encodecommand="lame -S -q 2 -b 160 %in %out"
cdidcommand="cd-discid %cdrom"
freedbcommand="cddb-tool"
freedbserver="http://freedb.freedb.org/~cddb/cddb.cgi"

# Leave this alone
cddbuser=$(whoami)
cddbhost=$(hostname)

cd-discid $cdrom > /tmp/davidmp3script-cdid
cddb-tool query $freedbserver 5 $cddbuser $cddbhost `cat /tmp/davidmp3script-cdid` > /tmp/davidmp3script-query
This is what i have got so far, it puts the query into /tmp/davidmp3script-query but im stuck on the bit of getting the genre out of the file.
 
Old 08-23-2004, 03:35 AM   #8
kzar
Member
 
Registered: Oct 2003
Posts: 66

Original Poster
Rep: Reputation: 15
Right thought first step was knowing what i needed to do so i have got an example of each thing which could happen. Now to read about sed in that link you gave me .

Multiple results
Code:
210 Found exact matches, list follows (until terminating `.')
misc b40d990c The Vines / Winning Days
newage b40d990c The Vines / Winning Days
.
Single result
Code:
200 rock 3506fb05 Kasabian /
No match
Code:
202 No match for disc ID 9b0a2b0b.
edit: i know what i need to do, get the code at the start, if its 210 read the first word of the next line as the genre, if its 200 read the second word of the first line as the genre or if its 202 throw a wobly.

Last edited by kzar; 08-23-2004 at 04:41 AM.
 
Old 08-23-2004, 02:45 PM   #9
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,903
Blog Entries: 10

Rep: Reputation: 847Reputation: 847Reputation: 847Reputation: 847Reputation: 847Reputation: 847Reputation: 847
/me high-fives kzar: "Excellent work mate!"

:}

If you run into any problems, there's heaps of
really good bash-programmers here.



Cheers,
Tink
 
Old 08-23-2004, 05:16 PM   #10
kzar
Member
 
Registered: Oct 2003
Posts: 66

Original Poster
Rep: Reputation: 15
Thanks . Here is the code so far, Ive pretty much finished the freedb stuff there but now i just have to write the whole cd ripping, mp3 encoding, mp3 taging and renaming bit . Wish me luck .
Code:
#!/bin/bash

# Change these options
# Most arnt used yet ovbiously
cdrom="/dev/cdrom"
ripcommand="cdparanoia %track %out"
encodecommand="lame -S -q 2 -b 160 %in %out"
cdidcommand="cd-discid %cdrom"
freedbcommand="cddb-tool"
freedbserver="http://freedb.freedb.org/~cddb/cddb.cgi"

# Leave this alone
cddbuser=$(whoami)
cddbhost=$(hostname)

# Get the disk id
cd-discid $cdrom > /tmp/davidmp3script-cdid
# Get the query from freedb
cddb-tool query $freedbserver 5 $cddbuser $cddbhost `cat /tmp/davidmp3script-cdid` > /tmp/davidmp3script-query

# Get the genre from the query
responsecode=$(cat /tmp/davidmp3script-query | awk '{i++} i==1 {print ""$1""}')
case "$responsecode" in
                200)
                        genre=$(cat /tmp/davidmp3script-query | awk '{print $2}')
                ;;
                210)
                        genre=$(cat /tmp/davidmp3script-query | awk '{i++} i==2 {print ""$1""}')
                ;;
                202)
                        echo "No results"
                ;;
esac

# Get the read from freedb
cddb-tool read $freedbserver 5 $cddbuser $cddbhost $genre `cat /tmp/davidmp3script-cdid` > /tmp/davidmp3script-read
 
Old 08-24-2004, 05:00 AM   #11
kzar
Member
 
Registered: Oct 2003
Posts: 66

Original Poster
Rep: Reputation: 15
Quote:
Originally posted by Tinkster

If you run into any problems, there's heaps of
really good bash-programmers here.
Bit stuck actualy, i have made a file which lists the audio tracks for ripping, it looks somthing like this.
Code:
1
2
3
4
5
6
7
8
9
Is there some kind of do until EOF loop ? i need to use these numbers but i cant think of how to do it.
 
Old 08-24-2004, 06:55 AM   #12
kzar
Member
 
Registered: Oct 2003
Posts: 66

Original Poster
Rep: Reputation: 15
Heres my attempt. Problem is putting the number variable just after the other one doesnt work.

Code:
for i in `cat /tmp/davidmp3script-tracks`;
do
temp=`awk '/TTITLE$i=/{print}' /tmp/davidmp3script-read`
track$i=`echo $temp | cut -d"=" -f2`
echo "$track$i"
done
Heres what it should do for the first track
Code:
temp=`awk '/TTITLE1=/{print}' /tmp/davidmp3script-read`
track1=`echo $temp | cut -d"=" -f2`
echo "$track1"
any ideas how i can achieve this?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
query saurabhparihar Linux - Newbie 2 05-21-2005 02:00 PM
xmms and freedb.org Hammett Linux - Software 0 11-03-2004 01:00 PM
X -query pacman23 Linux - Software 2 07-22-2004 07:16 AM
command line mp3 encoding with freedb? chakkerz Linux - General 9 06-28-2004 07:08 PM
xmms - freedb doesn't recognize CD - can I enter manually? cpv204 Linux - Software 0 06-05-2003 08:47 PM


All times are GMT -5. The time now is 12:38 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration