Logo
IT Dienstleistungen

sop - The Sopcast Starterscript

It's useless now that a real gui exists with gsopcast. give it a try, works well.

I searched for a comfortable way to start sopcast 1) links from the browser and ended up with this script.

It depends on the sopcast binary available in your path

#!/bin/bash                    
######################################################
# Startupscript for www.sopcast.com P2P Videostreams #
# Needs the sp-sc-auth from Sopcast www.sopcast.com  #
#                                                    #
# Published under the terms of the GNU GPL License   #
######################################################
 
# Define some variables
 
# Which port to use
# default "8908"   
LOCALPORT=8908     
 
# Which Mediaplayer (vlc, mplayer, xine) (executable)
# default "vlc" / works best with x.264              
MEDIAPLAYER=vlc                                      
 
# How long wait for buffer before we start the mediaplayer
# Time to Buffer depends on your connection and the channel
WAITTIME=10                                                
 
#some more stuff
RED="\033[1;31m"
GREEN="\033[1;32m"
YELLOW="\033[1;33m"
BLUE="\033[1;34m"  
RESET="\033[00m"   
 
# set Channel from $1
CHANNEL=$1           
 
# Which Brokerserver (broker, broker1, broker2)
# If given with sopcast-adress, this variable will be overwritten.
# default "broker"                                                
BROKER=broker                                                     
 
#helper functions
HELP=$(echo -e "SOPCAST-Starter - the sopcast linux tool
calls the sopcast binary with complete parameterset     
from your browser                                       
 
\tUsage: $(basename $0) [channel] | [sopcast-url]\n")
 
#nice passivepopup for 3 seconds                     
user_info() {                                        
                kdialog --passivepopup "$1" --title "SOPCAST-Starter" 3
}                                                                      
 
#Help output
if [[ $1 = "-h" || $1 = "" ]]; then
        user_info "$HELP"          
   exit 1                          
fi                                 
 
# check if sop is called with complete sopcast address (like a browser would)
if [[ "$1" =~ "sop://" ]]; then                                              
     # EXTRACT CHANNEL FROM ADDRESS                                          
     CHANNEL=$(echo $1 | grep .sopcast.com:3912/ | awk -F ".sopcast.com:3912/" '{ print Buffer $2 }')
     # EXTRACT CALLED BROKERSERVER                                                                   
     BROKER=$(echo $1 | grep .sopcast.com:3912/ | awk -F ".sopcast.com:3912/" '{ print Buffer $1 }' | awk -F "sop://" '{ print Buffer $2 }')                                                                                                              
fi                                                                                                                           
 
#start sopcast now                                                                                                           
start_sopcast() {                                                                                                            
 
        # kill running instances first
        if [[ $(ps -a | grep sp-sc) != "" ]]; then
            killall -9 sp-sc-auth >/dev/null
        fi
        # start sopcast in background, shrink the ouput to buffersize only (maybe use it later)
        sp-sc-auth sop://$BROKER.sopcast.com:3912/$CHANNEL 3908 $LOCALPORT | grep nblockAvailable= |awk -F "nblockAvailable=" '{ print Buffer $2 }' | tr -s "\n" "\r BUFFER: " &
        kdialog --passivepopup "Sopcast startet for channel $CHANNEL " --title "SOPCAST-Starter" 5
        # wait for buffer to grow....
        sleep $WAITTIME
        #fire up mediaplayer
        user_info "$MEDIAPLAYER ready to start..."
        $MEDIAPLAYER http://localhost:$LOCALPORT/tv.asf >/dev/null
        # if mediaplayer ends, check if sopcast runs
        if [[ $(ps -a | grep sp-sc) != "" ]]; then
            kdialog --yesno "Your Mediaplayer was terminated, do you want to re-run it (YES)\
             or do you want to kill the sopcast process (NO)" --title "SOPCAST-Starter"
            if [[ $? = "1" ]]; then
                killall -9 sp-sc-auth >/dev/null
            elif [[ $? = "0" ]]; then
                $MEDIAPLAYER http://localhost:$LOCALPORT/tv.asf >/dev/null
            fi
        fi
}
 
start_sopcast
#set Prompt to white again (change if your using black on white)
echo -e "$RESET"
1)
P2P Videostreams www.sopcast.com

Seiten-Werkzeuge