From: Dylan Lloyd Date: Tue, 19 Mar 2013 01:30:53 +0000 (-0400) Subject: init X-Git-Url: https://disinclined.org/git/?a=commitdiff_plain;h=18dc69fafa04b8d8ac28f7c0ba6547859b05712f;p=fvlc.git init --- 18dc69fafa04b8d8ac28f7c0ba6547859b05712f diff --git a/fvlc b/fvlc new file mode 100755 index 0000000..0fa82c4 --- /dev/null +++ b/fvlc @@ -0,0 +1,37 @@ +#!/bin/bash + +PROCESS_COUNT="$(pgrep fvlc | wc -l)" +if [[ $PROCESS_COUNT > 2 ]] +then + exit 1 +fi + +SOURCE_DOMAIN="${1:?error: missing source argument}" +DESTINATION_FILE="${2:?error: missing destination argument}.flv" + +# This loop is a hacky workaround +# When tcpdump is given the -c1 argument, +# it refuses to output the packet contents +# :-( + +TEMPFILE=$(mktemp) +while [ -z "$URLHEAD" ] +do + LOCALHOST_IP=$(ifconfig wlan0 | grep 'inet ' | awk '{print $2}') + sudo tcpdump -vvvA -iwlan0 -s 500 \ + "tcp port 80 and src $LOCALHOST_IP" >$TEMPFILE 2>/dev/null & + sleep 5s && kill $! + URLHEAD=$(grep 'GET /api/player' $TEMPFILE | awk '{print $2}') +done + +rm $TEMPFILE + +QUERYURL="$SOURCE_DOMAIN$URLHEAD" +VIDEO_URL=$(curl $QUERYURL) +VIDEO_URL=${VIDEO_URL%\&title=*} +VIDEO_URL=${VIDEO_URL#url=} + +mplayer $VIDEO_URL -dumpstream -dumpfile "$DESTINATION_FILE" 2>&1 >/dev/null & disown +notify-send -i .config/film.png "Buffering video " + +vlc "$DESTINATION_FILE"