Shell Script help - MP3 Downloader using Wget


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell Script help - MP3 Downloader using Wget
# 1  
Old 03-04-2009
Shell Script help - MP3 Downloader using Wget

I want to make a script to use wget to find and download mp3s on a website into a directory with a name derived from that URL. So far I have:

#!/bin/sh
echo “MP3 Downloader”
echo -n "Enter full URL address of website or website subdirectory > "
read text

cd ~
mkdir $text
cd $text

wget -r -nc -k -np -U Mozilla/5.0 -A.mp3,oog -e robots=off -w 3 -l 7 --limit-rate=50k --random-wait --restrict-file-names=windows $text

My problem is the middle bit. I want to make a new directory based on the URL and then change to it before Wgetting.

I cannot input a URL (presumably because of the "/"s and I don't know how to resolve that.

Also $text seems to be good for one go only so I can't use it for any more instances.

Any help would be gratefully appreciated.
# 2  
Old 03-04-2009
Depends on the url and what naming logic you want to create the directory.

What do you mean by "$text seems to be good for one go only so I can't use it for any more instances"? Everytime you run the script $text will have the value supplied via read command.
# 3  
Old 03-05-2009
wget's "-x" option will make it create a hierarchy of directories when files are downloaded, i.e. it will create, in the current directory, www.somewebsite.com/path/to/file.mp3 . This is usually used with wget's recursive options but doesn't have to be. You can make it put the root in some other path with -P /path/to/somewhere
# 4  
Old 03-05-2009
Thanks for the replies.

Corona, I think -X will be perfectly sufficient for my needs. Thanks.

Rik, I might be wrong but it seemed to me when I tried to use $text twice it only worked the first time. Ie in:-

#!/bin/sh
echo “MP3 Downloader”
echo -n "Enter new directory name> "
read text

cd ~
mkdir $text
cd $text

I 'm pretty sure the cd $text part doesn't work and the directory doesn't change to the newly created directory.

Anyway, that could all be moot, because, if I use -X I can hopefully simplify the code to:-

#!/bin/sh
echo “MP3 Downloader”
echo -n "Enter full URL address of website or website subdirectory > "
read text

wget -r -nc -k -np -X -U Mozilla/5.0 -A.mp3,oog -e robots=off -w 3 -l 7 --limit-rate=50k --random-wait --restrict-file-names=windows $text
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Wget - working in browser but cannot download from wget

Hi, I need to download a zip file from my the below US govt link. https://www.sam.gov/SAMPortal/extractfiledownload?role=WW&version=SAM&filename=SAM_PUBLIC_MONTHLY_20160207.ZIP I only have wget utility installed on the server. When I use the below command, I am getting error 403... (2 Replies)
Discussion started by: Prasannag87
2 Replies

2. Shell Programming and Scripting

Need help in wget or curl command in UNIX shell

Hi, I need help in wget or curl command to invoke a REST client services. This is the format i need to send request wget -H "tokenId: F6" -H "Authorization: Basic <64 bit encoded username:password>" -H "https://example.com" -H "Accept: application/Json" -o download.xml... (1 Reply)
Discussion started by: zen01234
1 Replies

3. Shell Programming and Scripting

Curl/wget shell script to follow redirect.

Hello eveyone. I would like to create a simple batch with curl (or wget) to download a URL but the URL I can only download from the browser and not from shell because curl and wget won't follow the 301 redirect which I get :confused: I tried with curl -L but no luck. I want to hear your opinion.... (5 Replies)
Discussion started by: accolito
5 Replies

4. Shell Programming and Scripting

script to rename mp3 files

hi there, i'm using OS X. i have a bunch of mp3 files strewn across a directory tree that i'd like to rename. specifically i'd like to remove any track numbers and leading non-alphabetic characters from the filenames like this: 01 - song1.mp3 2 song2.mp3 become: song1.mp3... (6 Replies)
Discussion started by: creakyshrimp
6 Replies

5. Red Hat

other non-interactive network downloader besides wget

Are there any non-interactive network downloaders like wget that come with fedora by default? I noticed that wget doesn't come with fedora. (4 Replies)
Discussion started by: cokedude
4 Replies

6. Shell Programming and Scripting

automatic script for flac to mp3 conversion

used flac2mp3 (0 Replies)
Discussion started by: barrydocks
0 Replies

7. Shell Programming and Scripting

Shell script with wget in ssh command

Hi, I am using a linux with bash. I have a script written which will login to a remote server and from there it runs a "wget" to downlaod a build file from a webserver. Here is the line inside the script: ssh -t -q -o StrictHostKeyChecking=no -o ConnectTimeout=5 root@${a}'wget... (4 Replies)
Discussion started by: sunrexstar
4 Replies

8. Shell Programming and Scripting

Help with shell script "wget"

I am trying to gather a list of files (products) every 30 days that have been added to a website. First it will delete the files that are already in the directory from 30 days ago. Then it will it gather the updated files (products) from the webstie and it will place them in a directory. Lastly it... (3 Replies)
Discussion started by: jhampt
3 Replies

9. Shell Programming and Scripting

make script deleting mp3 with warnig to users

hi i need to make a script that will check the directories of the users on mp3 or mp4 files. if so they must be automaticly deleted and they have to get a warning message instead. this should be running every day at 1 pm and should be done within the cron file. could someone help me with... (2 Replies)
Discussion started by: stefan
2 Replies

10. Shell Programming and Scripting

Response Code using wget in shell

I am trying to get the status code of a web request,size of the download file and response time using wget. When i use the command: wget <sitename> ,it gives all these parameters in the command line.But i want to get these values seperately and assign in different variables using shell script.Is... (2 Replies)
Discussion started by: rajbal
2 Replies
Login or Register to Ask a Question