-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
111 additions
and
0 deletions.
There are no files selected for viewing
52 changes: 52 additions & 0 deletions
52
Scripts/System/DownloadClients/DeleteRogueUNPACKDirectories.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/** | ||
* @name Delete Rogue _UNPACK_ Directories | ||
* @description Will check any _UNPACK_ directories, and if they haven't be modified in 24 hours will delete that directory | ||
* @revision 1 | ||
* @minimumVersion 1.0.0.0 | ||
*/ | ||
|
||
let folders = Variables['RogueUnpackDirectoryList']; | ||
if(!folders){ | ||
Logger.WLog('RogueUnpackDirectoryList variable not defined.') | ||
return; | ||
} | ||
|
||
folders = folders.trim().split('\n'); | ||
if(!folders.length){ | ||
Logger.WLog('RogueUnpackDirectoryList variable has no folders.') | ||
return; | ||
} | ||
|
||
for(let folder of folders) | ||
{ | ||
var dir = new System.IO.DirectoryInfo(folder); | ||
if(dir.Exists === false) | ||
continue; | ||
Logger.ILog('Checking diretory: ' + folder); | ||
|
||
const cutoffDate = new Date(Date.now() - (24 * 60 * 60 * 1000)); | ||
let subdirs = dir.GetDirectories('_UNPACK_*', System.IO.SearchOption.AllDirectories); | ||
for(let subdir of subdirs) | ||
{ | ||
if(subdirs.Exists === false) | ||
continue; | ||
|
||
Logger.ILog('Found _UNPACK_ directory:' + subdir.FullName); | ||
|
||
if (subdir.LastWriteTime > cutoffDate || subdir.CreationTime > cutoffDate) | ||
{ | ||
Logger.ILog('Directory was written/created recently: ' + subdir.FullName); | ||
continue; | ||
} | ||
|
||
try | ||
{ | ||
Logger.ILog('Deleting rogue directory: ' + subdir.FullName); | ||
subdir.Delete(true); | ||
} | ||
catch(err) | ||
{ | ||
Logger.WLog('Failed to delete directory: ' + ex.Message); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** | ||
* @name Add MKV extension to files without an extension | ||
* @description Monitors the directories listed in the variable AddExtensionDirectoryList and any file thats found without an extenion, MKV will be added to it | ||
* @revision 1 | ||
* @minimumVersion 1.0.0.0 | ||
*/ | ||
|
||
let folders = Variables['AddExtensionDirectoryList']; | ||
if(!folders){ | ||
Logger.WLog('AddExtensionDirectoryList variable not defined.') | ||
return; | ||
} | ||
|
||
folders = folders.trim().split('\n'); | ||
if(!folders.length){ | ||
Logger.WLog('AddExtensionDirectoryList variable has no folders.') | ||
return; | ||
} | ||
|
||
for(let folder of folders) | ||
{ | ||
|
||
var dir = new System.IO.DirectoryInfo(folder); | ||
Logger.ILog('Dir exists:' + dir.Exists); | ||
var files = dir.GetFiles("*", System.IO.SearchOption.AllDirectories); | ||
|
||
Logger.ILog('Files: ' + files.length); | ||
|
||
for(var file of files) | ||
{ | ||
let name = file.FullName; | ||
|
||
if(name.endsWith('.mp4.mkv') || name.endsWith('.avi.mkv')){ | ||
file.MoveTo(name.substring(0, name.length - 4)); | ||
continue; | ||
} | ||
|
||
if(name !== file.Directory.FullName && name.indexOf('.mkv.mkv') < 0) | ||
{ | ||
let index = name.lastIndexOf('.'); | ||
if(index > 0) | ||
{ | ||
let extension = name.substring(index + 1); | ||
Logger.ILog('Extension: '+ extension); | ||
if(extension.length < 5) | ||
continue; | ||
} | ||
} | ||
if (file.Length < 200000000) | ||
continue; | ||
|
||
if(name.indexOf('.mkv.mkv') > 0) | ||
name = name.replace(/\.mkv/g, ''); | ||
|
||
Logger.ILog("Adding MKV extension to file: " + file.FullName); | ||
|
||
file.MoveTo(name + ".mkv"); | ||
} | ||
} |