What's new
PGBlitz.com

Register Now! Find useful tips, Interact /w Community Members and join the part the Best Community on the Internet!

Trakt.or - Plex TV-Show Library tracker

H1f0x

Administrator
Project Manager
Donor
Hi all,

It's me again :)

I created a small application which will automatically fetch all tv-shows in your Plex library and create a list to track the progress on them.

The simple web app can do the following for you:
  • creates a summary of which episodes and seasons are missing in your library but would be already available
  • tracking not yet released episodes of a tv-show in you library
  • simple feed for the upcoming 7 days of which episode of tv-shows in your library will be aired.




Project URL: https://github.com/h1f0x/docker-trackt-plex-tracker
Docker Compose file for PGBlitz: https://github.com/h1f0x/docker-trackt-plex-tracker/tree/master/compose-files
Pull Request: https://github.com/PGBlitz/Apps-Community/pull/38

Install instructions are on Github available.
The "config.ini" for plexguide is located at: /opt/appdata/traktor/config.ini
Would be awesome i could get some feedback to improve the experience :)

EDIT #1: I just found out, that not all tv-shows can be tracked at least in my german libraries have some minor issues, working on it now! >> fixed! Added language option.

Cheers
H1f0x
 
Last edited:

H1f0x

Administrator
Project Manager
Donor
A lot of bug fixing was done. You should re-install the container to apply a new version of it!
 

Admin9705

Administrator
Project Manager
i bookmarked, but a yml would have to be written in pg-community. currently working on other projects, but have bookmarked for down the road. you can also submit a yml in the community and other's can install and deploy as an fyi.

 

H1f0x

Administrator
Project Manager
Donor
Yep i think i created the pull on the community repo already as linked. this is for the community! :) Or i miss-understood you now completely.. :D
 

pYTTH

Blitz Legioner
Staff
Awesome work. I will have a look at it on the weekend and provide a feedback
 

timekills

Blitz Samurai
Staff
Donor
Since the /opt/appdata/plex/database/Library/Application Support/Plex Media Server/Plug-in Support/Databases folder is ported to the Traktor container under the "plex" folder, that info could be added as a display prompt once the install is complete.

Of course, preferably it would be hard-coded into the config.ini, but since it's an external Docker app, it would change upon update anyway.
 

H1f0x

Administrator
Project Manager
Donor
Yeah i will mention that somewhere in the README.md, good point! well, i could write a pgblitz config file and host another docker container for this purpose actually. would this be easier?

Also I want to mention, i copy the plex database before I access it with the script to be on the save side. Any Idea how to show this info, once the container is installed?

I have some features I want to implement in the next release, so the config file, can be modified within the web ui.
 

timekills

Blitz Samurai
Staff
Donor
I created a brand new app on Trakt and used those credentials in config.ini and also added the location for the database.
Restarted the Traktor docker, as well as stopped it and started it.
Waited > 24 hours

Still only get the "Ups! shows.json not ready (yet).. Have you updated the config.ini? Please wait a moment and refresh the page. "

3155

My config.ini file is (obfuscated credentials):

[trakt.tv]
client_id = 2axxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx8
client_secret = dxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx6

[Plex]
database_location = /plex/com.plexapp.plugins.library.db
# language codes examples > de, fr, it, es and so on.. (https://trakt.docs.apiary.io/#reference/languages/get-languages)
# script default language is "en"
library_language = en
 

H1f0x

Administrator
Project Manager
Donor
hmm interesting. I deployed it many times on my setup, with the same configuration so did a friend of mine :(

Is it possible for you to do the following:

Bash:
$ docker exec -it traktor /bin/bash

$ export LD_LIBRARY_PATH=/usr/local/lib/ && /usr/bin/python3.6 /opt/trakt-plex-tracker/trakt-or.py
and check the output of it?

You can DM me the output, if wanted. Im wondering whats the issue :S
 

timekills

Blitz Samurai
Staff
Donor
Well - the good news is, it looks like it's actively reaching out to get data.
The bad news is, it's throwing an Index error.

Last few lines from the end:

DEBUG:urllib3.connectionpool:https://api.trakt.tv:443 "GET /search/show?query=The+Orville&year=2017&extended=full HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://api.trakt.tv:443 "GET /shows/119017/seasons?extended=full HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://api.trakt.tv:443 "GET /shows/119017/seasons/1?extended=full HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://api.trakt.tv:443 "GET /shows/119017/seasons/2?extended=full HTTP/1.1" 200 None
en
DEBUG:urllib3.connectionpool:https://api.trakt.tv:443 "GET /search/show?query=Godless+%282017%29&year=2017&extended=full HTTP/1.1" 200 None
Traceback (most recent call last):
File "/opt/trakt-plex-tracker/trakt-or.py", line 263, in <module>
config['Plex']['library_language'])
File "/opt/trakt-plex-tracker/trakt-or.py", line 111, in find_trakt_show
if items[0].score < 1000:
IndexError: list index out of range




