-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconvert.js
More file actions
executable file
·114 lines (109 loc) · 2.56 KB
/
convert.js
File metadata and controls
executable file
·114 lines (109 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/usr/bin/env node
'use strict';
var prompt = require('prompt'),
fs = require('fs'),
path = require('path-extra');
var configPath = path.join(path.homedir(), ".plex-processor.json");
// Check to see if we can get the config file.
fs.exists(configPath, function (exists) {
var configuration = {};
if (exists) {
try {
configuration = JSON.parse(fs.readFileSync(configPath));
} catch (exception) {
configuration = {};
}
}
if (exists && configuration) {
prompt.start();
prompt.get({
properties: {
'convert': {
description: 'Type to convert [movie | tv]',
default: 'movie',
required: true,
pattern: /^(movie|tv)$/,
message: 'Please enter a valid type.'
}
}
}, function (err, result) {
if (result) {
var convert = require('./lib/' + result.convert);
convert.run(configuration);
}
});
} else {
prompt.start();
prompt.get({
properties: {
'preset': {
description: 'Choose a Handbrake preset',
required: true,
default: 'AppleTV 3'
},
'movie_input': {
description: 'Path to movie input directory',
required: true,
message: 'Please enter a valid directory.',
conform: function (value) {
if (fs.existsSync(value)) {
return true;
}
return false;
}
},
'movie_output': {
description: 'Path to movie output directory',
required: true,
message: 'Please enter a valid directory.',
conform: function (value) {
if (fs.existsSync(value)) {
return true;
}
return false;
}
},
'tv_input': {
description: 'Path to TV shows input directory',
required: true,
message: 'Please enter a valid directory.',
conform: function (value) {
if (fs.existsSync(value)) {
return true;
}
return false;
}
},
'tv_output': {
description: 'Path to TV shows output directory',
required: true,
message: 'Please enter a valid directory.',
conform: function (value) {
if (fs.existsSync(value)) {
return true;
}
return false;
}
},
'archive': {
description: 'Path to archive directory',
required: true,
message: 'Please enter a valid directory.',
conform: function (value) {
if (fs.existsSync(value)) {
return true;
}
return false;
}
}
}
}, function (err, result) {
if (result) {
fs.writeFile(configPath, JSON.stringify(result, null, "\t"), function () {
console.log('Configuration saved. Please restart.');
process.exit();
});
}
});
}
});