I posted previously in this Programming thread about formatting the IceCast xml list.. Well, that's done (thanks guys), and the list is ready to be imported/added to an existing combobox list, in VLC-GTK...
But, cos the IceCast list is about 3MB (10,000 lines), I cant add the new stuff to the 'fave streams' list in VLC-GTK, without getting the 'argument list too long' error...
The list of streams I wanna add to, is the file ${HOME}/.vlc-gtk/vlc-gtk-faves
It contains lines all of the format
NAME|URL
(Anything with a pipe in the middle would do to test the code below... )
Once this list gets to 1,700 lines long, then VLC-GTK starts to bug out, giving 'Argument list too long' all over the place... Under 1,700 and it just takes a while to load, but no errors...
I've tried to condense down the relevant code into an example below:
(the code was originally for a list of about 12 mms:// TV stations... needs updating me thinks)
Code: Select all
FAVES=${HOME}/.vlc-gtk/vlc-gtk-faves #the list of streams ... each line in format NAME|URL
# build the list for a gtkdialog combobox .. <item>$LINE</item>
while read LINE
do
if [ "${LINE%%|*}" != "$FAVE_STREAM" ];then # dont include the last played stream in the list yet, add it top top later
FAVE_ITEMS="$FAVE_ITEMS
<item>${LINE%%|*}</item>" #get only fave names for combobox list
fi
done <"$FAVES"
FAVE_ITEMS="$(echo "$FAVE_ITEMS" | sort)" #sort favourite streams
# add last played stream to top of list
if [ "$FAVE_STREAM" != "" ];then
[ "$(cat $FAVES | grep "${FAVE_STREAM}|")" != "" ] && FAVE_ITEMS="<item>$FAVE_STREAM</item>
${FAVE_ITEMS}"
fi
Code: Select all
<combobox width-request="295">
<variable>FAVE_STREAM_URL</variable>
'$FAVE_ITEMS'
</combobox>
..and lastly, here's the (very crappy, inefficient) code that finds the URL later, once the user has chosen from the list.. I've not even got to this bit yet, to test it with over 1,700 lines, but it'll be relevant..
Code: Select all
#FAVE_STREAM_URL is the name of the stream chosen by the user
while read LINE; do
case $LINE in
"${FAVE_STREAM_URL}|"*) FAVE_STREAM_URL="${LINE##*|}"; NAME="${LINE%%|*}" # get name and URL #040812 fix case selection
esac
done<${HOME}/.vlc-gtk/vlc-gtk-faves
How can I rid myself of these 'Argument list too long' errors when the stream list is over 2,000 lines long? And ideally, speed up the code above a little bit at the same time..