Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite in an effort to be more readable. Summary:
* Reuse getConfig (though it'll always fall back to /etc) * Seperate filters (sorry for the long lines)
- Loading branch information
Tom Vincent
committed
Sep 3, 2010
1 parent
6482f65
commit ed687cd
Showing
1 changed file
with
16 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,24 @@ | ||
#!/bin/sh | ||
|
||
source /etc/ytmp.conf | ||
. /usr/lib/tlvince/getConfig.sh | ||
. $(getConfig ytmp) | ||
|
||
if ! [ -n "$INTERFACE" ]; then echo "INTERFACE not set in /etc/ytmp.conf" >&2; exit 1; fi | ||
[ $INTERFACE ] || { | ||
echo "$0: error: INTERFACE not set in /etc/ytmp.conf" >&2 | ||
exit 1 | ||
} | ||
|
||
rm /tmp/ytmpurls 2> /dev/null | ||
|
||
ngrep -W byline -qil 'get|session' tcp dst port 80 -d $INTERFACE | egrep --line-buffered -i "(get\ /watch|GET \/[0-9]* .*|^session_token.*)" | sed --unbuffered -e 's/GET \/ HTTP\/1\.1\.//' -e 's/.*video_id%22%3A%22\([_a-zA-Z0-9-]\{11,11\}\).*/host=youtube\nid=\1/' -e 's/.*\/\([0-9]*\) .*/host=vimeo\nid=\1/g' -e 's/.*=\([_a-zA-Z0-9-]\{11,11\}\)[ &].*/host=youtube\nid=\1/' >> /tmp/ytmpurls & | ||
FILTERS=" | ||
s/GET \/ HTTP\/1\.1\.// # Unwanted GET headers | ||
s/.*\/\([0-9]*\) .*/host=vimeo\nid=\1/g # Vimeo video ID | ||
s/.*=\([_a-zA-Z0-9-]\{11,11\}\)[ &].*/host=youtube\nid=\1/ # Youtube video ID | ||
s/.*video_id%22%3A%22\([_a-zA-Z0-9-]\{11,11\}\).*/host=youtube\nid=\1/ # Youtube channel video ID | ||
" | ||
|
||
exit 0 | ||
ngrep -W byline -qil 'get|session' tcp dst port 80 -d "$INTERFACE" | \ | ||
egrep --line-buffered -i "(get\ /watch|GET \/[0-9]* .*|^session_token.*)" | \ | ||
sed --unbuffered -e "$FILTERS" >> /tmp/ytmpurls & | ||
|
||
#'-e 's/GET \/ HTTP\/1\.1\.//'' -> get rid of unwanted 'GET / HTTP/1.1.' matches | ||
#'-e 's/.*\/\([0-9]*\) .*/host=vimeo\nid=\1/g'' -> filter vimeo video ids | ||
#'-e 's/.*=\([_a-zA-Z0-9-]\{11,11\}\)[ &].*/host=youtube\nid=\1/' -> filter | ||
# youtube video ids | ||
#'-e 's/.*video_id%22%3A%22\([_a-zA-Z0-9-]\{11,11\}\).*/host=youtube\nid=\1/'' | ||
# -> filter youtube channel video ids | ||
exit 0 |