The idea is to exchange (video) data from a central point of prescence... The intended audience consists of the following players:
In the future the intention is to add mobile devices and other players.
In order to enable the audience to manage their torrents, a virtual webhost is a premium requirement. On this vhost the following web applications need to be installed:
In order to stream data to the XBMC application, XNS is needed. An application that supports this protocol is ccxstream, so as root run:
portinstall ccxstream
Changes to /etc/rc.local:
#!/bin/sh
### ccxstream
if [ -e /etc/ccxstream.conf ]; then
. /etc/ccxstream.conf
${BIN} ${PARAMS} -C ${SERVERCOMMENT}
fi
And a config file (/etc/ccxstream.conf):
#!/bin/sh
#Below the user to run the service as (mandatory)
RUNASUSER="root"
#Below the password on the XBOX (optional)
#REMOTEPASS="xboxpassword"
#Below the interface to listen on (mandatory)
LISTENINTERFACE="xxx.xxx.xxx.xxx"
#Below allow application to follow symlinks (optional)
FOLLOWSYMLINKS="YES"
#Comment (optional)
SERVERCOMMENT="XBMS server for your viewing pleasure."
#Shares to make available (mandatory)
SHARES="movies=/path/to/media/video/movies series=/path/to/media/video/series"
#Location of binary file. Leave default unless you know what you're doing (mandatory)
BIN="/usr/local/bin/ccxstream"
#-----------------------------------------------------------------------------#
#-----------------------------------------------------------------------------#
DIR="-"
PIDFILE=/var/run/ccxstream.pid
PARAMS="-f -F $PIDFILE -r $DIR -u $RUNASUSER"
if test "x$FOLLOWSYMLINKS" != "x" ; then
PARAMS="$PARAMS -L"
fi
if test "x$REMOTEPASS" != "x" ; then
PARAMS="$PARAMS -P $REMOTEPASS"
fi
if test "x$LISTENINTERFACE" != "x" ; then
PARAMS="$PARAMS -l $LISTENINTERFACE"
fi
for i in $SHARES ; do
PARAMS="$PARAMS -S $i"
done
if test "x$SERVERCOMMENT" = "x" ; then
SERVERCOMMENT="`hostname`"
fi
emerge ccxstream
Remember to change /etc/conf.d/ccxstream to fit your needs.
A small php script (with hardcoded settings) to autosymlink movies by year:
<?php /* * Movie management * */ /** * Sucks given directory into a sorted array * Recurses into subdirs if asked * */ function it_get_dir($directory, $recurse="true" ) { // Disable directory traversal if ( strstr ( $directory, ".." ) ) { return false; } $Dir = opendir( $directory ); $num = 0; // false !== ... evades problems when encountering '0' or 'false' in names. while( false !== ($file = readdir( $Dir )) ) { $filename = $directory . $file; if ( ! is_link($filename) ) { if( ! is_dir( $filename ) ) { $dirlist[$num] = $filename; $num++; } elseif( $recurse ) { if ( $file != "." && $file != ".." ) { $dirlist = array_merge( $dirlist,it_get_dir($filename . "/" )); $num = count( $dirlist ) + 1; } } else { if( $file != "." && $file != ".." ) { $dirlist[$num] = $filename; $num++; } } } } closedir( $Dir ); if( ! empty($dirlist) ) { rsort($dirlist); reset($dirlist); } return $dirlist; } /*** Settings **/ $config["basedir"]= "/mnt/nfs/nslu2/opt/data/public/video/movies/"; $config["allmovies"] = $config["basedir"] . "all/"; $config["byyear"] = $config["basedir"] . "by year/"; $config["linkpath"] = "../../all/"; /*** MAIN ******/ if( ! @file_exists( $config["byyear"] ) ) { if( @mkdir( $config["byyear"], 0775, false ) === false ) { die( "Failed to create " . $config["byyear"] . ".\n"); } } print( "Obtaining filelist...\n" ); $movielist = @it_get_dir( $config["allmovies"], false ); foreach( $movielist as $movie ) { $movie = str_replace( $config["allmovies"], "", $movie ); // Fetch YEAR ereg( "\([0-9][0-9][0-9][0-9]\)$", $movie, $mov_year ); $cleanyear = array( "(", ")" ); $year = str_replace( $cleanyear, "", $mov_year[0] ); // Fetch Movie Name Only $movie = ereg_replace( "\ \([0-9][0-9][0-9][0-9]\)$", "", $movie ); if( @is_dir( $config["allmovies"] . "$movie ($year)/" ) ) { if( ! @is_link( $config["byyear"] . "$year/$movie" ) ) { if( ! @file_exists( $config["byyear"] . "$year/" ) ) { if( mkdir( $config["byyear"] . "$year/", 0755 ) === false ) { die( "Failed to create " . $config["byyear"] . "$year/.\n"); } } @symlink( $config["linkpath"] . "$movie ($year)/", $config["byyear"] . "$year/$movie" ); } } else { die( "Failed...\n" ); } } ?>