LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices



Reply
 
Search this Thread
Old 04-25-2007, 07:21 PM   #1
bioe007
Member
 
Registered: Apr 2006
Location: lynnwood, wa - usa
Distribution: archlinux
Posts: 654

Rep: Reputation: 30
scripting cd->mp3 && id tags?


hi, i have recently switched to audacious.. actually I've never been too into storing tons of music on my computers until i started playing w/audacious. now I have learned a bit about cdparanoia and lame.

i have written a simple script:

Code:
#!/bin/bash
cd $HOME/.WAVtmp

# rip fast (-Z) and whole disk (-B)
cdparanoia -Z -B

# convert to .mp3 as long as .wav are present
for file in track*.cdda.wav
  do
    # -vbr-new> var bitrate 
    # -b32> bitrate =32 (saw this somewhere)
    # -q2> recommended man lame
    lame -vbr-new -b32 -mj -q2 $file $(echo $file | sed 's/track\(..\).cdda.wav/\1.mp3/')
    rm $file
done
it doesnt do much, just rip the cd and convert to .mp3. I then cp and move to a unique directory (/music/<artist>/album)

things I'm still missing: id3 tags? what exactly are these things and how to i 'get' them attached to my songs? there are some options (man lame) but these seem to require a file to input? can I automate this step too?

also any tips on automating the:
Code:
 