Initial ~20 lines:

DEBUG:urllib3.util.retry:Converted retries value: 3 -> Retry(total=3, connect=None, read=None, redirect=None, status=None)
DEBUG:urllib3.util.retry:Converted retries value: 3 -> Retry(total=3, connect=None, read=None, redirect=None, status=None)
en
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): api.trakt.tv:443
DEBUG:urllib3.connectionpool:https://api.trakt.tv:443 "GET /search/show?query=Orange+Is+the+New+Black&year=2013&extended=full HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://api.trakt.tv:443 "GET /shows/1415/seasons?extended=full HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://api.trakt.tv:443 "GET /shows/1415/seasons/1?extended=full HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://api.trakt.tv:443 "GET /shows/1415/seasons/2?extended=full HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://api.trakt.tv:443 "GET /shows/1415/seasons/3?extended=full HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://api.trakt.tv:443 "GET /shows/1415/seasons/4?extended=full HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://api.trakt.tv:443 "GET /shows/1415/seasons/5?extended=full HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://api.trakt.tv:443 "GET /shows/1415/seasons/6?extended=full HTTP/1.1" 200 None
en
DEBUG:urllib3.connectionpool:https://api.trakt.tv:443 "GET /search/show?query=The+Wire&year=2002&extended=full HTTP/1.1" 200 None
/opt/trakt-plex-tracker/trakt-or.py:107: UserWarning: Unhandled pagination response, more pages can be returned with `pagination=True`
items = Trakt['search'].query(query, media, year, extended='full')
DEBUG:urllib3.connectionpool:https://api.trakt.tv:443 "GET /shows/1429/seasons?extended=full HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://api.trakt.tv:443 "GET /shows/1429/seasons/1?extended=full HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://api.trakt.tv:443 "GET /shows/1429/seasons/2?extended=full HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://api.trakt.tv:443 "GET /shows/1429/seasons/3?extended=full HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://api.trakt.tv:443 "GET /shows/1429/seasons/4?extended=full HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://api.trakt.tv:443 "GET /shows/1429/seasons/5?extended=full HTTP/1.1" 200 None
en



It has ~200 lines in the middle I didn't include checking shows similar to the initial pattern. I can put it all on Pastebin but reading through it I doubt those will provide any detail the last few and first few lines don't already provide.
 

H1f0x

Administrator
Project Manager
Donor
Alright, i need to add some better try/catches. I thought I've got them all correct. I will update below, once i added it. Thank you very mich!
 

H1f0x

Administrator
Project Manager
Donor
Alright, i added some quick fix, can you do the following within the container:

Bash:
cd /opt/trakt-plex-tracker/
git pull
export LD_LIBRARY_PATH=/usr/local/lib/ && /usr/bin/python3.6 /opt/trakt-plex-tracker/trakt-or.py
if this is working for now, i will rebuild the docker image if you can confirm its working for now.
I add some proper debugging function within next week :)
 
Last edited:

timekills

Blitz Samurai
Staff
Donor
It got further...but still had an error.

DEBUG:urllib3.connectionpool:https://api.trakt.tv:443 "GET /search/show?query=Stranger+Things&year=2016&extended=full HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://api.trakt.tv:443 "GET /shows/104439/seasons?extended=full HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://api.trakt.tv:443 "GET /shows/104439/seasons/1?extended=full HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://api.trakt.tv:443 "GET /shows/104439/seasons/2?extended=full HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://api.trakt.tv:443 "GET /shows/104439/seasons/3?extended=full HTTP/1.1" 200 None
Traceback (most recent call last):
File "/opt/trakt-plex-tracker/trakt-or.py", line 275, in <module>
result = calculate_owning(data)
File "/opt/trakt-plex-tracker/trakt-or.py", line 204, in calculate_owning
for season in show['seasons']:
KeyError: 'seasons'




Also - there are a few shows it doesn't find, (i.e. Godless 2017) although they show up in Trakt as played through the Plex Trakt plugin.

