RConverting context vars to be full FQDNs to provide compatibility to those not using contexts
This commit is contained in:
parent
b63c9641f3
commit
85e805bc8b
@ -1,6 +1,5 @@
|
|||||||
{
|
{
|
||||||
"baseURL": "http://dvr.example.com",
|
"plexPyURL": "http://dvr.example.com/plexpy",
|
||||||
"plexPyContext": "/plexpy",
|
|
||||||
"plexPyAPIKey": "abc1234",
|
"plexPyAPIKey": "abc1234",
|
||||||
"plexToken": "ABC1234ABC1234",
|
"plexToken": "ABC1234ABC1234",
|
||||||
"plexHost": "http://192.168.1.1",
|
"plexHost": "http://192.168.1.1",
|
||||||
@ -8,6 +7,7 @@
|
|||||||
"telegramToken": "123456789:ABCDEFG",
|
"telegramToken": "123456789:ABCDEFG",
|
||||||
"telegramChatID": "12345678",
|
"telegramChatID": "12345678",
|
||||||
"serverName": "Plex",
|
"serverName": "Plex",
|
||||||
"sonarrContext": "/tv",
|
"sonarrURL": "http://dvr.example.com/tv",
|
||||||
"sonarrAPIKey": "abc1234"
|
"sonarrAPIKey": "abc1234",
|
||||||
|
"excludeList": "A,bravo,char"
|
||||||
}
|
}
|
@ -9,8 +9,7 @@ import (
|
|||||||
|
|
||||||
// Config - This struct will hold configuration components.
|
// Config - This struct will hold configuration components.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
BaseURL string `json:"baseURL"`
|
PlexPyURL string `json:"plexPyURL"`
|
||||||
PlexPyContext string `json:"plexPyContext"`
|
|
||||||
PlexPyAPIKey string `json:"plexPyAPIKey"`
|
PlexPyAPIKey string `json:"plexPyAPIKey"`
|
||||||
PlexToken string `json:"plexToken"`
|
PlexToken string `json:"plexToken"`
|
||||||
PlexHost string `json:"plexHost"`
|
PlexHost string `json:"plexHost"`
|
||||||
@ -18,7 +17,7 @@ type Config struct {
|
|||||||
TelegramToken string `json:"telegramToken"`
|
TelegramToken string `json:"telegramToken"`
|
||||||
TelegramChatID string `json:"telegramChatID"`
|
TelegramChatID string `json:"telegramChatID"`
|
||||||
ServerName string `json:"serverName"`
|
ServerName string `json:"serverName"`
|
||||||
SonarrContext string `json:"sonarrContext"`
|
SonarrURL string `json:"sonarrURL"`
|
||||||
SonarrAPIKey string `json:"sonarrAPIKey"`
|
SonarrAPIKey string `json:"sonarrAPIKey"`
|
||||||
ExcludeList string `json:"excludeList"` // ExcludeList will be checked against any section.
|
ExcludeList string `json:"excludeList"` // ExcludeList will be checked against any section.
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ func LookupTVFileLocation(config config.Config, ids []int) []string {
|
|||||||
|
|
||||||
func DeleteSeriesFromSonarr(config config.Config, ids []int) {
|
func DeleteSeriesFromSonarr(config config.Config, ids []int) {
|
||||||
for _, i := range ids {
|
for _, i := range ids {
|
||||||
sonarrURL := fmt.Sprintf("%s%s%s%d%s%s", config.BaseURL, config.SonarrContext, "/api/series/", i, "/?deleteFiles=true&apikey=", config.SonarrAPIKey)
|
sonarrURL := fmt.Sprintf("%s%s%s%d%s%s", config.SonarrURL, "/api/series/", i, "/?deleteFiles=true&apikey=", config.SonarrAPIKey)
|
||||||
req, err := http.NewRequest(http.MethodDelete, sonarrURL, nil)
|
req, err := http.NewRequest(http.MethodDelete, sonarrURL, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
@ -56,7 +56,7 @@ func GetLibraryType(config config.Config, sectionID int) string {
|
|||||||
|
|
||||||
// GetCount will gather a count of media in a specific library, required for GetTitles.
|
// GetCount will gather a count of media in a specific library, required for GetTitles.
|
||||||
func GetCount(config config.Config, sectionID int) int {
|
func GetCount(config config.Config, sectionID int) int {
|
||||||
countURL := fmt.Sprintf("%s%s%s%s%s%d", config.BaseURL, config.PlexPyContext, "/api/v2?apikey=", config.PlexPyAPIKey, "&cmd=get_library§ion_id=", sectionID)
|
countURL := fmt.Sprintf("%s%s%s%s%s%d", config.PlexPyURL, "/api/v2?apikey=", config.PlexPyAPIKey, "&cmd=get_library§ion_id=", sectionID)
|
||||||
req, err := http.NewRequest(http.MethodGet, countURL, nil)
|
req, err := http.NewRequest(http.MethodGet, countURL, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
@ -90,7 +90,7 @@ func GetCount(config config.Config, sectionID int) int {
|
|||||||
func GetTitles(config config.Config, sectionID int, days int) ([]int, []string) {
|
func GetTitles(config config.Config, sectionID int, days int) ([]int, []string) {
|
||||||
count := GetCount(config, sectionID)
|
count := GetCount(config, sectionID)
|
||||||
|
|
||||||
titlesURL := fmt.Sprintf("%s%s%s%s%s%d%s%d", config.BaseURL, config.PlexPyContext, "/api/v2?apikey=", config.PlexPyAPIKey, "&cmd=get_library_media_info§ion_id=", sectionID, "&order_column=last_played&refresh=true&order_dir=asc&length=", count)
|
titlesURL := fmt.Sprintf("%s%s%s%s%s%d%s%d", config.PlexPyURL, "/api/v2?apikey=", config.PlexPyAPIKey, "&cmd=get_library_media_info§ion_id=", sectionID, "&order_column=last_played&refresh=true&order_dir=asc&length=", count)
|
||||||
|
|
||||||
req, err := http.NewRequest(http.MethodGet, titlesURL, nil)
|
req, err := http.NewRequest(http.MethodGet, titlesURL, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -162,7 +162,7 @@ func GetTitles(config config.Config, sectionID int, days int) ([]int, []string)
|
|||||||
// GetSonarrIDs gets the IDs to delete from the title list in PlexPy.
|
// GetSonarrIDs gets the IDs to delete from the title list in PlexPy.
|
||||||
func GetSonarrIDs(config config.Config, titles []string) []int {
|
func GetSonarrIDs(config config.Config, titles []string) []int {
|
||||||
ids := make([]int, 0)
|
ids := make([]int, 0)
|
||||||
sonarrURL := fmt.Sprintf("%s%s%s%s", config.BaseURL, config.SonarrContext, "/api/series?apikey=", config.SonarrAPIKey)
|
sonarrURL := fmt.Sprintf("%s%s%s%s", config.SonarrURL, "/api/series?apikey=", config.SonarrAPIKey)
|
||||||
req, err := http.NewRequest(http.MethodGet, sonarrURL, nil)
|
req, err := http.NewRequest(http.MethodGet, sonarrURL, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
Loading…
Reference in New Issue
Block a user