Wrapper - Skript für LINUX grab

Digital Recording
Mike25
Neugieriger
Neugieriger
Beiträge: 19
Registriert: Samstag 21. September 2002, 20:06

Wrapper - Skript für LINUX grab

Beitrag von Mike25 »

Hallo Leute,

für alle grab - Benutzer da draussen:
Ich habe einen kleinen Shell - Wrapper mit folgenden Funktionen geschrieben:
- Name der aktuellen Sendung auf aktuellem Kanal holen über nhttpd
- APID und VPID des aktuellen Kanals holen über nhttpd
- Speichern des Streams mit Sendername als Name + lfd. Nummer
- Es können alle Parameter die grab versteht, durchgereicht werden

Vorraussetzungen:
- Linux grab (aus Tuxbox CVS)
- links Webbrowser (Konsole) (sorry, aber lynx geht nicht)
- grep, sed und awk (sollten bei jedem UNIX dabei sein)
- es muss ein Eintrag in /etc/hosts für dbox existieren bzw. im lokalen DNS-Server ;)

OK- hier das Skript:

Code: Alles auswählen

#!/bin/sh

GRAB=`which grab`
LINKS=`which links`

ONIDSID=`$LINKS -source http://dbox/control/getonidsid`
NAME=`$LINKS -source http://dbox/control/epg | grep $ONIDSID | sed s/^[0-9]*.[0-9]*.//g`

VPID=`$LINKS -source http://dbox/fb/info.dbox2 | grep "<CENTER>0x" | awk '{ print substr($0,26,8) }' | sed -n '4p'`
APID=`$LINKS -source http://dbox/fb/info.dbox2 | grep "<CENTER>0x" | awk '{ print substr($0,26,8) }' | sed -n '5p'`

echo "************************************************"
echo "Sendung:  $NAME"
echo "VideoPID: $VPID"
echo "AudioPID: $APID"
echo "************************************************"

$GRAB -p $VPID $APID -o "$NAME " $*
Viel Spass damit!
Mike
Mike25
Neugieriger
Neugieriger
Beiträge: 19
Registriert: Samstag 21. September 2002, 20:06

Verbesserung, passend für ggrab

Beitrag von Mike25 »

Hallo Leute,

neue Version des Scripts:
- Wahl zwischen links und wget zum Bedienen der HTTP-Schnittstelle
- Ausführlicherer Output

Code: Alles auswählen

#!/bin/sh
#
# Simple shell-wrapper for (g)grab.
# It tries to fetch the APID, VPID and EPG-Title from the Neutrino-HTTP-Interface
# and runs (g)grab with following Parameters:
# "-p" followed by VPID and APID
# "-o" followed by EPG-Title and incrementing number given by (g)grab
#
# If you need additional Parameters for (g)grab, just give them with this
# Script and it will pass them through (g)grab.
# i.e.: "grab_wrapper.sh -m 60" will force (g)grab to record for 60 minutes.
# see (g)grab -h for details

# Uncomment following line to use the new ggrab
GRAB=`which ggrab`

# Uncomment following line to use "old" grab
#GRAB=`which grab`

# Uncomment following line to use links as http-Client
#HTTPCLIENT="`which links` -source"

# Uncomment following line to use wget as http-Client
HTTPCLIENT="`which wget` -O -"

echo "Fetch ONIDSID..."
ONIDSID=`$HTTPCLIENT http://dbox/control/getonidsid 2> /dev/null`
echo "Fetch EPG-Title..."
NAME=`$HTTPCLIENT http://dbox/control/epg 2> /dev/null | grep $ONIDSID | sed s/^[0-9]*.[0-9]*.//g`
echo "Fetch VPID..."
VPID=`$HTTPCLIENT http://dbox/control/zapto?getpids 2> /dev/null | sed -n '1p'`
VPID=`echo "obase=16;ibase=10; $VPID;" | bc`
echo "Fetch APID..."
APID=`$HTTPCLIENT http://dbox/control/zapto?getpids 2> /dev/null | sed -n '2p'`
APID=`echo "obase=16;ibase=10; $APID;" | bc`

echo "************************************************"
echo "EPG-Title: $NAME"
echo "VideoPID:  $VPID"
echo "AudioPID:  $APID"
echo "************************************************"
echo "Executing  $GRAB -p $VPID $APID -o $NAME $*"
echo "************************************************"
$GRAB -p $VPID $APID -o "$NAME " $*
Viel Spass damit!