Преглед на файлове

added external options and paths db

Timothy Pomeroy преди 5 години
родител
ревизия
5de7708082
променени са 3 файла, в които са добавени 188 реда и са изтрити 27 реда
  1. 87 0
      data/paths.json
  2. 93 0
      data/settings.json
  3. 8 27
      index.js

+ 87 - 0
data/paths.json

@@ -0,0 +1,87 @@
+{
+
+  "/Shares/Torrents/finished/pr0n": {
+    "type": "pr0n",
+    "destination": "/Shares/.Private",
+    "folder": true,
+    "exts": ["avi", "mkv", "mov", "mp4", "m4v"],
+    "ext": "m4v",
+    "preset": "Very Fast 480p30",
+    "clean": {
+      "\\.XXX\\.(.*)\\Team$": ""
+    },
+    "database": "data/pr0n.json"
+  },
+
+  "/Shares/Torrents/finished/Movies": {
+    "type": "movie",
+    "destination": "/Users/pomeroyt/Desktop/Convert/done",
+    "exts": ["avi", "mkv", "mov", "mp4", "m4v"],
+    "ext": "m4v",
+    "preset": "Fast 1080p30",
+    "titlecase": true,
+    "genre": true,
+    "clean": {
+      "(480i|480p|720i|720p|1080i|1080p|4k)(.*)?$": "",
+      "(HDRip|DVDRip|DVDRIp|BRRip|BDRip|BluRay|HC)(.*)?$": "",
+      "(XviD|Xvid|AC3|x264|X264)(.*)?$": "",
+      "(iNTERNAL|THC|HDTC|HC)(.*)?$": "",
+      "(REMASTERED|READNFO)(.*)?$": "",
+      "\\.": " ",
+      "\\-": " ",
+      "_": " ",
+      "\\s\\s": " ",
+      "\\s\\s": " ",
+      "\\s\\s": " "
+    },
+    "database": "data/movies.json"
+  },
+
+  "/Shares/Torrents/finished/Kids": {
+    "type": "movie",
+    "destination": "/Shares/Movies/Kids",
+    "exts": ["avi", "mkv", "mov", "mp4", "m4v"],
+    "ext": "m4v",
+    "preset": "Fast 1080p30",
+    "titlecase": true,
+    "clean": {
+      "(480i|480p|720i|720p|1080i|1080p|4k)(.*)?$": "",
+      "(HDRip|DVDRip|DVDRIp|BRRip|BDRip|BluRay|HC)(.*)?$": "",
+      "(XviD|Xvid|AC3|x264|X264)(.*)?$": "",
+      "(iNTERNAL|THC|HDTC|HC)(.*)?$": "",
+      "(REMASTERED|READNFO)(.*)?$": "",
+      "\\.": " ",
+      "\\-": " ",
+      "_": " ",
+      "\\s\\s": " ",
+      "\\s\\s": " ",
+      "\\s\\s": " "
+    },
+    "database": "data/kids.json"
+  },
+
+  "/Shares/Torrents/finished/radarr": {
+    "type": "movie",
+    "destination": "/Users/pomeroyt/Desktop/Convert/done",
+    "exts": ["avi", "mkv", "mov", "mp4", "m4v"],
+    "ext": "m4v",
+    "preset": "Fast 1080p30",
+    "titlecase": true,
+    "tmdblookup": true,
+    "clean": {
+      "(480i|480p|720i|720p|1080i|1080p|4k)(.*)?$": "",
+      "(HDRip|DVDRip|DVDRIp|BRRip|BDRip|BluRay|HC)(.*)?$": "",
+      "(XviD|Xvid|AC3|x264|X264)(.*)?$": "",
+      "(iNTERNAL|THC|HDTC|HC)(.*)?$": "",
+      "(REMASTERED|READNFO)(.*)?$": "",
+      "\\.": " ",
+      "\\-": " ",
+      "_": " ",
+      "\\s\\s": " ",
+      "\\s\\s": " ",
+      "\\s\\s": " "
+    },
+    "database": "data/radarr.json"
+  }
+
+}

+ 93 - 0
data/settings.json

