diff --git a/HandBrakeCluster/Exceptions.class.php b/HandBrakeCluster/Exceptions.class.php index dccf04e..5bd80d9 100644 --- a/HandBrakeCluster/Exceptions.class.php +++ b/HandBrakeCluster/Exceptions.class.php @@ -2,16 +2,18 @@ class HandBrakeCluster_Exception extends Exception {}; -class HandBrakeCluster_Exception_DatabaseConfigMissing extends HandBrakeCluster_Exception {}; -class HandBrakeCluster_Exception_DatabaseConnectFailed extends HandBrakeCluster_Exception {}; -class HandBrakeCluster_Exception_NoDatabaseConnection extends HandBrakeCluster_Exception {}; -class HandBrakeCluster_Exception_DatabaseQueryFailed extends HandBrakeCluster_Exception {}; -class HandBrakeCluster_Exception_ResultCountMismatch extends HandBrakeCluster_Exception {}; +class HandBrakeCluster_Exception_DatabaseConfigMissing extends HandBrakeCluster_Exception {}; +class HandBrakeCluster_Exception_DatabaseConnectFailed extends HandBrakeCluster_Exception {}; +class HandBrakeCluster_Exception_NoDatabaseConnection extends HandBrakeCluster_Exception {}; +class HandBrakeCluster_Exception_DatabaseQueryFailed extends HandBrakeCluster_Exception {}; +class HandBrakeCluster_Exception_ResultCountMismatch extends HandBrakeCluster_Exception {}; -class HandBrakeCluster_Exception_UnknownSetting extends HandBrakeCluster_Exception {}; +class HandBrakeCluster_Exception_UnknownSetting extends HandBrakeCluster_Exception {}; -class HandBrakeCluster_Exception_TemplateException extends HandBrakeCluster_Exception {}; -class HandBrakeCluster_Exception_Unauthorized extends HandBrakeCluster_Exception_TemplateException {}; -class HandBrakeCluster_Exception_FileNotFound extends HandBrakeCluster_Exception_TemplateException {}; +class HandBrakeCluster_Exception_TemplateException extends HandBrakeCluster_Exception {}; +class HandBrakeCluster_Exception_Unauthorized extends HandBrakeCluster_Exception_TemplateException {}; +class HandBrakeCluster_Exception_FileNotFound extends HandBrakeCluster_Exception_TemplateException {}; -?> +class HandBrakeCluster_Exception_InvalidSourceDirectory extends HandBrakeCluster_Exception {}; + +?> \ No newline at end of file diff --git a/HandBrakeCluster/Rips/SourceLister.class.php b/HandBrakeCluster/Rips/SourceLister.class.php new file mode 100644 index 0000000..e448025 --- /dev/null +++ b/HandBrakeCluster/Rips/SourceLister.class.php @@ -0,0 +1,56 @@ +base_directory = $base_directory; + + $this->scan(); + } + + public function scan() { + if (!is_dir($this->base_directory)) { + throw new HandBrakeCluster_Exception_InvalidSourceDir($this->base_directory); + } + + // Define a queue of directories to scan, starting with the base directory, + // and keep going until they have all been scanned + $scan_directories = array($this->base_directory); + while ($scan_directories) { + $dir = dir(array_shift($scan_directories)); + + while (($entry = $dir->read()) !== false) { + if ($entry == '.' || $entry == '..') { + continue; + } + + // Skip any non-directories + $source = $dir->path . DIRECTORY_SEPARATOR . $entry; + if (!is_dir($source)) { + continue; + } + + // Accept this dir as a source if it contains a VIDEO_TS dir, + // otherwise add the dir to the queue to scan deeper + $source_vts = $source . DIRECTORY_SEPARATOR . 'VIDEO_TS'; + if (is_dir($source_vts)) { + $this->sources[] = $source_vts; + } else { + $scan_directories[] = $source; + } + } + + $dir->close(); + } + } + + public function sources() { + return $this->sources; + } + +}; + +?> \ No newline at end of file diff --git a/pages/browse/sources.php b/pages/browse/sources.php new file mode 100644 index 0000000..c96f227 --- /dev/null +++ b/pages/browse/sources.php @@ -0,0 +1,10 @@ +config(); + +$lister = new HandBrakeCluster_Rips_SourceLister($config->get('rips.source_dir')); + +$this->smarty->assign('sources', $lister->sources()); + +?> \ No newline at end of file diff --git a/templates/browse/sources.tpl b/templates/browse/sources.tpl new file mode 100644 index 0000000..ffa1766 --- /dev/null +++ b/templates/browse/sources.tpl @@ -0,0 +1,16 @@ +
+ The following DVD sources are available to be ripped: +
++ There are currently no DVD sources available to rip. +
+{/if}