mkdir <pathtomusic>/artist/album
mv .WAVtmp/*.mp3 <pathtomusic>/artist/album
steps would really be appreciated. I could pass these as #1 and #2 args to the script but then what? i suppose it'd be nice to error check (existing directory) and integrate the mp3 tags to song title=>filename.mp3

Sorry if this is obvious I'm very new to scripting and completely clueless about the tags stuff, googling returns information overload... where to start?

many thanks!
 
Old 04-25-2007, 07:41 PM   #2
H_TeXMeX_H
Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269
I would recommend trying this program for the id3 tags:

http://freshmeat.net/projects/id3ren/

I'm not exactly sure what you're trying to do in the "automation" part. If you could be more specific, it would help.

Also, here's a great bash scripting guide (it says advanced, but that should not be taken to mean "for advanced bash scripters only", instead it should be "this guide will make you an advanced bash scripter, when you finish reading it and practice a lot")

http://tldp.org/LDP/abs/
 
Old 04-25-2007, 07:43 PM   #3
bioe007
Member
 
Registered: Apr 2006
Location: lynnwood, wa - usa
Distribution: archlinux
Posts: 654

Original Poster
Rep: Reputation: 30
thanks for the links H_TexMex_H,

what I'm really _hoping_ I can figure out is how to add the tags while ripping/encoding the CD. like add to my script something that gets the correct tags and applies them to the correct file as they're being encoded.

much thanks!
 
Old 04-25-2007, 07:49 PM   #4
bioe007
Member
 
Registered: Apr 2006
Location: lynnwood, wa - usa
Distribution: archlinux
Posts: 654

Original Poster
Rep: Reputation: 30
so I looked quickly at id3ren page (link above)
Quote:
id3ren is used to rename batches of MP3 files by reading the ID3 tag of MP3 files which contains song name, artists, album, year, and a comment. The secondary function of id3ren is a tagger, which can create, modify, or remove ID3 tags. The id3 fields fields can be set on the command line, entered interactively, or "guessed" from the path and filename.
i'm interested in both functions (renaming and creating) but for the creating part does anyone know if there is an automagic way to get the tag info?

I don't want to sit around typing names of songs all day..

{perhaps thats what i'm not understanding - do all id3 tags _have_ to be generated by typing? or is there some place that can scan the files and recognize the artist/album/song?}
 
Old 04-26-2007, 12:08 AM   #5
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
Most people rip CDs with a program already written that performs CDDB lookups (usually using the FreeDB database). This rips and tags automatically. You can also pass tag information along to your encoder, like
Code:
        cdparanoia -qXd $device $track - | oggenc -Qq6 \
            -o $dest/$fn_format.ogg \
            -a "$artist" \
            -d "$date" \
            -l "$album" \
            -N "$fn_track" \
            -t "$title" \
            -G "$genre" \
            -c comment="$comment" \
            -
That way you can just pass things like artists and albums just once and only specify each track title or what have you. I wanted to have a program for ripping and tagging that didn't use CDDB, so wrote a shell script with cdparanoia, oggenc, lame and an optional gui with gtkdialog. I ain't gonna post my crap spaghetti code, but those are just some examples/ideas. CDDB lookup is what you want, anyway, I think.

Last edited by slakmagik; 04-26-2007 at 12:09 AM. Reason: s/ripper/encoder/
 
Old 04-26-2007, 12:18 AM   #6
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
Quote:
Originally Posted by bioe007
also any tips on automating the:
Code:
 
mkdir <pathtomusic>/artist/album
mv .WAVtmp/*.mp3 <pathtomusic>/artist/album
steps would really be appreciated. I could pass these as #1 and #2 args to the script but then what? i suppose it'd be nice to error check (existing directory) and integrate the mp3 tags to song title=>filename.mp3

Sorry if this is obvious I'm very new to scripting and completely clueless about the tags stuff, googling returns information overload... where to start?

many thanks!
This part just hit my brain - as far as moving them, I store them in places based on their tag info - you'd pass in the tag info and then pass that through a function to make the proper filenames
Code:
mk_fn_proper() {
    echo $1 | sed '
    s/ /_/g
    s/(//g
    s/)//g
    s,/,-,g
    '
}
Note, the above doesn't come close to catching everything - just a Works For Me, YMMV example. Then make something like:
Code:
    dest=$audioroot/$fn_genre/${fn_artist#The_*}_${date}_${fn_album}
    if [ ! -d $dest ]; then
        mkdir -p $dest
    fi
and plug that into the stuff I already posted. Doesn't work if you're ripping The The CDs, though. Just do
Code:
dest=$audioroot/$fn_genre/${fn_artist}_${date}_${fn_album}
if you don't mind leading The's (or you *are* ripping The The).
 
Old 04-26-2007, 12:50 AM   #7
bioe007
Member
 
Registered: Apr 2006
Location: lynnwood, wa - usa
Distribution: archlinux
Posts: 654

Original Poster
Rep: Reputation: 30
wow, great help all. excellent pointers for writing the script. CDDB is what I'm looking for?

I'll google that.

another thing came to mind -> musicbrainz? I find libmusicbrainz in /var/log/packages and seem to recall reading it does something for id3 tags? i'll google that one too...

another thread, another reason to love the slackware community!
 
Old 04-26-2007, 11:09 PM   #8
jong357
Senior Member
 
Registered: May 2003
Location: Columbus, OH
Distribution: DIYSlackware
Posts: 1,914

Rep: Reputation: 52
id3tag is what your after. That's what libmusicbrainz links against anyway for it's id3 usage. The id3tag binary is a part of id3lib... I forget if it comes with Slack or not. It probably does since libmusicbrainz is in Pat's repo.

http://id3lib.sourceforge.net/

Also, have a look here for example script implementation:

http://wiki.linuxquestions.org/wiki/Audio_conversion

The first and last script there implement id3tags along with others I believe... It's not hard at all to make a script to do everything you want. Kind of a 'must' on Linux to make a script unless you use something like soundjuicer...

Last edited by jong357; 04-26-2007 at 11:35 PM.
 
Old 04-27-2007, 05:22 AM   #9
piete
Member
 
Registered: Apr 2005
Location: Havant, Hampshire, UK
Distribution: Slamd64, Slackware, PS2Linux
Posts: 465

Rep: Reputation: 44
Awesome you've gone ahead and just written what you needed, there's nothing better than that.

A quick poke around led me to find some things that may interest you:

http://www.suwald.com/ripit/ripit.html command line ripper in perl
http://home.gna.org/lltag/ command line tagger, I think also in perl.

I reckon you could integrate lltag into what you're trying to do without too much hassle. I've not found any pure shell scripts that deal with the CDDB lookup, but I have no doubt that with enough regular expressions you could make something that worked!

While I think that writing things from scratch is fantastic, I feel i would be remiss in my duty as semi-regular LQ poster without saying such a blindingly obvious thing as "It's ok to use someone elses program to do what you need, there's no shame in not writing everything from scratch".

With that said, keep us (that's the royal us, I mean me ...) posted on the ups and downs of this script!

Slack on!
- Piete.
 
Old 04-27-2007, 01:26 PM   #10
bioe007
Member
 
Registered: Apr 2006
Location: lynnwood, wa - usa
Distribution: archlinux
Posts: 654

Original Poster
Rep: Reputation: 30
@jong357 - this looks interesting... but what is ogg? joking, I'll do some more reading.

I've been a bit neglectful of this project due to other problems (with WINE)

@piete - those are great links. I've downloaded the ripit/lltag sources and will start playing... I have a book on perl and needed a reason to learn that anyway

thank you all!

I will try to make something that is CLI and fully vanilla slack compatible, then post my results for all.
 
Old 04-27-2007, 02:59 PM   #11
H_TeXMeX_H
Guru
 
Registered: Oct 2005
Location: $RANDOM
Distribution: slackware64
Posts: 12,928
Blog Entries: 2

Rep: Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269Reputation: 1269
ogg vorbis is (IMO, and all other things being equal) way better than mp3
 
  


Reply

Tags
id3, mp3, wav


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
AOL UK && BT Voyager 100 && Slackware 10.2 && RP-PPPoE pitt0071 Linux - Networking 3 01-17-2006 07:10 AM
Bash scripting and && operator Dark_Helmet Programming 16 09-18-2005 10:57 PM
Japanese canna won't work : Warning: &#12363;&#12394;&#28450;&#23383;&#22793;&am OrganicOrange84 Debian 3 06-30-2005 03:28 PM
Ph&#7909;c h&#7891;i d&#7919; li&#7879;u b&#7883; m&#7845;t???, c&#7913; pollsite General 1 06-27-2005 01:39 PM
bash shell scripting - && and || gui10 Programming 10 12-15-2001 04:37 PM


All times are GMT -5. The time now is 04:26 PM.

Main Menu
Advertisement
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 Google+: linuxquestions
Open Source Consulting | Domain Registration