soma-ripper (.m3u) for mocp dev.

Submitted scripts and programs
Forum rules
Your own work only.
User avatar
wuxmedia
Grasshopper
Posts: 6454
Joined: Wed Oct 17, 2012 11:32 am
Location: Back in Blighty
Contact:

soma-ripper (.m3u) for mocp dev.

Unread post by wuxmedia » Sat Aug 09, 2014 8:55 pm

So I was bored, wanted to have all of the soma stations (even though now there are only a few I like a lot) In MOCP.

sure you can make a list, but it's a pain, and the stations don't stick to that.
so here is a rough assed way of pulling the stations from a twitter link i found.

Code: Select all

#!/bin/bash
## WuX 2014-07-24 -finished 2014-08-13
## Complex script to do just what I want, with somaFM Stations

## tidy up just in case No complaints! 
/bin/rm -r /tmp/m3u 2> /dev/null
/bin/rm /tmp/soma* 2> /dev/null

#Make the dest file
echo "#EXTM3U" > /tmp/somapls.m3u

#User Information:
echo -e "Working.....\nGetting station list..."

## Get complete list of streams, non verbose:
wget -qP /tmp http://somafm.com/SomaFM.com.m3u -O /tmp/somafmlist.txt

## Get just the playlists url:
ST2=$(grep "http:" /tmp/somafmlist.txt)

## Info 
echo "Converting them"

## Turn them into .m3u, AND add a dir to the webpath:
echo "$ST2" | sed "[email protected]@.m3u@g;[email protected]@.com/m3u@g" > /tmp/somafmlist.txt

## Adding all the stations it missed.
echo "http://somafm.com/m3u/defcon.m3u" >> /tmp/somafmlist.txt
echo "http://somafm.com/m3u/bagel.m3u" >> /tmp/somafmlist.txt
echo "http://somafm.com/m3u/folkfwd.m3u" >> /tmp/somafmlist.txt
echo "http://somafm.com/m3u/thetrip.m3u" >> /tmp/somafmlist.txt
echo "http://somafm.com/m3u/earwaves.m3u" >> /tmp/somafmlist.txt

# Info
echo "Downloading all the individual playlists..."
 
## Quietly wget those fuckers:
mkdir /tmp/m3u
wget -qP /tmp/m3u -i /tmp/somafmlist.txt 
echo "Fixing them up, pretty like."

## Fuck em up:
for i in /tmp/m3u/*.m3u; do 
sed s@icy@http@g $i > $i.x
echo $i |cut -d "/" -f4 | cut -d "." -f1 >> $i.x
mv $i.x $i
done

## Pull out the info into a .m3u
for z in /tmp/m3u/*.m3u; do
NAME=$(tail -1 $z) ADR=$(head -1 $z)
echo -e "#EXTINF:0,$NAME\n$ADR" >> /tmp/somapls.m3u
done

## Chuck it in the home dir
mv /tmp/somapls.m3u ~/

## Tidy up, just in case 
/bin/rm -r /tmp/m3u
/bin/rm /tmp/soma*

## Info:
echo "Finished, somapls.m3u can be found in your home dir"
It mostly works... should give a named station in the playlist window.
probably an easier way, can't remember why i wanted m3u's rather than .pls...
Last edited by wuxmedia on Wed Aug 13, 2014 12:26 pm, edited 2 times in total.
Reason: Finished the damn thing.
"Seek, and Ye shall find"
"Github | Chooons | Site"

User avatar
rhowaldt
Dog
Posts: 4565
Joined: Wed Oct 17, 2012 9:01 am
Contact:

Re: soma-ripper (.m3u) for mocp dev.

Unread post by rhowaldt » Sat Aug 09, 2014 11:52 pm

^ nice hack wux :)
All statements are true in some sense, false in some sense, meaningless in some sense, true and false in some sense, true and meaningless in some sense, false and meaningless in some sense, and true and false and meaningless in some sense.

User avatar
wuxmedia
Grasshopper
Posts: 6454
Joined: Wed Oct 17, 2012 11:32 am
Location: Back in Blighty
Contact:

Re: soma-ripper (.m3u) for mocp dev.

Unread post by wuxmedia » Sun Aug 10, 2014 12:14 pm

thanks, despite the obvious flaws - I learnt a bit about various things whilst doing it.
"Seek, and Ye shall find"
"Github | Chooons | Site"

User avatar
wuxmedia
Grasshopper
Posts: 6454
Joined: Wed Oct 17, 2012 11:32 am
Location: Back in Blighty
Contact:

Re: soma-ripper (.m3u) for mocp dev.

Unread post by wuxmedia » Wed Aug 13, 2014 10:52 am

Ooops, well this was "dev" I tried it today and realised it didn't actually do anything - but spam the /tmp dir
Finished it..!
"Seek, and Ye shall find"
"Github | Chooons | Site"

Post Reply