DEBUG:urllib3.connectionpool:https://api.trakt.tv:443 "GET /search/show?query=Godless+%282017%29&year=2017&extended=full HTTP/1.1" 200 None
ERROR: Godless (2017) not found on Trakt.tv
 

H1f0x

Administrator
Project Manager
Donor
hmm.. added some more. you can pull it again and run it.. Apparently it was never the case with my library that a show was not able to be found at all :/


Yeah, i need to verify why your query looks malformated, but this takes some more time. The title for example if Godless which is queried is: "Godless (2017)" instead of "Godless" i think it is like this in your Plex library, I had a similar issue with "The Flash (2014)" the fix i implemented worked for my show, apparently not for your.. but this needs some more time. I will load the show myself and debug it out.
 

timekills

Blitz Samurai
Staff
Donor
I agree - on Trakt it is simply "Godless". In Sonarr, it names it Godless (2017). Same with The Flash for me.
I tried changing the folder it's in to just "Godless" and will see what happens when I pull.

What is odd, is it finds the TV show through the old Trakt plugin, because it has the played status in Trakt. Not sure how Trakt finds it through that one, since both use the same API.

Update to follow...
 

timekills

Blitz Samurai
Staff
Donor
Latest error (having fun yet?)

DEBUG:urllib3.connectionpool:https://api.trakt.tv:443 "GET /search/show?query=Falling+Skies&year=2011&extended=full HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://api.trakt.tv:443 "GET /shows/34818/seasons?extended=full HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://api.trakt.tv:443 "GET /shows/34818/seasons/1?extended=full HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://api.trakt.tv:443 "GET /shows/34818/seasons/2?extended=full HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://api.trakt.tv:443 "GET /shows/34818/seasons/3?extended=full HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://api.trakt.tv:443 "GET /shows/34818/seasons/4?extended=full HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://api.trakt.tv:443 "GET /shows/34818/seasons/5?extended=full HTTP/1.1" 200 None
Traceback (most recent call last):
File "/opt/trakt-plex-tracker/trakt-or.py", line 282, in <module>
result = calculate_owning(data)
File "/opt/trakt-plex-tracker/trakt-or.py", line 233, in calculate_owning
show['owning_percent'] = (100 / (show_owning_true + show_owning_false)) * show_owning_true
ZeroDivisionError: division by zero
 

H1f0x

Administrator
Project Manager
Donor
hahaha :D it's all because of the shows it cannot find. I tried creating an object with an error msg for the front end. it seams we just destroyed the world, by division by zero. Apparently i will exclude for now shows which cannot be found. Should have done that from the beginning. So some shows will just now appear on the UI till i fixed this.

Good question about the API. I need to check out their code to see what they're doing.

you can pull again, i just pass the shows which cannot be found for now... i really hopes this solves the issue for now.
 

timekills

Blitz Samurai
Staff
Donor
Closer - got further this time, but different error.

DEBUG:urllib3.connectionpool:https://api.trakt.tv:443 "GET /search/show?query=The+Man+in+the+High+Castle&year=2015&extended=full HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://api.trakt.tv:443 "GET /shows/68319/seasons?extended=full HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://api.trakt.tv:443 "GET /shows/68319/seasons/1?extended=full HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://api.trakt.tv:443 "GET /shows/68319/seasons/2?extended=full HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://api.trakt.tv:443 "GET /shows/68319/seasons/3?extended=full HTTP/1.1" 200 None
Traceback (most recent call last):
File "/opt/trakt-plex-tracker/trakt-or.py", line 275, in <module>
data = compare_plex_trakt(plex_shows, trakt_shows)
File "/opt/trakt-plex-tracker/trakt-or.py", line 180, in compare_plex_trakt
if show_plex['name'] == show_trakt['plex_title']:
TypeError: 'NoneType' object is not subscriptable
 

H1f0x

Administrator
Project Manager
Donor
what the.. your library is interesting... some of the errors you just showed me i was already familiar with, but this one - not. :D give me a sec.. '^^
 

H1f0x

Administrator
Project Manager
Donor
There we go again.. haha :D Pull again.. But for sure some shows will be missing for you, i need to investigate those issues further by trying to recreate them first :)
 

H1f0x

Administrator
Project Manager
Donor
interesting fact: this error should have appeared before the one you posted before... xD
 

timekills

