xtreme newbie_ extracting url from .m3u and download its target to hdd

Hello and thank you for taking some time reading this!

Here’s my problem:
I regularly receive a url link to an m3u file. If I dbl click it, itunes pops up and plays the audio. It turns out that I’ve opened the m3u in textedit to see what it looked like and I could clearly see the url of an actual mp3 sitting on a server. Here’s the syntax of the m3u I get:

#EXTM3U
#EXTINF:,
http://server.org/show/shownumber.mp3

I’ve tried converting the file (renamed to shownumber.TXT) to html using automator, and retrieving the link, but I get an error at that point in the workflow.
It says:
Applescript error
curl: (3) malformed (1)

However the html code of the shownumber.htm looks just fine:

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}

#EXTM3U

#EXTINF:,

http://server.org/show/shownumber.mp3

My guess is that it doesn’t actually link to anything… it just displays the url, automator must be looking for something “clickable”…

I know this kinda looks like an automator question, but this has been haunting me for the last 3 days and I think automator just can’t handle this task…
So what do you think would be a clever way to use applescript to get that url so I can shoot it back to automator’s safari action: “download urls”?

Your help is much appreciated, hope I was clear :confused:
have a great day
ron

You could go thru iTunes. Highlight any of the streamling tracks in iTunes and then run this:


tell application "iTunes"
	get selection of front browser window
	if (selection of front browser window) is not {} then
		set sel to selection
		repeat with thisTrack in sel
			if "http" is in address of thisTrack then
				set musicURL to address of thisTrack
				tell application "Safari"
					open location musicURL
				end tell
			end if
		end repeat
	end if
end tell

If you have Speed Download you could have it download the tracks:


tell application "iTunes"
	get selection of front browser window
	if (selection of front browser window) is not {} then
		set sel to selection
		repeat with thisTrack in sel
			if "http" is in address of thisTrack then
				set musicURL to address of thisTrack
				tell application "Speed Download"
					AddURL musicURL
				end tell
			end if
		end repeat
	end if
end tell

very impressive Gyuen! Thanks for the help!

I suppose this would work great… however, I would really appreciate not having to intervene at any point in this.
My idea was to save my final automator workflow (and the lovely applescript component that would put me out of my misery) as an iCal plugin,
have it run automatically once a week
have it retrieve the mp3 files to my hard drive
import the files into itunes
set my ipod to automatically sync with the playlist containing these files
enjoy the delightful feeling of having made a machine your slave through the use of a cunning workflow
enjoy the tracks

Wouldn’t it be great if you could automatically receive radio shows and store them to your iPod?! yeah, I know I’m talking about a podcast but unfortunately for some reason I do not understand… the creators of that show have not yet created a xml file to podcast their show… suck, huh?

I think ultimate achievement in a process has been reached when things are done without you participating.
I’m empowering my computer with a certain level of initiative :slight_smile: what any true loyal sidekick should have!

thanks again!

Ron,

Then you could use a shell script automator action:

for f in “$@”
do
grep -i http “$f”
done

After you have the selected m3u files, perform that shell scipt command and it’ll pass the URLs onto the next step.

Gary

Gary,

Thanks for the ongoing contribution!
I’ve just tried your shell script in automator. I’m afraid something doesn’t quite click though…
I’ve pulled down the modifiers (menus "bin/bash ; bin/csh ; etc) using pass input to stdin & as arguments
I get an error sound in almost any configuration of that script, and those who don’t lead to a little red cross in the action’s box in automator lead to nothing.

I don’t know what I’m doing wrong…

I would not dare say your script doesn’t work because I’m not familiar with that kind of syntax… nor would I blame you if you gave up on this one… :frowning:

if it’s any help, here’s a description of my automator workflow:

  1. get specified URL (page on which the link to m3u is)
  2. get link URLs from webpages
  3. filter URLs (entire url ends with .m3u)
  4. download URLs (to /temp)
  5. run shell script
for f in "$@"
do
    grep -i http "$f"
done

6.download URLs (to /temp)

It is so frustrating to feel so close but not to get there…

thanks again Gary

Hi Ron,

I tried a few different things with a shell script action. I couldn’t get it to work. Automator did pass the correct URLs to the next action but it seems within quotes. Maybe that was the problem.

I tried going back to an AppleScript action. I think it would look something like this. It doesn’t work and I’d have to learn a bit more AppleScript to figure it out. Maybe someone else here knows.


on run {input}
	set m3uFile to open for access input
	set fileRows to (read m3uFile as list)
	set theseRows to (a reference to fileRows)
	repeat with currentLine in theseRows
		if currentLine contains "http" then
			...
		end if
	end repeat
	return input
end run