@@ -0,0 +1,93 @@
+{
+  "secret": "fZGpA7aqSmPHqu25dk7389NMGTnZyzBo",
+  
+  "tmdbApiKey": "d14f485c9f702e6541547b6c9ed695da",
+
+  "dateFormat": "MMM DD YYYY HH:mm a",
+  "yearFormat": "YYYY",
+
+  "logLevel": 1,
+  "test": true,
+
+  "defaults": {
+    "preset": "Fast 1080p30",
+    "clean": {},
+    "titlecase": false,
+    "folder": false,
+    "database": "data/db.json"
+  },
+
+  "activity": {
+    "file": "data/activity.json"
+  },
+
+  "watcher": {
+    "ignored": "(^|[/\\])..|([s|S]ample.*)",
+    "ignoreInitial": false,
+    "persistent": true,
+    "usePolling": true,
+    "interval": 10000,
+    "depth": 1,
+    "awaitWriteFinish": {
+      "stabilityThreshold": 3000,
+      "pollInterval": 1000
+    },
+    "ignorePermissionErrors": false,
+    "atomic": true
+  },
+
+  "queue": {
+    "batchSize": 1,
+    "concurrent": 1,
+    "maxRetries": 3,
+    "retryDelay": 5000,
+    "deleteOnFail": true
+  },
+
+  "genre": {
+    "translations": {
+      "Action": ["Adventure"],
+      "Suspense Thriller": ["Crime", "Mystery", "Suspense", "Thriller"],
+      "Sci-fi": ["Science Fiction", "Science fiction", "Speculative"],
+      "Drama": ["Historical", "Historical Fiction", "Historical fiction", "Political", "Saga", "Satire", "Social", "Urban"]
+    },
+    "combinations": {
+      "Romantic Comedy": ["Romance", "Comedy"]
+    },
+    "weights": {
+      "Horror": 10,
+      "Sci-fi": 8,
+      "Action": 6,
+      "Fantasy": 4,
+      "Comedy": 3,
+      "Western": 2
+    }
+  },
+
+  "titlecase": {
+    "lowers": [
+      "A",
+      "An",
+      "The",
+      "And",
+      "But",
+      "Or",
+      "For",
+      "Nor",
+      "As",
+      "At",
+      "By",
+      "For",
+      "From",
+      "In",
+      "Into",
+      "Near",
+      "Of",
+      "On",
+      "Onto",
+      "To",
+      "With"
+    ],
+    "uppers": ["Id", "Tv"]
+  }
+}

+ 8 - 27
index.js

@@ -10,6 +10,8 @@ const FileSync = require('lowdb/adapters/FileSync');
 const chokidar = require('chokidar');
 const hbjs = require('handbrake-js');
 
+const settings = require('./data/settings.json');
+
 const args = minimist(process.argv.slice(2), {
   alias: {
     h: 'help',
@@ -43,35 +45,13 @@ String.prototype.toTitleCase = function() {
   });
   // Certain minor words should be left lowercase unless
   // they are the first or last words in the string
-  lowers = [
-    'A',
-    'An',
-    'The',
-    'And',
-    'But',
-    'Or',
-    'For',
-    'Nor',
-    'As',
-    'At',
-    'By',
-    'For',
-    'From',
-    'In',
-    'Into',
-    'Near',
-    'Of',
-    'On',
-    'Onto',
-    'To',
-    'With',
-  ];
+  lowers = (settings && settings.titlecase && settings.titlecase.lowers) || [];
   for (i = 0, j = lowers.length; i < j; i++)
     str = str.replace(new RegExp('\\s' + lowers[i] + '\\s', 'g'), function(txt) {
       return txt.toLowerCase();
     });
   // Certain words such as initialisms or acronyms should be left uppercase
-  uppers = ['Id', 'Tv'];
+  uppers = (settings && settings.titlecase && settings.titlecase.uppers) || [];
   for (i = 0, j = uppers.length; i < j; i++) str = str.replace(new RegExp('\\b' + uppers[i] + '\\b', 'g'), uppers[i].toUpperCase());
   return str;
 };
@@ -129,8 +109,8 @@ const processOutput = str => {
 
 const getFilesize = async file => {
   let stats = fs.existsSync(file) ? fs.statSync(file) : false;
-  let bytes = (stats) ? stats['size'] : 0;
-  return (bytes && bytes > 0) ? bytes/1024 : 0;
+  let bytes = stats ? stats['size'] : 0;
+  return bytes && bytes > 0 ? bytes / 1024 : 0;
 };
 
 // spawn a handbrake
@@ -239,7 +219,8 @@ const processFile = async file => {
   // do we already have an existing output that matches?
   if (fs.existsSync(output)) {
     let outputSize = await getFilesize(output); //get output filesize
-    if (outputSize > 100) { //make sure its bigger than 100k
+    if (outputSize > 100) {
+      //make sure its bigger than 100k
       processOutput(` -> "${path.basename(file)}" [skipping] (already processed)\n`);
       setFile(db, file, {
         output: output,