ASK-ME-ABOUT-LOOM / purgeomatic

Delete movie/tv data based on watch statistics
GNU General Public License v3.0
60 stars 11 forks source link

Script seems to crash at variable times. Also get error message with each movie or TV show. #7

Closed skinner84 closed 1 year ago

skinner84 commented 1 year ago

Output below. I am running this in Docker.

sudo docker run --rm -it --env-file environment.env ghcr.io/ask-me-about-loom/purgeomatic:latest python delete.tv.unwatched.py DRY_RUN enabled!

2023-09-12T06:28:03.563757 ERROR: The Young Ones: Extra data: line 1 column 5 (char 4) ERROR: Years and Years: Extra data: line 1 column 5 (char 4) ERROR: Wonders of the Universe: Extra data: line 1 column 5 (char 4) ERROR: Wolf Pack: Extra data: line 1 column 5 (char 4) ERROR: Wolf Like Me: Extra data: line 1 column 5 (char 4) ERROR: The Witcher: Extra data: line 1 column 5 (char 4) ERROR: Will & Grace: Extra data: line 1 column 5 (char 4) ERROR: Wild Wild Country: Extra data: line 1 column 5 (char 4) ERROR: When They See Us: Extra data: line 1 column 5 (char 4) ERROR: Wayne: Extra data: line 1 column 5 (char 4) ERROR: WandaVision: Extra data: line 1 column 5 (char 4) ERROR: Vikings: Valhalla: Extra data: line 1 column 5 (char 4) ERROR: Vikings: Extra data: line 1 column 5 (char 4) ERROR: Vigil: Extra data: line 1 column 5 (char 4) ERROR: Upright: Extra data: line 1 column 5 (char 4) ERROR: The Unicorn: Extra data: line 1 column 5 (char 4) ERROR: The Undoing: Extra data: line 1 column 5 (char 4) ERROR: The Twilight Zone (2019): Extra data: line 1 column 5 (char 4) ERROR: The Twelve (AU): Extra data: line 1 column 5 (char 4) ERROR: Turning Point: 9/11 and the War on Terror: Extra data: line 1 column 5 (char 4) ERROR: Treasures of Ancient Egypt: Extra data: line 1 column 5 (char 4) ERROR: Top Gear: Extra data: line 1 column 5 (char 4) ERROR: Tiger King: Extra data: line 1 column 5 (char 4) ERROR: The Terror: Extra data: line 1 column 5 (char 4) ERROR: Tell Me Lies: Extra data: line 1 column 5 (char 4) ERROR: A Teacher: Extra data: line 1 column 5 (char 4) ERROR: Tales from the Loop: Extra data: line 1 column 5 (char 4) ERROR: The Super Switch: Extra data: line 1 column 5 (char 4) ERROR: Strike Back: Extra data: line 1 column 5 (char 4) ERROR: The Stranger (2020): Extra data: line 1 column 5 (char 4) ERROR: Stephen Fry: Out There: Extra data: line 1 column 5 (char 4) ERROR: Stay Close: Extra data: line 1 column 5 (char 4) ERROR: StartUp (2016): Extra data: line 1 column 5 (char 4) ERROR: StarTalk with Neil deGrasse Tyson: Extra data: line 1 column 5 (char 4) ERROR: Squid Game: Extra data: line 1 column 5 (char 4) ERROR: Soul Mates: Extra data: line 1 column 5 (char 4) ERROR: Solar Opposites: Extra data: line 1 column 5 (char 4) ERROR: The Sinner: Extra data: line 1 column 5 (char 4) ERROR: The Simpsons: Extra data: line 1 column 5 (char 4) ERROR: Silicon Valley: Extra data: line 1 column 5 (char 4) ERROR: The Silent Sea: Extra data: line 1 column 5 (char 4) ERROR: Sick of It: Extra data: line 1 column 5 (char 4) ERROR: The Shop: Uninterrupted: Extra data: line 1 column 5 (char 4) ERROR: Shark Wranglers: Extra data: line 1 column 5 (char 4) ERROR: Shameless (US): Extra data: line 1 column 5 (char 4) ERROR: Shadow and Bone: Extra data: line 1 column 5 (char 4) ERROR: Seinfeld: Extra data: line 1 column 5 (char 4) ERROR: Schitt's Creek: Extra data: line 1 column 5 (char 4) ERROR: Santa Clarita Diet: Extra data: line 1 column 5 (char 4) ERROR: Samurai Champloo: Extra data: line 1 column 5 (char 4) ERROR: Russian Doll: Extra data: line 1 column 5 (char 4) ERROR: RUN (2020): Extra data: line 1 column 5 (char 4) ERROR: Round the Twist: Extra data: line 1 column 5 (char 4) ERROR: The Responder: Extra data: line 1 column 5 (char 4) ERROR: Real Husbands of Hollywood: More Kevin, More Problems: Extra data: line 1 column 5 (char 4) ERROR: Real Husbands of Hollywood: Extra data: line 1 column 5 (char 4) ERROR: Ray Donovan: Extra data: line 1 column 5 (char 4) ERROR: Raised by Wolves (2020): Extra data: line 1 column 5 (char 4) ERROR: Quiz: Extra data: line 1 column 5 (char 4) ERROR: The Queen's Gambit: Extra data: line 1 column 5 (char 4) ERROR: Pretty Little Liars: Extra data: line 1 column 5 (char 4) ERROR: Pose: Extra data: line 1 column 5 (char 4) ERROR: Pororo the Little Penguin: Extra data: line 1 column 5 (char 4) ERROR: The Planets (2019): Extra data: line 1 column 5 (char 4) ERROR: Planet Earth II: Extra data: line 1 column 5 (char 4) ERROR: Patriot (2017): Extra data: line 1 column 5 (char 4) ERROR: The Pacific: Extra data: line 1 column 5 (char 4)

