-
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.
Merge pull request #43 from lawrencecurtis/patch-4
*darr manually import trigger scripts
- Loading branch information
Showing
4 changed files
with
165 additions
and
0 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
Scripts/Flow/Applications/Lidarr/Lidarr - Manually trigger import.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,55 @@ | ||
/** | ||
* @name Lidarr - Manually trigger import | ||
* @description Manually tells Lidarr to rescan, run after last file in folder moved | ||
* @author Lawrence / DoughDoze | ||
* @revision 3 | ||
* @param {string} URI Lidarr root URI and port (e.g. http://lidarr:8686) | ||
* @param {string} ApiKey API Key | ||
* @output Command sent | ||
*/ | ||
function Script(URI, ApiKey) { | ||
URI = URI || Variables['Lidarr.URI'] | ||
ApiKey = ApiKey || Variables['Lidarr.ApiKey'] | ||
|
||
const lidarr = new Lidarr(URI, ApiKey); | ||
if (lidarr.downloadedAlbumsScan(Variables.folder.FullName)) return 1; | ||
|
||
return -1; | ||
} | ||
|
||
class Lidarr { | ||
constructor(URI, ApiKey) { | ||
if (!URI || !ApiKey) { | ||
Logger.ELog("No credentials specified"); | ||
return -1; | ||
} | ||
|
||
this.URI = URI; | ||
this.ApiKey = ApiKey; | ||
} | ||
|
||
downloadedAlbumsScan(path) { | ||
let endpoint = `${this.URI}/api/v1/command`; | ||
let commandBody = { | ||
path: path, | ||
name: "DownloadedAlbumsScan", | ||
}; | ||
|
||
let jsonData = JSON.stringify(commandBody); | ||
http.DefaultRequestHeaders.Add("X-API-Key", this.ApiKey); | ||
let response = http.PostAsync(endpoint, JsonContent(jsonData)).Result; | ||
http.DefaultRequestHeaders.Remove("X-API-Key"); | ||
|
||
if (response.IsSuccessStatusCode) { | ||
let responseData = JSON.parse( | ||
response.Content.ReadAsStringAsync().Result | ||
); | ||
Logger.ILog(responseData); | ||
return responseData; | ||
} else { | ||
let error = response.Content.ReadAsStringAsync().Result; | ||
Logger.WLog("API error: " + error); | ||
return null; | ||
} | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
Scripts/Flow/Applications/Radarr/Radarr - Manually trigger import.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,55 @@ | ||
/** | ||
* @name Radarr - Manually trigger import | ||
* @description Manually tells Radarr to rescan, run after last file in folder moved | ||
* @author Lawrence / DoughDoze | ||
* @revision 1 | ||
* @param {string} URI Radarr root URI and port (e.g. http://radarr:7878) | ||
* @param {string} ApiKey API Key | ||
* @output Command sent | ||
*/ | ||
function Script(URI, ApiKey) { | ||
URI = URI || Variables["Radarr.URI"]; | ||
ApiKey = ApiKey || Variables["Radarr.ApiKey"]; | ||
|
||
const radarr = new Radarr(URI, ApiKey); | ||
if (radarr.downloadedMoviesScan(Variables.folder.FullName)) return 1; | ||
|
||
return -1; | ||
} | ||
|
||
class Radarr { | ||
constructor(URI, ApiKey) { | ||
if (!URI || !ApiKey) { | ||
Logger.ELog("No credentials specified"); | ||
return -1; | ||
} | ||
|
||
this.URI = URI; | ||
this.ApiKey = ApiKey; | ||
} | ||
|
||
downloadedMoviesScan(path) { | ||
let endpoint = `${this.URI}/api/v3/command`; | ||
let commandBody = { | ||
path: path, | ||
name: "downloadedMoviesScan", | ||
}; | ||
|
||
let jsonData = JSON.stringify(commandBody); | ||
http.DefaultRequestHeaders.Add("X-API-Key", this.ApiKey); | ||
let response = http.PostAsync(endpoint, JsonContent(jsonData)).Result; | ||
http.DefaultRequestHeaders.Remove("X-API-Key"); | ||
|
||
if (response.IsSuccessStatusCode) { | ||
let responseData = JSON.parse( | ||
response.Content.ReadAsStringAsync().Result | ||
); | ||
Logger.ILog(responseData); | ||
return responseData; | ||
} else { | ||
let error = response.Content.ReadAsStringAsync().Result; | ||
Logger.WLog("API error: " + error); | ||
return null; | ||
} | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
Scripts/Flow/Applications/Sonarr/Sonarr - Manually trigger import.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,55 @@ | ||
/** | ||
* @name Sonarr - Manually trigger import | ||
* @description Manually tells Sonarr to rescan, run after last file in folder moved | ||
* @author Lawrence / DoughDoze | ||
* @revision 1 | ||
* @param {string} URI Sonarr root URI and port (e.g. http://sonarr:8989) | ||
* @param {string} ApiKey API Key | ||
* @output Command sent | ||
*/ | ||
function Script(URI, ApiKey) { | ||
URI = URI || Variables['Sonarr.URI'] | ||
ApiKey = ApiKey || Variables['Sonarr.ApiKey'] | ||
|
||
const sonarr = new Sonarr(URI, ApiKey); | ||
if (sonarr.downloadedEpisodesScan(Variables.folder.FullName)) return 1; | ||
|
||
return -1; | ||
} | ||
|
||
class Sonarr { | ||
constructor(URI, ApiKey) { | ||
if (!URI || !ApiKey) { | ||
Logger.ELog("No credentials specified"); | ||
return -1; | ||
} | ||
|
||
this.URI = URI; | ||
this.ApiKey = ApiKey; | ||
} | ||
|
||
downloadedEpisodesScan(path) { | ||
let endpoint = `${this.URI}/api/v3/command`; | ||
let commandBody = { | ||
path: path, | ||
name: "downloadedEpisodesScan", | ||
}; | ||
|
||
let jsonData = JSON.stringify(commandBody); | ||
http.DefaultRequestHeaders.Add("X-API-Key", this.ApiKey); | ||
let response = http.PostAsync(endpoint, JsonContent(jsonData)).Result; | ||
http.DefaultRequestHeaders.Remove("X-API-Key"); | ||
|
||
if (response.IsSuccessStatusCode) { | ||
let responseData = JSON.parse( | ||
response.Content.ReadAsStringAsync().Result | ||
); | ||
Logger.ILog(responseData); | ||
return responseData; | ||
} else { | ||
let error = response.Content.ReadAsStringAsync().Result; | ||
Logger.WLog("API error: " + error); | ||
return null; | ||
} | ||
} | ||
} |
File renamed without changes.