Compare commits
32 Commits
Author | SHA1 | Date | |
---|---|---|---|
37adca95f8 | |||
85e805bc8b | |||
b63c9641f3 | |||
33d7c5eaa7 | |||
f3424d83bc | |||
|
b1bbda788c | ||
|
fe5109b75f | ||
|
42439d61b4 | ||
|
cd44fb971d | ||
78f8a74c0e | |||
946420bcc3 | |||
d028398661 | |||
8257268df5 | |||
97ebf34be0 | |||
f381b5421e | |||
|
9cfd5c4274 | ||
|
b0d51ad15e | ||
|
0a8b11e154 | ||
|
cbafaa5781 | ||
|
7c2af867b0 | ||
|
b86a80b001 | ||
|
f890d7f0ee | ||
|
31dc49eae4 | ||
|
267a891e4d | ||
|
bba80e3005 | ||
|
8330101154 | ||
|
8997e6ae1a | ||
|
91c2214082 | ||
|
b175b02b87 | ||
|
b6b5814588 | ||
|
81797f66ca | ||
3e5695a802 |
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,2 +1,3 @@
|
|||||||
config.json
|
config.json
|
||||||
housekeeper
|
housekeeper
|
||||||
|
.vscode
|
63
cmd/main.go
63
cmd/main.go
@ -3,6 +3,9 @@ package main
|
|||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
"log"
|
"log"
|
||||||
|
"sort"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"git.linuxrocker.com/mattburchett/Housekeeper/pkg/communicator"
|
"git.linuxrocker.com/mattburchett/Housekeeper/pkg/communicator"
|
||||||
"git.linuxrocker.com/mattburchett/Housekeeper/pkg/config"
|
"git.linuxrocker.com/mattburchett/Housekeeper/pkg/config"
|
||||||
@ -13,14 +16,16 @@ import (
|
|||||||
func main() {
|
func main() {
|
||||||
var c string
|
var c string
|
||||||
var days int
|
var days int
|
||||||
var sectionID int
|
var sectionID string
|
||||||
var check bool
|
var check bool
|
||||||
|
var text bool
|
||||||
var delete bool
|
var delete bool
|
||||||
|
|
||||||
flag.StringVar(&c, "config", "", "Configuration to load")
|
flag.StringVar(&c, "config", "", "Configuration to load")
|
||||||
flag.IntVar(&days, "days", 0, "How many days of inactivity to look for on Plex.")
|
flag.IntVar(&days, "days", 0, "How many days of inactivity to look for on Plex.")
|
||||||
flag.IntVar(§ionID, "sectionid", 0, "Plex Section ID")
|
flag.StringVar(§ionID, "sectionid", "", "Plex Section ID. Multiples can be specified (separated by a comma). Ex: 1,2")
|
||||||
flag.BoolVar(&check, "check", true, "Perform only a check. This will send the message out to Telegram with what can be removed. Does not delete.")
|
flag.BoolVar(&check, "check", true, "Perform only a check. This will send the message out to Telegram with what can be removed. Does not delete.")
|
||||||
|
flag.BoolVar(&text, "text", false, "This will override the communication to Telegram and print to stdout.")
|
||||||
flag.BoolVar(&delete, "delete", false, "Perform the delete task.")
|
flag.BoolVar(&delete, "delete", false, "Perform the delete task.")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
@ -28,7 +33,7 @@ func main() {
|
|||||||
if c == "" {
|
if c == "" {
|
||||||
log.Fatal("You need to specify a configuration file.")
|
log.Fatal("You need to specify a configuration file.")
|
||||||
}
|
}
|
||||||
if sectionID == 0 {
|
if sectionID == "" {
|
||||||
log.Fatal("You need to specify a section ID for Plex.")
|
log.Fatal("You need to specify a section ID for Plex.")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,21 +42,47 @@ func main() {
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
ids, titles := locator.GetTitles(cfg, sectionID, days)
|
sectionIds := strings.Split(sectionID, ",")
|
||||||
|
titlesFullList := make([]string, 0)
|
||||||
|
|
||||||
|
for _, section := range sectionIds {
|
||||||
|
sectionIDConv, _ := strconv.Atoi(section)
|
||||||
|
libraryType := locator.GetLibraryType(cfg, sectionIDConv)
|
||||||
|
|
||||||
|
ids, titles := locator.GetTitles(cfg, sectionIDConv, days)
|
||||||
|
|
||||||
|
for _, title := range titles {
|
||||||
|
titlesFullList = append(titlesFullList, title)
|
||||||
|
}
|
||||||
|
|
||||||
|
if delete {
|
||||||
|
if libraryType == "movie" {
|
||||||
|
files := eraser.LookupMovieFileLocation(cfg, ids)
|
||||||
|
err = eraser.DeleteFiles(delete, files)
|
||||||
|
if err != nil {
|
||||||
|
log.Println(err)
|
||||||
|
}
|
||||||
|
} else if libraryType == "show" {
|
||||||
|
// files := eraser.LookupTVFileLocation(cfg, ids)
|
||||||
|
sonarrIDs := locator.GetSonarrIDs(cfg, titles)
|
||||||
|
eraser.DeleteSeriesFromSonarr(cfg, sonarrIDs)
|
||||||
|
// err = eraser.DeleteFiles(delete, files)
|
||||||
|
// if err != nil {
|
||||||
|
// log.Println(err)
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if check {
|
if check {
|
||||||
err = communicator.TelegramPost(cfg, titles)
|
sort.Strings(titlesFullList)
|
||||||
if err != nil {
|
if text {
|
||||||
log.Fatal(err)
|
communicator.StdoutPost(titlesFullList)
|
||||||
|
} else {
|
||||||
|
err = communicator.TelegramPost(cfg, titlesFullList)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if delete {
|
|
||||||
files := eraser.LookupFileLocation(cfg, ids)
|
|
||||||
err = eraser.DeleteMedia(delete, files)
|
|
||||||
if err != nil {
|
|
||||||
log.Println(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
{
|
{
|
||||||
"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",
|
||||||
"plexPort": 32400,
|
"plexPort": 32400,
|
||||||
"telegramToken": "123456789:ABCDEFG",
|
"telegramToken": "123456789:ABCDEFG",
|
||||||
"telegramChatID": "12345678",
|
"telegramChatID": "12345678",
|
||||||
"serverName": "Plex"
|
"serverName": "Plex",
|
||||||
|
"sonarrURL": "http://dvr.example.com/tv",
|
||||||
|
"sonarrAPIKey": "abc1234",
|
||||||
|
"excludeList": "A,bravo,char"
|
||||||
}
|
}
|
3
go.mod
Normal file
3
go.mod
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
module git.linuxrocker.com/mattburchett/Housekeeper
|
||||||
|
|
||||||
|
go 1.15
|
@ -11,28 +11,49 @@ import (
|
|||||||
"git.linuxrocker.com/mattburchett/Housekeeper/pkg/config"
|
"git.linuxrocker.com/mattburchett/Housekeeper/pkg/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type error interface {
|
||||||
|
Error() string
|
||||||
|
}
|
||||||
|
|
||||||
// TelegramPost will send a message to a specific ChatID in Telegram containing the list of items to be cleaned with this cleaner.
|
// TelegramPost will send a message to a specific ChatID in Telegram containing the list of items to be cleaned with this cleaner.
|
||||||
func TelegramPost(config config.Config, titles []string) error {
|
func TelegramPost(config config.Config, titles []string) error {
|
||||||
url := "https://api.telegram.org/bot" + config.TelegramToken + "/sendMessage"
|
var err error
|
||||||
|
if len(titles) != 0 {
|
||||||
|
url := "https://api.telegram.org/bot" + config.TelegramToken + "/sendMessage"
|
||||||
|
|
||||||
values := map[string]string{"chat_id": config.TelegramChatID, "text": "The following items are to be removed from " + config.ServerName + " in 24 hours. Please go to Plex and start the title to keep it on " + config.ServerName + ". You do not need to keep watching, just hit play and load a few seconds.\n\n" + fmt.Sprintf("%v", strings.Join(titles, "\n")), "disable_notifications": "true"}
|
values := map[string]string{"chat_id": config.TelegramChatID, "text": "The following items are to be removed from " + config.ServerName + " in 24 hours. Please go to Plex and start the title to keep it on " + config.ServerName + ". You do not need to keep watching, just hit play and load a few seconds.\n\n" + fmt.Sprintf("%v", strings.Join(titles, "\n")), "disable_notifications": "true"}
|
||||||
|
|
||||||
jsonValue, _ := json.Marshal(values)
|
jsonValue, _ := json.Marshal(values)
|
||||||
req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonValue))
|
req, err := http.NewRequest("POST", url, bytes.NewBuffer(jsonValue))
|
||||||
req.Header.Set("X-Custom-Header", "Housekeeper")
|
req.Header.Set("X-Custom-Header", "Housekeeper")
|
||||||
req.Header.Set("Content-Type", "application/json")
|
req.Header.Set("Content-Type", "application/json")
|
||||||
|
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
resp, err := client.Do(req)
|
resp, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
fmt.Println("response Status:", resp.Status)
|
||||||
|
fmt.Println("response Headers:", resp.Header)
|
||||||
|
body, _ := ioutil.ReadAll(resp.Body)
|
||||||
|
fmt.Println("response Body:", string(body))
|
||||||
|
|
||||||
|
} else {
|
||||||
|
fmt.Println("There are no titles, therefore no message to send!")
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
|
||||||
|
|
||||||
fmt.Println("response Status:", resp.Status)
|
|
||||||
fmt.Println("response Headers:", resp.Header)
|
|
||||||
body, _ := ioutil.ReadAll(resp.Body)
|
|
||||||
fmt.Println("response Body:", string(body))
|
|
||||||
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// StdoutPost will relay the titles out to stdout.
|
||||||
|
func StdoutPost(titles []string) {
|
||||||
|
if len(titles) != 0 {
|
||||||
|
for _, title := range titles {
|
||||||
|
fmt.Println(title)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
fmt.Println("There are no titles. Nothing to display.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -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,6 +17,9 @@ 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"`
|
||||||
|
SonarrURL string `json:"sonarrURL"`
|
||||||
|
SonarrAPIKey string `json:"sonarrAPIKey"`
|
||||||
|
ExcludeList string `json:"excludeList"` // ExcludeList will be checked against any section.
|
||||||
}
|
}
|
||||||
|
|
||||||
//GetConfig gets the configuration values for the api using the file in the supplied configPath.
|
//GetConfig gets the configuration values for the api using the file in the supplied configPath.
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package eraser
|
package eraser
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
@ -13,17 +14,14 @@ import (
|
|||||||
"git.linuxrocker.com/mattburchett/Housekeeper/pkg/model"
|
"git.linuxrocker.com/mattburchett/Housekeeper/pkg/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
// LookupFileLocation will gather a list of Information based on IDs returned by locator.GetTitles
|
// LookupMovieFileLocation will gather a list of Information based on IDs returned by locator.GetTitles
|
||||||
func LookupFileLocation(config config.Config, ids []int) []string {
|
func LookupMovieFileLocation(config config.Config, ids []int) []string {
|
||||||
fileList := make([]string, 0)
|
fileList := make([]string, 0)
|
||||||
|
|
||||||
for _, i := range ids {
|
for _, i := range ids {
|
||||||
plexURL := fmt.Sprintf("%s:%d%s%d%s%s", config.PlexHost, config.PlexPort, "/library/metadata/", i, "/?X-Plex-Token=", config.PlexToken)
|
plexURL := fmt.Sprintf("%s:%d%s%d%s%s", config.PlexHost, config.PlexPort, "/library/metadata/", i, "/?X-Plex-Token=", config.PlexToken)
|
||||||
|
|
||||||
req, err := http.NewRequest(http.MethodGet, plexURL, nil)
|
req, err := http.NewRequest(http.MethodGet, plexURL, nil)
|
||||||
if err != nil {
|
|
||||||
log.Fatal(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
httpClient := http.Client{}
|
httpClient := http.Client{}
|
||||||
req.Header.Set("User-Agent", "Housekeeper")
|
req.Header.Set("User-Agent", "Housekeeper")
|
||||||
@ -41,22 +39,102 @@ func LookupFileLocation(config config.Config, ids []int) []string {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
plexModel := model.XMLPlexAPI{}
|
plexModel := model.XMLPlexMovieAPI{}
|
||||||
xml.Unmarshal(body, &plexModel)
|
xml.Unmarshal(body, &plexModel)
|
||||||
fileList = append(fileList, filepath.Dir(plexModel.Video.Media.Part.File))
|
fileList = append(fileList, filepath.Dir(plexModel.Video.Media.Part.File))
|
||||||
}
|
}
|
||||||
return fileList
|
return fileList
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteMedia will actually perform the deletion.
|
// LookupTVFileLocation will gather a list of Information based on IDs returned by locator.GetTitles
|
||||||
func DeleteMedia(delete bool, files []string) error {
|
func LookupTVFileLocation(config config.Config, ids []int) []string {
|
||||||
|
fileList := make([]string, 0)
|
||||||
|
m := make(map[string]bool)
|
||||||
|
results := make([]string, 0)
|
||||||
|
|
||||||
|
for _, i := range ids {
|
||||||
|
plexURL := fmt.Sprintf("%s:%d%s%d%s%s", config.PlexHost, config.PlexPort, "/library/metadata/", i, "/allLeaves/?X-Plex-Token=", config.PlexToken)
|
||||||
|
|
||||||
|
req, err := http.NewRequest(http.MethodGet, plexURL, nil)
|
||||||
|
|
||||||
|
httpClient := http.Client{}
|
||||||
|
req.Header.Set("User-Agent", "Housekeeper")
|
||||||
|
|
||||||
|
res, getErr := httpClient.Do(req)
|
||||||
|
if getErr != nil {
|
||||||
|
log.Fatal(getErr)
|
||||||
|
}
|
||||||
|
|
||||||
|
body, readErr := ioutil.ReadAll(res.Body)
|
||||||
|
if readErr != nil {
|
||||||
|
log.Fatal(readErr)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
plexModel := model.XMLPlexTVAPI{}
|
||||||
|
xml.Unmarshal(body, &plexModel)
|
||||||
|
|
||||||
|
plexTV := plexModel.Video
|
||||||
|
|
||||||
|
for _, i := range plexTV {
|
||||||
|
fileList = append(fileList, filepath.Dir(i.Media.Part.File))
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, r := range fileList {
|
||||||
|
if _, ok := m[r]; !ok {
|
||||||
|
m[r] = true
|
||||||
|
results = append(results, r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return results
|
||||||
|
}
|
||||||
|
|
||||||
|
func DeleteSeriesFromSonarr(config config.Config, ids []int) {
|
||||||
|
for _, i := range ids {
|
||||||
|
sonarrURL := fmt.Sprintf("%s%s%d%s%s", config.SonarrURL, "/api/series/", i, "/?deleteFiles=true&apikey=", config.SonarrAPIKey)
|
||||||
|
req, err := http.NewRequest(http.MethodDelete, sonarrURL, nil)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
httpClient := http.Client{}
|
||||||
|
req.Header.Set("User-Agent", "Housekeeper")
|
||||||
|
|
||||||
|
res, getErr := httpClient.Do(req)
|
||||||
|
if getErr != nil {
|
||||||
|
log.Fatal(getErr)
|
||||||
|
}
|
||||||
|
|
||||||
|
body, readErr := ioutil.ReadAll(res.Body)
|
||||||
|
if readErr != nil {
|
||||||
|
log.Fatal(readErr)
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteModel := model.SonarrResponse{}
|
||||||
|
jsonErr := json.Unmarshal(body, &deleteModel)
|
||||||
|
if jsonErr != nil {
|
||||||
|
log.Fatal(jsonErr)
|
||||||
|
}
|
||||||
|
|
||||||
|
// if strings.Contains("does not exist", deleteModel.Message) {
|
||||||
|
// log.Printf("The following ID does not exist: %v", i)
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteFiles will actually perform the deletion.
|
||||||
|
func DeleteFiles(delete bool, files []string) error {
|
||||||
var err error
|
var err error
|
||||||
if delete {
|
if delete {
|
||||||
for _, i := range files {
|
for _, i := range files {
|
||||||
fmt.Printf("Removing %v\n", i)
|
fmt.Printf("Removing %v\n", i)
|
||||||
err = os.RemoveAll(i)
|
err = os.RemoveAll(i)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Println(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,21 +2,61 @@ package locator
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"encoding/xml"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"git.linuxrocker.com/mattburchett/Housekeeper/pkg/config"
|
"git.linuxrocker.com/mattburchett/Housekeeper/pkg/config"
|
||||||
"git.linuxrocker.com/mattburchett/Housekeeper/pkg/model"
|
"git.linuxrocker.com/mattburchett/Housekeeper/pkg/model"
|
||||||
"git.linuxrocker.com/mattburchett/Housekeeper/pkg/util"
|
"git.linuxrocker.com/mattburchett/Housekeeper/pkg/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// GetLibraryType checks to see what type the library is.
|
||||||
|
func GetLibraryType(config config.Config, sectionID int) string {
|
||||||
|
typeURL := fmt.Sprintf("%s:%d%s%d%s%s", config.PlexHost, config.PlexPort, "/library/sections/", sectionID, "/?X-Plex-Token=", config.PlexToken)
|
||||||
|
|
||||||
|
req, err := http.NewRequest(http.MethodGet, typeURL, nil)
|
||||||
|
httpClient := http.Client{}
|
||||||
|
req.Header.Set("User-Agent", "Housekeeper")
|
||||||
|
|
||||||
|
res, getErr := httpClient.Do(req)
|
||||||
|
if getErr != nil {
|
||||||
|
log.Fatal(getErr)
|
||||||
|
}
|
||||||
|
|
||||||
|
body, readErr := ioutil.ReadAll(res.Body)
|
||||||
|
if readErr != nil {
|
||||||
|
log.Fatal(readErr)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
typeModel := model.XMLPlexLibraryType{}
|
||||||
|
xml.Unmarshal(body, &typeModel)
|
||||||
|
|
||||||
|
var libraryType string
|
||||||
|
|
||||||
|
if typeModel.Thumb == "/:/resources/movie.png" {
|
||||||
|
libraryType = "movie"
|
||||||
|
} else if typeModel.Thumb == "/:/resources/show.png" {
|
||||||
|
libraryType = "show"
|
||||||
|
} else {
|
||||||
|
log.Fatal("Unsupported library type found. This app only supports movies and shows.")
|
||||||
|
}
|
||||||
|
|
||||||
|
return libraryType
|
||||||
|
}
|
||||||
|
|
||||||
// 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%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)
|
||||||
@ -50,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%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 {
|
||||||
@ -82,7 +122,20 @@ func GetTitles(config config.Config, sectionID int, days int) ([]int, []string)
|
|||||||
|
|
||||||
epoch := util.SubtractedEpoch(days)
|
epoch := util.SubtractedEpoch(days)
|
||||||
|
|
||||||
|
exclude := strings.Split(config.ExcludeList, ",")
|
||||||
|
|
||||||
|
var breakOut bool
|
||||||
|
|
||||||
for _, i := range data {
|
for _, i := range data {
|
||||||
|
for _, ex := range exclude {
|
||||||
|
if strings.Contains(i.Title, ex) {
|
||||||
|
breakOut = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if breakOut {
|
||||||
|
breakOut = false
|
||||||
|
continue
|
||||||
|
}
|
||||||
if int64(i.LastPlayed) <= epoch && int64(i.LastPlayed) != 0 {
|
if int64(i.LastPlayed) <= epoch && int64(i.LastPlayed) != 0 {
|
||||||
titles = append(titles, i.Title)
|
titles = append(titles, i.Title)
|
||||||
strirk, err := strconv.Atoi(i.RatingKey)
|
strirk, err := strconv.Atoi(i.RatingKey)
|
||||||
@ -105,3 +158,42 @@ func GetTitles(config config.Config, sectionID int, days int) ([]int, []string)
|
|||||||
sort.Strings(titles)
|
sort.Strings(titles)
|
||||||
return ids, titles
|
return ids, titles
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetSonarrIDs gets the IDs to delete from the title list in PlexPy.
|
||||||
|
func GetSonarrIDs(config config.Config, titles []string) []int {
|
||||||
|
ids := make([]int, 0)
|
||||||
|
sonarrURL := fmt.Sprintf("%s%s%s", config.SonarrURL, "/api/series?apikey=", config.SonarrAPIKey)
|
||||||
|
req, err := http.NewRequest(http.MethodGet, sonarrURL, nil)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
httpClient := http.Client{}
|
||||||
|
req.Header.Set("User-Agent", "Housekeeper")
|
||||||
|
|
||||||
|
res, getErr := httpClient.Do(req)
|
||||||
|
if getErr != nil {
|
||||||
|
log.Fatal(getErr)
|
||||||
|
}
|
||||||
|
|
||||||
|
body, readErr := ioutil.ReadAll(res.Body)
|
||||||
|
if readErr != nil {
|
||||||
|
log.Fatal(readErr)
|
||||||
|
}
|
||||||
|
|
||||||
|
sonarrModel := model.SonarrSeries{}
|
||||||
|
jsonErr := json.Unmarshal(body, &sonarrModel)
|
||||||
|
if jsonErr != nil {
|
||||||
|
log.Fatal(jsonErr)
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, r := range sonarrModel {
|
||||||
|
for _, s := range titles {
|
||||||
|
if r.Title == s {
|
||||||
|
ids = append(ids, r.ID)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ids
|
||||||
|
}
|
||||||
|
237
pkg/model/eraser_model.go
Normal file
237
pkg/model/eraser_model.go
Normal file
@ -0,0 +1,237 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import "encoding/xml"
|
||||||
|
|
||||||
|
// XMLPlexMovieAPI - This is the XML version of the Library.
|
||||||
|
type XMLPlexMovieAPI struct {
|
||||||
|
XMLName xml.Name `xml:"MediaContainer"`
|
||||||
|
Text string `xml:",chardata"`
|
||||||
|
Size string `xml:"size,attr"`
|
||||||
|
AllowSync string `xml:"allowSync,attr"`
|
||||||
|
Identifier string `xml:"identifier,attr"`
|
||||||
|
LibrarySectionID string `xml:"librarySectionID,attr"`
|
||||||
|
LibrarySectionTitle string `xml:"librarySectionTitle,attr"`
|
||||||
|
LibrarySectionUUID string `xml:"librarySectionUUID,attr"`
|
||||||
|
MediaTagPrefix string `xml:"mediaTagPrefix,attr"`
|
||||||
|
MediaTagVersion string `xml:"mediaTagVersion,attr"`
|
||||||
|
Video struct {
|
||||||
|
Text string `xml:",chardata"`
|
||||||
|
RatingKey string `xml:"ratingKey,attr"`
|
||||||
|
Key string `xml:"key,attr"`
|
||||||
|
GUID string `xml:"guid,attr"`
|
||||||
|
LibrarySectionTitle string `xml:"librarySectionTitle,attr"`
|
||||||
|
LibrarySectionID string `xml:"librarySectionID,attr"`
|
||||||
|
LibrarySectionKey string `xml:"librarySectionKey,attr"`
|
||||||
|
Studio string `xml:"studio,attr"`
|
||||||
|
Type string `xml:"type,attr"`
|
||||||
|
Title string `xml:"title,attr"`
|
||||||
|
ContentRating string `xml:"contentRating,attr"`
|
||||||
|
Summary string `xml:"summary,attr"`
|
||||||
|
Rating string `xml:"rating,attr"`
|
||||||
|
AudienceRating string `xml:"audienceRating,attr"`
|
||||||
|
Year string `xml:"year,attr"`
|
||||||
|
Tagline string `xml:"tagline,attr"`
|
||||||
|
Thumb string `xml:"thumb,attr"`
|
||||||
|
Art string `xml:"art,attr"`
|
||||||
|
Duration string `xml:"duration,attr"`
|
||||||
|
OriginallyAvailableAt string `xml:"originallyAvailableAt,attr"`
|
||||||
|
AddedAt string `xml:"addedAt,attr"`
|
||||||
|
UpdatedAt string `xml:"updatedAt,attr"`
|
||||||
|
AudienceRatingImage string `xml:"audienceRatingImage,attr"`
|
||||||
|
ChapterSource string `xml:"chapterSource,attr"`
|
||||||
|
PrimaryExtraKey string `xml:"primaryExtraKey,attr"`
|
||||||
|
RatingImage string `xml:"ratingImage,attr"`
|
||||||
|
Media struct {
|
||||||
|
Text string `xml:",chardata"`
|
||||||
|
VideoResolution string `xml:"videoResolution,attr"`
|
||||||
|
ID string `xml:"id,attr"`
|
||||||
|
Duration string `xml:"duration,attr"`
|
||||||
|
Bitrate string `xml:"bitrate,attr"`
|
||||||
|
Width string `xml:"width,attr"`
|
||||||
|
Height string `xml:"height,attr"`
|
||||||
|
AspectRatio string `xml:"aspectRatio,attr"`
|
||||||
|
AudioChannels string `xml:"audioChannels,attr"`
|
||||||
|
AudioCodec string `xml:"audioCodec,attr"`
|
||||||
|
VideoCodec string `xml:"videoCodec,attr"`
|
||||||
|
Container string `xml:"container,attr"`
|
||||||
|
VideoFrameRate string `xml:"videoFrameRate,attr"`
|
||||||
|
AudioProfile string `xml:"audioProfile,attr"`
|
||||||
|
VideoProfile string `xml:"videoProfile,attr"`
|
||||||
|
Part struct {
|
||||||
|
Text string `xml:",chardata"`
|
||||||
|
ID string `xml:"id,attr"`
|
||||||
|
Key string `xml:"key,attr"`
|
||||||
|
Duration string `xml:"duration,attr"`
|
||||||
|
File string `xml:"file,attr"`
|
||||||
|
Size string `xml:"size,attr"`
|
||||||
|
AudioProfile string `xml:"audioProfile,attr"`
|
||||||
|
Container string `xml:"container,attr"`
|
||||||
|
VideoProfile string `xml:"videoProfile,attr"`
|
||||||
|
Stream []struct {
|
||||||
|
Text string `xml:",chardata"`
|
||||||
|
ID string `xml:"id,attr"`
|
||||||
|
StreamType string `xml:"streamType,attr"`
|
||||||
|
Default string `xml:"default,attr"`
|
||||||
|
Codec string `xml:"codec,attr"`
|
||||||
|
Index string `xml:"index,attr"`
|
||||||
|
Bitrate string `xml:"bitrate,attr"`
|
||||||
|
Language string `xml:"language,attr"`
|
||||||
|
LanguageCode string `xml:"languageCode,attr"`
|
||||||
|
BitDepth string `xml:"bitDepth,attr"`
|
||||||
|
ChromaLocation string `xml:"chromaLocation,attr"`
|
||||||
|
ChromaSubsampling string `xml:"chromaSubsampling,attr"`
|
||||||
|
FrameRate string `xml:"frameRate,attr"`
|
||||||
|
HasScalingMatrix string `xml:"hasScalingMatrix,attr"`
|
||||||
|
Height string `xml:"height,attr"`
|
||||||
|
Level string `xml:"level,attr"`
|
||||||
|
Profile string `xml:"profile,attr"`
|
||||||
|
RefFrames string `xml:"refFrames,attr"`
|
||||||
|
ScanType string `xml:"scanType,attr"`
|
||||||
|
Title string `xml:"title,attr"`
|
||||||
|
Width string `xml:"width,attr"`
|
||||||
|
DisplayTitle string `xml:"displayTitle,attr"`
|
||||||
|
Selected string `xml:"selected,attr"`
|
||||||
|
Channels string `xml:"channels,attr"`
|
||||||
|
AudioChannelLayout string `xml:"audioChannelLayout,attr"`
|
||||||
|
SamplingRate string `xml:"samplingRate,attr"`
|
||||||
|
Key string `xml:"key,attr"`
|
||||||
|
} `xml:"Stream"`
|
||||||
|
} `xml:"Part"`
|
||||||
|
} `xml:"Media"`
|
||||||
|
Genre []struct {
|
||||||
|
Text string `xml:",chardata"`
|
||||||
|
ID string `xml:"id,attr"`
|
||||||
|
Filter string `xml:"filter,attr"`
|
||||||
|
Tag string `xml:"tag,attr"`
|
||||||
|
} `xml:"Genre"`
|
||||||
|
Director struct {
|
||||||
|
Text string `xml:",chardata"`
|
||||||
|
ID string `xml:"id,attr"`
|
||||||
|
Filter string `xml:"filter,attr"`
|
||||||
|
Tag string `xml:"tag,attr"`
|
||||||
|
} `xml:"Director"`
|
||||||
|
Writer []struct {
|
||||||
|
Text string `xml:",chardata"`
|
||||||
|
ID string `xml:"id,attr"`
|
||||||
|
Filter string `xml:"filter,attr"`
|
||||||
|
Tag string `xml:"tag,attr"`
|
||||||
|
} `xml:"Writer"`
|
||||||
|
Producer []struct {
|
||||||
|
Text string `xml:",chardata"`
|
||||||
|
ID string `xml:"id,attr"`
|
||||||
|
Filter string `xml:"filter,attr"`
|
||||||
|
Tag string `xml:"tag,attr"`
|
||||||
|
} `xml:"Producer"`
|
||||||
|
Country struct {
|
||||||
|
Text string `xml:",chardata"`
|
||||||
|
ID string `xml:"id,attr"`
|
||||||
|
Filter string `xml:"filter,attr"`
|
||||||
|
Tag string `xml:"tag,attr"`
|
||||||
|
} `xml:"Country"`
|
||||||
|
Role []struct {
|
||||||
|
Text string `xml:",chardata"`
|
||||||
|
ID string `xml:"id,attr"`
|
||||||
|
Filter string `xml:"filter,attr"`
|
||||||
|
Tag string `xml:"tag,attr"`
|
||||||
|
Role string `xml:"role,attr"`
|
||||||
|
Thumb string `xml:"thumb,attr"`
|
||||||
|
} `xml:"Role"`
|
||||||
|
} `xml:"Video"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// XMLPlexTVAPI - This is the XML version of the Library.
|
||||||
|
type XMLPlexTVAPI struct {
|
||||||
|
XMLName xml.Name `xml:"MediaContainer"`
|
||||||
|
Text string `xml:",chardata"`
|
||||||
|
Size string `xml:"size,attr"`
|
||||||
|
AllowSync string `xml:"allowSync,attr"`
|
||||||
|
Art string `xml:"art,attr"`
|
||||||
|
Banner string `xml:"banner,attr"`
|
||||||
|
Identifier string `xml:"identifier,attr"`
|
||||||
|
Key string `xml:"key,attr"`
|
||||||
|
LibrarySectionID string `xml:"librarySectionID,attr"`
|
||||||
|
LibrarySectionTitle string `xml:"librarySectionTitle,attr"`
|
||||||
|
LibrarySectionUUID string `xml:"librarySectionUUID,attr"`
|
||||||
|
MediaTagPrefix string `xml:"mediaTagPrefix,attr"`
|
||||||
|
MediaTagVersion string `xml:"mediaTagVersion,attr"`
|
||||||
|
MixedParents string `xml:"mixedParents,attr"`
|
||||||
|
Nocache string `xml:"nocache,attr"`
|
||||||
|
ParentIndex string `xml:"parentIndex,attr"`
|
||||||
|
ParentTitle string `xml:"parentTitle,attr"`
|
||||||
|
ParentYear string `xml:"parentYear,attr"`
|
||||||
|
Theme string `xml:"theme,attr"`
|
||||||
|
Title1 string `xml:"title1,attr"`
|
||||||
|
Title2 string `xml:"title2,attr"`
|
||||||
|
ViewGroup string `xml:"viewGroup,attr"`
|
||||||
|
ViewMode string `xml:"viewMode,attr"`
|
||||||
|
Video []struct {
|
||||||
|
Text string `xml:",chardata"`
|
||||||
|
RatingKey string `xml:"ratingKey,attr"`
|
||||||
|
Key string `xml:"key,attr"`
|
||||||
|
ParentRatingKey string `xml:"parentRatingKey,attr"`
|
||||||
|
GrandparentRatingKey string `xml:"grandparentRatingKey,attr"`
|
||||||
|
Studio string `xml:"studio,attr"`
|
||||||
|
Type string `xml:"type,attr"`
|
||||||
|
Title string `xml:"title,attr"`
|
||||||
|
GrandparentKey string `xml:"grandparentKey,attr"`
|
||||||
|
ParentKey string `xml:"parentKey,attr"`
|
||||||
|
GrandparentTitle string `xml:"grandparentTitle,attr"`
|
||||||
|
ParentTitle string `xml:"parentTitle,attr"`
|
||||||
|
ContentRating string `xml:"contentRating,attr"`
|
||||||
|
Summary string `xml:"summary,attr"`
|
||||||
|
Index string `xml:"index,attr"`
|
||||||
|
ParentIndex string `xml:"parentIndex,attr"`
|
||||||
|
Rating string `xml:"rating,attr"`
|
||||||
|
Year string `xml:"year,attr"`
|
||||||
|
Thumb string `xml:"thumb,attr"`
|
||||||
|
Art string `xml:"art,attr"`
|
||||||
|
ParentThumb string `xml:"parentThumb,attr"`
|
||||||
|
GrandparentThumb string `xml:"grandparentThumb,attr"`
|
||||||
|
GrandparentArt string `xml:"grandparentArt,attr"`
|
||||||
|
GrandparentTheme string `xml:"grandparentTheme,attr"`
|
||||||
|
Duration string `xml:"duration,attr"`
|
||||||
|
OriginallyAvailableAt string `xml:"originallyAvailableAt,attr"`
|
||||||
|
AddedAt string `xml:"addedAt,attr"`
|
||||||
|
UpdatedAt string `xml:"updatedAt,attr"`
|
||||||
|
TitleSort string `xml:"titleSort,attr"`
|
||||||
|
Media struct {
|
||||||
|
Text string `xml:",chardata"`
|
||||||
|
VideoResolution string `xml:"videoResolution,attr"`
|
||||||
|
ID string `xml:"id,attr"`
|
||||||
|
Duration string `xml:"duration,attr"`
|
||||||
|
Bitrate string `xml:"bitrate,attr"`
|
||||||
|
Width string `xml:"width,attr"`
|
||||||
|
Height string `xml:"height,attr"`
|
||||||
|
AspectRatio string `xml:"aspectRatio,attr"`
|
||||||
|
AudioChannels string `xml:"audioChannels,attr"`
|
||||||
|
AudioCodec string `xml:"audioCodec,attr"`
|
||||||
|
VideoCodec string `xml:"videoCodec,attr"`
|
||||||
|
Container string `xml:"container,attr"`
|
||||||
|
VideoFrameRate string `xml:"videoFrameRate,attr"`
|
||||||
|
VideoProfile string `xml:"videoProfile,attr"`
|
||||||
|
Part struct {
|
||||||
|
Text string `xml:",chardata"`
|
||||||
|
ID string `xml:"id,attr"`
|
||||||
|
Key string `xml:"key,attr"`
|
||||||
|
Duration string `xml:"duration,attr"`
|
||||||
|
File string `xml:"file,attr"`
|
||||||
|
Size string `xml:"size,attr"`
|
||||||
|
Container string `xml:"container,attr"`
|
||||||
|
VideoProfile string `xml:"videoProfile,attr"`
|
||||||
|
} `xml:"Part"`
|
||||||
|
} `xml:"Media"`
|
||||||
|
Director struct {
|
||||||
|
Text string `xml:",chardata"`
|
||||||
|
Tag string `xml:"tag,attr"`
|
||||||
|
} `xml:"Director"`
|
||||||
|
Writer []struct {
|
||||||
|
Text string `xml:",chardata"`
|
||||||
|
Tag string `xml:"tag,attr"`
|
||||||
|
} `xml:"Writer"`
|
||||||
|
} `xml:"Video"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SonarrResponse struct {
|
||||||
|
Message string `json:"message"`
|
||||||
|
Description string `json:"description"`
|
||||||
|
}
|
@ -1,6 +1,9 @@
|
|||||||
package model
|
package model
|
||||||
|
|
||||||
import "encoding/xml"
|
import (
|
||||||
|
"encoding/xml"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
// PlexPyLibraryInfo will gather all the library related info. We really just need the count from this...
|
// PlexPyLibraryInfo will gather all the library related info. We really just need the count from this...
|
||||||
type PlexPyLibraryInfo struct {
|
type PlexPyLibraryInfo struct {
|
||||||
@ -63,139 +66,91 @@ type PlexPyMediaInfo struct {
|
|||||||
} `json:"response"`
|
} `json:"response"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// XMLPlexAPI - This is the XML version of the struct below it.
|
type XMLPlexLibraryType struct {
|
||||||
type XMLPlexAPI struct {
|
XMLName xml.Name `xml:"MediaContainer"`
|
||||||
XMLName xml.Name `xml:"MediaContainer"`
|
Text string `xml:",chardata"`
|
||||||
Text string `xml:",chardata"`
|
Size string `xml:"size,attr"`
|
||||||
Size string `xml:"size,attr"`
|
AllowSync string `xml:"allowSync,attr"`
|
||||||
AllowSync string `xml:"allowSync,attr"`
|
Art string `xml:"art,attr"`
|
||||||
Identifier string `xml:"identifier,attr"`
|
Content string `xml:"content,attr"`
|
||||||
LibrarySectionID string `xml:"librarySectionID,attr"`
|
Identifier string `xml:"identifier,attr"`
|
||||||
LibrarySectionTitle string `xml:"librarySectionTitle,attr"`
|
LibrarySectionID string `xml:"librarySectionID,attr"`
|
||||||
LibrarySectionUUID string `xml:"librarySectionUUID,attr"`
|
MediaTagPrefix string `xml:"mediaTagPrefix,attr"`
|
||||||
MediaTagPrefix string `xml:"mediaTagPrefix,attr"`
|
MediaTagVersion string `xml:"mediaTagVersion,attr"`
|
||||||
MediaTagVersion string `xml:"mediaTagVersion,attr"`
|
Nocache string `xml:"nocache,attr"`
|
||||||
Video struct {
|
Thumb string `xml:"thumb,attr"`
|
||||||
Text string `xml:",chardata"`
|
Title1 string `xml:"title1,attr"`
|
||||||
RatingKey string `xml:"ratingKey,attr"`
|
ViewGroup string `xml:"viewGroup,attr"`
|
||||||
Key string `xml:"key,attr"`
|
ViewMode string `xml:"viewMode,attr"`
|
||||||
GUID string `xml:"guid,attr"`
|
Directory []struct {
|
||||||
LibrarySectionTitle string `xml:"librarySectionTitle,attr"`
|
Text string `xml:",chardata"`
|
||||||
LibrarySectionID string `xml:"librarySectionID,attr"`
|
Key string `xml:"key,attr"`
|
||||||
LibrarySectionKey string `xml:"librarySectionKey,attr"`
|
Title string `xml:"title,attr"`
|
||||||
Studio string `xml:"studio,attr"`
|
Secondary string `xml:"secondary,attr"`
|
||||||
Type string `xml:"type,attr"`
|
Prompt string `xml:"prompt,attr"`
|
||||||
Title string `xml:"title,attr"`
|
Search string `xml:"search,attr"`
|
||||||
ContentRating string `xml:"contentRating,attr"`
|
} `xml:"Directory"`
|
||||||
Summary string `xml:"summary,attr"`
|
}
|
||||||
Rating string `xml:"rating,attr"`
|
|
||||||
AudienceRating string `xml:"audienceRating,attr"`
|
// SonarrSeries type takes all the data from Sonarr and places it in a struct
|
||||||
Year string `xml:"year,attr"`
|
type SonarrSeries []struct {
|
||||||
Tagline string `xml:"tagline,attr"`
|
Title string `json:"title"`
|
||||||
Thumb string `xml:"thumb,attr"`
|
AlternateTitles []struct {
|
||||||
Art string `xml:"art,attr"`
|
Title string `json:"title"`
|
||||||
Duration string `xml:"duration,attr"`
|
SeasonNumber int `json:"seasonNumber"`
|
||||||
OriginallyAvailableAt string `xml:"originallyAvailableAt,attr"`
|
} `json:"alternateTitles"`
|
||||||
AddedAt string `xml:"addedAt,attr"`
|
SortTitle string `json:"sortTitle"`
|
||||||
UpdatedAt string `xml:"updatedAt,attr"`
|
SeasonCount int `json:"seasonCount"`
|
||||||
AudienceRatingImage string `xml:"audienceRatingImage,attr"`
|
TotalEpisodeCount int `json:"totalEpisodeCount"`
|
||||||
ChapterSource string `xml:"chapterSource,attr"`
|
EpisodeCount int `json:"episodeCount"`
|
||||||
PrimaryExtraKey string `xml:"primaryExtraKey,attr"`
|
EpisodeFileCount int `json:"episodeFileCount"`
|
||||||
RatingImage string `xml:"ratingImage,attr"`
|
SizeOnDisk int64 `json:"sizeOnDisk"`
|
||||||
Media struct {
|
Status string `json:"status"`
|
||||||
Text string `xml:",chardata"`
|
Overview string `json:"overview"`
|
||||||
VideoResolution string `xml:"videoResolution,attr"`
|
PreviousAiring time.Time `json:"previousAiring"`
|
||||||
ID string `xml:"id,attr"`
|
Network string `json:"network"`
|
||||||
Duration string `xml:"duration,attr"`
|
AirTime string `json:"airTime,omitempty"`
|
||||||
Bitrate string `xml:"bitrate,attr"`
|
Images []struct {
|
||||||
Width string `xml:"width,attr"`
|
CoverType string `json:"coverType"`
|
||||||
Height string `xml:"height,attr"`
|
URL string `json:"url"`
|
||||||
AspectRatio string `xml:"aspectRatio,attr"`
|
} `json:"images"`
|
||||||
AudioChannels string `xml:"audioChannels,attr"`
|
Seasons []struct {
|
||||||
AudioCodec string `xml:"audioCodec,attr"`
|
SeasonNumber int `json:"seasonNumber"`
|
||||||
VideoCodec string `xml:"videoCodec,attr"`
|
Monitored bool `json:"monitored"`
|
||||||
Container string `xml:"container,attr"`
|
Statistics struct {
|
||||||
VideoFrameRate string `xml:"videoFrameRate,attr"`
|
PreviousAiring time.Time `json:"previousAiring"`
|
||||||
AudioProfile string `xml:"audioProfile,attr"`
|
EpisodeFileCount int `json:"episodeFileCount"`
|
||||||
VideoProfile string `xml:"videoProfile,attr"`
|
EpisodeCount int `json:"episodeCount"`
|
||||||
Part struct {
|
TotalEpisodeCount int `json:"totalEpisodeCount"`
|
||||||
Text string `xml:",chardata"`
|
SizeOnDisk int64 `json:"sizeOnDisk"`
|
||||||
ID string `xml:"id,attr"`
|
PercentOfEpisodes float64 `json:"percentOfEpisodes"`
|
||||||
Key string `xml:"key,attr"`
|
} `json:"statistics"`
|
||||||
Duration string `xml:"duration,attr"`
|
} `json:"seasons"`
|
||||||
File string `xml:"file,attr"`
|
Year int `json:"year"`
|
||||||
Size string `xml:"size,attr"`
|
Path string `json:"path"`
|
||||||
AudioProfile string `xml:"audioProfile,attr"`
|
ProfileID int `json:"profileId"`
|
||||||
Container string `xml:"container,attr"`
|
SeasonFolder bool `json:"seasonFolder"`
|
||||||
VideoProfile string `xml:"videoProfile,attr"`
|
Monitored bool `json:"monitored"`
|
||||||
Stream []struct {
|
UseSceneNumbering bool `json:"useSceneNumbering"`
|
||||||
Text string `xml:",chardata"`
|
Runtime int `json:"runtime"`
|
||||||
ID string `xml:"id,attr"`
|
TvdbID int `json:"tvdbId"`
|
||||||
StreamType string `xml:"streamType,attr"`
|
TvRageID int `json:"tvRageId"`
|
||||||
Default string `xml:"default,attr"`
|
TvMazeID int `json:"tvMazeId"`
|
||||||
Codec string `xml:"codec,attr"`
|
FirstAired time.Time `json:"firstAired"`
|
||||||
Index string `xml:"index,attr"`
|
LastInfoSync time.Time `json:"lastInfoSync"`
|
||||||
Bitrate string `xml:"bitrate,attr"`
|
SeriesType string `json:"seriesType"`
|
||||||
Language string `xml:"language,attr"`
|
CleanTitle string `json:"cleanTitle"`
|
||||||
LanguageCode string `xml:"languageCode,attr"`
|
ImdbID string `json:"imdbId,omitempty"`
|
||||||
BitDepth string `xml:"bitDepth,attr"`
|
TitleSlug string `json:"titleSlug"`
|
||||||
ChromaLocation string `xml:"chromaLocation,attr"`
|
Certification string `json:"certification,omitempty"`
|
||||||
ChromaSubsampling string `xml:"chromaSubsampling,attr"`
|
Genres []string `json:"genres"`
|
||||||
FrameRate string `xml:"frameRate,attr"`
|
Tags []interface{} `json:"tags"`
|
||||||
HasScalingMatrix string `xml:"hasScalingMatrix,attr"`
|
Added time.Time `json:"added"`
|
||||||
Height string `xml:"height,attr"`
|
Ratings struct {
|
||||||
Level string `xml:"level,attr"`
|
Votes int `json:"votes"`
|
||||||
Profile string `xml:"profile,attr"`
|
Value float64 `json:"value"`
|
||||||
RefFrames string `xml:"refFrames,attr"`
|
} `json:"ratings"`
|
||||||
ScanType string `xml:"scanType,attr"`
|
QualityProfileID int `json:"qualityProfileId"`
|
||||||
Title string `xml:"title,attr"`
|
ID int `json:"id"`
|
||||||
Width string `xml:"width,attr"`
|
NextAiring time.Time `json:"nextAiring,omitempty"`
|
||||||
DisplayTitle string `xml:"displayTitle,attr"`
|
|
||||||
Selected string `xml:"selected,attr"`
|
|
||||||
Channels string `xml:"channels,attr"`
|
|
||||||
AudioChannelLayout string `xml:"audioChannelLayout,attr"`
|
|
||||||
SamplingRate string `xml:"samplingRate,attr"`
|
|
||||||
Key string `xml:"key,attr"`
|
|
||||||
} `xml:"Stream"`
|
|
||||||
} `xml:"Part"`
|
|
||||||
} `xml:"Media"`
|
|
||||||
Genre []struct {
|
|
||||||
Text string `xml:",chardata"`
|
|
||||||
ID string `xml:"id,attr"`
|
|
||||||
Filter string `xml:"filter,attr"`
|
|
||||||
Tag string `xml:"tag,attr"`
|
|
||||||
} `xml:"Genre"`
|
|
||||||
Director struct {
|
|
||||||
Text string `xml:",chardata"`
|
|
||||||
ID string `xml:"id,attr"`
|
|
||||||
Filter string `xml:"filter,attr"`
|
|
||||||
Tag string `xml:"tag,attr"`
|
|
||||||
} `xml:"Director"`
|
|
||||||
Writer []struct {
|
|
||||||
Text string `xml:",chardata"`
|
|
||||||
ID string `xml:"id,attr"`
|
|
||||||
Filter string `xml:"filter,attr"`
|
|
||||||
Tag string `xml:"tag,attr"`
|
|
||||||
} `xml:"Writer"`
|
|
||||||
Producer []struct {
|
|
||||||
Text string `xml:",chardata"`
|
|
||||||
ID string `xml:"id,attr"`
|
|
||||||
Filter string `xml:"filter,attr"`
|
|
||||||
Tag string `xml:"tag,attr"`
|
|
||||||
} `xml:"Producer"`
|
|
||||||
Country struct {
|
|
||||||
Text string `xml:",chardata"`
|
|
||||||
ID string `xml:"id,attr"`
|
|
||||||
Filter string `xml:"filter,attr"`
|
|
||||||
Tag string `xml:"tag,attr"`
|
|
||||||
} `xml:"Country"`
|
|
||||||
Role []struct {
|
|
||||||
Text string `xml:",chardata"`
|
|
||||||
ID string `xml:"id,attr"`
|
|
||||||
Filter string `xml:"filter,attr"`
|
|
||||||
Tag string `xml:"tag,attr"`
|
|
||||||
Role string `xml:"role,attr"`
|
|
||||||
Thumb string `xml:"thumb,attr"`
|
|
||||||
} `xml:"Role"`
|
|
||||||
} `xml:"Video"`
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user