skinner84 commented 1 year ago

Here is my env file as well. Obfuscated URLs and API keys. My sonarr and radarr instances are behind an ssl load balancer (traefik). Not sure if that would break anything.

# Config for all scripts. Defaults are commented out.

RADARR=https://radarr.acme.com
RADARR_API=abcde

TAUTULLI=http://1.2.3.4:8181
TAUTULLI_API=abcde

SONARR=https://sonarr.acme.com
SONARR_API=abcde

OVERSEERR=http://localhost:5055
#OVERSEERR_API=abcdefghijklmnopqrstuvwxyz987654=

#TAUTULLI_MOVIE_SECTIONID=1
#TAUTULLI_TV_SECTIONID=2

# Number of rows to pull from Tautulli's media table.
#TAUTULLI_NUM_ROWS=3000

# Delete movies/series that haven't been watched in this many days.
#DAYS_SINCE_LAST_WATCH=500

# For deleting movies/series that have been added, but nobody ever watched.
# Set to 0 to disable.
#DAYS_WITHOUT_WATCH=60

# This is off by default! If you set this to any value, it will be on.
# Even the mere existence of this environment variable, set to nothing/blank, and it will be on.
# Turn it on to disable the delete action. The script will only report what it would do.
DRY_RUN=yes
ASK-ME-ABOUT-LOOM commented 1 year ago

This is the first time I've seen an error like this. I'm also not sure if the HTTPS or the load balancer would break anything (though I can't think of why that would happen). I'll see if I can replicate this error and get back to you.

ASK-ME-ABOUT-LOOM commented 1 year ago

Would you mind seeing if you can connect to the sonarr host directly via API? The command would be:

curl https://sonarr.acme.com/api/v3/series?tvdbId=368643\&apiKey=

You'll need to update it to the correct URL and paste in your sonarr API key at the end of the command. The TVDB ID I'm using there is for Raised by Wolves, which I see is in your library. I just want to see what a direct API connection to your sonarr instance looks like and confirm that it works.

Running this command should dump out a bunch of sonarr's data about the TV show and should look like

[
  {
    "title": "Raised by Wolves (2020)",
    "alternateTitles": [
      {
        "title": "A farkas gyermekei",
        "seasonNumber": -1
      }
    ],
    "sortTitle": "raised by wolves 2020",
    "status": "ended",
    "ended": true,
skinner84 commented 1 year ago

I ended up running it all locally on the same host Radarr/Sonarr is on and it works perfectly. I think it may be a DNS resolution issue on my end from the host I originally ran it from. Will attempt again tonight. How does your script handle an error with the API request?

Nice work on making this by the way!

ASK-ME-ABOUT-LOOM commented 1 year ago

How does your script handle an error with the API request?

Essentially, you've seen it. When overseerr's API key isn't defined, there are two API calls that take place when a movie or TV show is a candidate for deletion: one does the media lookup and stores the metadata in an object, the other does the delete.

Both of those calls are enclosed in a try/except block, and the error output from that occurs immediately after it tries the delete. The output is the word "ERROR" followed by the title that threw the error and the error message, or in your case:

ERROR: The Young Ones: Extra data: line 1 column 5 (char 4)

Based on the way that error appears, my speculation is that there's an issue making the API call to sonarr, which is why I wanted to see that curl output. But you've confirmed it by running locally from the sonarr host.

If DNS is the issue, is it possible to directly connect via IP? Or would HTTPS/traefik preclude that?

skinner84 commented 1 year ago

If DNS is the issue, is it possible to directly connect via IP? Or would HTTPS/traefik preclude that?

Yep - the containers aren't exposed anywhere beyond the host. Traefik sits in front of it all. Either way, it's my issue. I will fix it when I'm back online and let you know.

skinner84 commented 1 year ago

I sorted it.

It was DNS + my Traefik instance challenges for basic auth. Not expecting you to bake that into your script :)

Consider this issue closed.