#!/bin/bash
#
# pls2pd (L) Copyleft 2003.
#
# This is a basic script that will parse a .pls playlist file and
# just strip the first item on the list (called File1) and send a
# message to pd with the extracted URL
#
# Its use comes from interfacing streamtuner to audioflow (version 0.0.9 at the moment)
# for requesting it to connect to the specified stream url
#
# A disconnect message will be sent each time before requesting
# the new connection, otherwise you will get an "already connected"
# warning
#
# The pls file to be parsed should be feeded to pls2pd through standard input:
#
# 	i.e.: cat riereta.pls | pls2pd
#
# If you plan to use streamtuner together with audioflow *remember* to set
# pls2pd as the program to use for tunning on streamtuner (default is totem "%",
# so replace to pls2pd "%")
#
#
#
# made by rama at riereta net
#

PD_PORT=3050 # port pd is is listening at
STREAM_URL=`grep File1= $1 | sed 's/File1=//g'` # stripped URL from inside the playlist file

echo "stream2_ctl disconnect;" | pdsend $PD_PORT # tell pd to disconnect from the actual stream
echo "stream2_url $STREAM_URL;" | pdsend $PD_PORT # tell pd to connect to $STREAM_URL

#
# very easy! improvements, comments or whatever feedback is welcome
#
# enjoy
#
