#!/bin/sh
# encode videos from incoming and create torrent
# to share the torrent run something like btlaunchmany on $seeding or use the scandir feature available in many torrent clients
incoming=/tmp/incoming
encoding=/tmp/encoding
seeding=/tmp/seeding
f2t_params="-p videobin"

while [ 1 ]; do
  for i in `ls $incoming/*`; do
    mv $i $encoding
    ffmpeg2theora $encoding/`basename $i` -o $seeding/`basename $i`.ogv $f2t_params && \
    btmakemetafile http://tpb.tracker.thepiratebay.org/announce $seeding/`basename $i`.ogv
  done
  sleep 900 # wait for 15 minutes
done