Blitz Samurai
Staff
Donor
Hmm. Back to the division by zero error.
(I also would have expected the last error to be found previous to some others, but oddly enough, it doesn't seem to be searching in alphabetical order.)

en
DEBUG:urllib3.connectionpool:https://api.trakt.tv:443 "GET /search/show?query=Sharp+Objects&year=2018&extended=full HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://api.trakt.tv:443 "GET /shows/130010/seasons?extended=full HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://api.trakt.tv:443 "GET /shows/130010/seasons/1?extended=full HTTP/1.1" 200 None
Traceback (most recent call last):
File "/opt/trakt-plex-tracker/trakt-or.py", line 280, in <module>
result = calculate_owning(data)
File "/opt/trakt-plex-tracker/trakt-or.py", line 231, in calculate_owning
show['owning_percent'] = (100 / (show_owning_true + show_owning_false)) * show_owning_true
ZeroDivisionError: division by zero
 

H1f0x

Administrator
Project Manager
Donor
This error should actually not be possible.. but since i just saw a hole lot of new issues, everything is possible.
For now i just set the percent to 0 if this error is raised. Somehow the script thinks you own 0 episodes of this show. Which, cant be true, since you have it in the library....

pull is ready... :)
 

timekills

Blitz Samurai
Staff
Donor
Well then, you're going to love this one.
Now we've got dueling errors. :)

en
DEBUG:urllib3.connectionpool:https://api.trakt.tv:443 "GET /search/show?query=Supergirl&year=2015&extended=full HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://api.trakt.tv:443 "GET /shows/99046/seasons?extended=full HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://api.trakt.tv:443 "GET /shows/99046/seasons/1?extended=full HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://api.trakt.tv:443 "GET /shows/99046/seasons/2?extended=full HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://api.trakt.tv:443 "GET /shows/99046/seasons/3?extended=full HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://api.trakt.tv:443 "GET /shows/99046/seasons/4?extended=full HTTP/1.1" 200 None
Traceback (most recent call last):
File "/opt/trakt-plex-tracker/trakt-or.py", line 234, in calculate_owning
show['owning_percent'] = (100 / (show_owning_true + show_owning_false)) * show_owning_true
ZeroDivisionError: division by zero

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/opt/trakt-plex-tracker/trakt-or.py", line 285, in <module>
result = calculate_owning(data)
File "/opt/trakt-plex-tracker/trakt-or.py", line 236, in calculate_owning
show['owning_percent'] = 0
TypeError: 'NoneType' object does not support item assignment
 

H1f0x

Administrator
Project Manager
Donor
maybe yes - i think it is related to the shows it can't find. but not sure yet... :S

You can try again :D Surprise me!
 

timekills

Blitz Samurai
Staff
Donor
Ok - surprise. New one - the override to set owning % to zero maybe didn't work as hoped?

en
DEBUG:urllib3.connectionpool:https://api.trakt.tv:443 "GET /search/show?query=The+Last+Kingdom&year=2015&extended=full HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://api.trakt.tv:443 "GET /shows/100688/seasons?extended=full HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://api.trakt.tv:443 "GET /shows/100688/seasons/1?extended=full HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://api.trakt.tv:443 "GET /shows/100688/seasons/2?extended=full HTTP/1.1" 200 None
DEBUG:urllib3.connectionpool:https://api.trakt.tv:443 "GET /shows/100688/seasons/3?extended=full HTTP/1.1" 200 None
Traceback (most recent call last):
File "/opt/trakt-plex-tracker/trakt-or.py", line 290, in <module>
result = calculate_owning(data)
File "/opt/trakt-plex-tracker/trakt-or.py", line 236, in calculate_owning
show['owning_percent'] = 0
TypeError: 'NoneType' object does not support item assignment
 

H1f0x

Administrator
Project Manager
Donor
Good morning Sir,

Alright i made a few changes and tried to reproduce them locally. The year in the title, gets now splitted if a show can not be found, i return an empty array with the needed information.

I hope this works now.. :)

Cheers
 
Assists Greatly with Development Costs

timekills

Blitz Samurai
Staff
Donor
One underrated feature is you can check the season for a missing episode, and it shows you where you have a part 1 + part 2 combined. That's okay for viewing, but messes up Trakt (and sometimes Sonarr). So I can go and split them up into their proper episodes.

I really like this app. Thank you.
 

H1f0x

Administrator
Project Manager
Donor
Awesome! So glad it worked out! I hope you are not missing any shows? Everything looks alright?
Indeed, i did that too the last several days :D I hate combined shows too :p
 

Create an account or login to comment

You must be a member in order to leave a comment

Create account

Create an account on our community. It's easy!

Log in

Already have an account? Log in here.


Development Donations

 

Top NZB NewsGroups!

Members - Up To a 58% Discount!

Trending

Top