Adding ability to output to stdout instead of Telegram.
This commit is contained in:
parent
cd44fb971d
commit
42439d61b4
@ -15,12 +15,14 @@ func main() {
|
|||||||
var days int
|
var days int
|
||||||
var sectionID int
|
var sectionID int
|
||||||
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.IntVar(§ionID, "sectionid", 0, "Plex Section ID")
|
||||||
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, "check", 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()
|
||||||
|
|
||||||
@ -42,11 +44,15 @@ func main() {
|
|||||||
ids, titles := locator.GetTitles(cfg, sectionID, days)
|
ids, titles := locator.GetTitles(cfg, sectionID, days)
|
||||||
|
|
||||||
if check {
|
if check {
|
||||||
|
if text {
|
||||||
|
communicator.StdoutPost(titles)
|
||||||
|
} else {
|
||||||
err = communicator.TelegramPost(cfg, titles)
|
err = communicator.TelegramPost(cfg, titles)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if delete {
|
if delete {
|
||||||
if libraryType == "movie" {
|
if libraryType == "movie" {
|
||||||
|
@ -46,3 +46,14 @@ func TelegramPost(config config.Config, titles []string) error {
|
|||||||
|
|
||||||
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.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -134,7 +134,7 @@ func DeleteFiles(delete bool, files []string) error {
|
|||||||
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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user