-
Notifications
You must be signed in to change notification settings - Fork 0
/
Tdarr_Plugin_Yankees4life_URL_Emby_Refresh.js
101 lines (91 loc) · 2.59 KB
/
Tdarr_Plugin_Yankees4life_URL_Emby_Refresh.js
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
/* eslint-disable linebreak-style */
module.exports.dependencies = [
'request',
];
/* eslint no-plusplus: ["error", { "allowForLoopAfterthoughts": true }] */
const details = () => ({
id: 'Tdarr_Plugin_Yankees4life_URL_Emby_Refresh',
Stage: 'Post-processing',
Name: 'Trigger Emby.',
Type: 'Video',
Operation: 'Transcode',
Description: `Connects to emby and triggers a library refresh.\n\n`,
Version: '1.0',
Tags: '3rd party,post-processing,configurable',
Inputs: [{
name: 'emby_address',
type: 'string',
defaultValue: 'http://192.168.0.10',
inputUI: {
type: 'text',
},
tooltip: `
Enter the IP address/URL for emby. Must include http(s)://
\\nExample:\\n
http://192.168.0.10
\\nExample:\\n
https://subdomain.domain.tld`,
},
{
name: 'emby_port',
type: 'string',
defaultValue: '3486',
inputUI: {
type: 'text',
},
tooltip: `
Enter the port Emby is using, default is 3468
\\nExample:\\n
3468`,
},
{
name: 'emby_api',
type: 'string',
defaultValue: 'none',
inputUI: {
type: 'text',
},
tooltip: `
Enter the api Emby is using, default is none
\\nExample:\\n
none`,
},
],
});
// eslint-disable-next-line no-unused-vars
const plugin = (file, librarySettings, inputs, otherArguments) => {
const lib = require('../methods/lib')();
// eslint-disable-next-line no-unused-vars,no-param-reassign
inputs = lib.loadDefaultValues(inputs, details);
// eslint-disable-next-line import/no-unresolved,import/no-extraneous-dependencies
const request = require('request');
// Set up required variables.
const ADDRESS = inputs.emby_address;
const PORT = inputs.emby_port;
const API = inputs.emby_api;
// Check if all inputs have been configured. If they haven't then exit plugin.
if (
inputs
&& inputs.emby_address === ''
&& inputs.emby_port === ''
&& inputs.emby_api === ''
) {
response.infoLog += '☒Plugin options have not been configured, please configure options. Skipping this plugin. \n';
response.processFile = false;
return response;
}
// Set content of request/post.
request.post({
url: `${ADDRESS}:${PORT}/emby/library/refresh?api_key=${API}`,
},
// eslint-disable-next-line no-unused-vars
(error, res, body) => {
if (error) {
// eslint-disable-next-line no-console
console.error(error);
}
});
return undefined;
};
module.exports.details = details;
module.exports.plugin = plugin;