Files
download-dispatcher/source/lib/DownloadDispatcher/Source/Plugin/TV.class.php
Ben Roberts 9a954b2b9d Initial commit
Basic framework for application including two sample plugins: TV and
RouterboardFirmware.
2011-12-12 00:48:50 +00:00

68 lines
2.2 KiB
PHP

<?php
class DownloadDispatcher_Source_Plugin_TV extends DownloadDispatcher_PluginBase implements DownloadDispatcher_Source_IPlugin {
/**
* Name of this plugin
*
* @var string
*/
const PLUGIN_NAME = "TV";
protected $config;
protected $log;
public static function create($config, $log) {
return new self($config, $log);
}
protected function __construct($config, $log) {
$this->config = $config;
$this->log = $log;
}
public function run() {
DownloadDispatcher_LogEntry::debug($this->log, 'Running TV dispatcher');
// Iterate over source directories, and move matched files to the output directory
$source_dirs = $this->config->get('sources.TV.input-directories');
foreach ($source_dirs as $dir) {
if (is_dir($dir) && is_readable($dir)) {
$this->process_dir($dir);
} else {
DownloadDispatcher_LogEntry::warning($this->log, "TV input directory '{$dir}' does not exist or cannot be read.");
}
}
}
protected function process_dir($dir) {
// TODO - Iterate over the contents of the directory, process files and recurse deeper
}
protected function process_matched_file($dir, $file) {
// TODO - Handle movement of the matched file to the correct output directory
// Handle direct media files, and also RAR archives
}
protected function identify_output_dir($dir, $file) {
// TODO - Generate the correct output directory, apply any special case mappings, and ensure the destination exists
}
protected function identify_duplicate($dir, $file) {
// TODO - Verify that the file we've found hasn't already been processed
// Use the cache to reduce processing overhead
// TODO - Upstream caching
}
protected function rename_output($dir, $file) {
// TODO - use tvrenamer to update the filenames
}
protected function mark_processed($dir, $file) {
// TODO - Update the cache to show that a file has already been handled
// TODO - Upstream caching
}
}
?>