Update duplicate checking to allow for subtitles and mixed filetypes
This commit is contained in:
20
source/lib/DownloadDispatcher/Utility/MediaFile.class.php
Normal file
20
source/lib/DownloadDispatcher/Utility/MediaFile.class.php
Normal file
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
class DownloadDispatcher_Utility_MediaFile {
|
||||
|
||||
public static function isMediaFile($filename) {
|
||||
return preg_match('/(?<!(?:\.|-)sample)\.(?:avi|ogm|m4v|mkv|mov|mp4|mpg|srt|smi|rar)$/i', $filename);
|
||||
}
|
||||
|
||||
public static function isVideoFile($filename) {
|
||||
return preg_match('/(?<!(?:\.|-)sample)\.(?:avi|ogm|m4v|mkv|mov|mp4|mpg)$/i', $filename);
|
||||
}
|
||||
|
||||
public static function isMetadataFile($filename) {
|
||||
return preg_match('/(?<!(?:\.|-)sample)\.(srt|smi)$/i', $filename);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
@@ -6,10 +6,9 @@ class DownloadDispatcher_Utility_MediaFilesIterator extends FilterIterator {
|
||||
if (preg_match('/^sample/', $filename)) {
|
||||
return false;
|
||||
}
|
||||
if (preg_match('/(?<!(?:\.|-)sample)\.(?:avi|ogm|m4v|mkv|mov|mp4|mpg|srt|rar)$/i', $filename)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return DownloadDispatcher_Utility_MediaFile::isMediaFile($filename);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
class DownloadDispatcher_Utility_VideoFilesIterator extends FilterIterator {
|
||||
public function accept() {
|
||||
$filename = $this->current()->getFilename();
|
||||
if (preg_match('/^sample/', $filename)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return DownloadDispatcher_Utility_MediaFile::isVideoFile($filename);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user