Created
June 10, 2017 22:52
-
-
Save tom-henderson/774b3fccb6f1817906de424bd5670d60 to your computer and use it in GitHub Desktop.
Show current status of TV shows on a Plex server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from plexapi.server import PlexServer | |
| from plexapi.myplex import MyPlexAccount | |
| from pytvdbapi import api as tvdbapi | |
| API_KEY = 'TVDB API Key' | |
| USERNAME = 'Plex Username' | |
| PASSWORD = 'Plex Password' | |
| SERVER_NAME = 'Plex Server Name' | |
| def colour_string(s, colour): | |
| colours = { | |
| 'red': '\033[1;31m', | |
| 'green': '\033[1;32m', | |
| 'yellow': '\033[1;33m', | |
| 'blue': '\033[1;34m', | |
| 'magenta': '\033[1;35m', | |
| 'cyan': '\033[1;36m', | |
| 'white': '\033[37m'} | |
| reset = "\033[0m" | |
| if colour in colours: | |
| return "{}{}{}".format(colours[colour], s, reset) | |
| return s | |
| status_colours = { | |
| "Ended": "red", | |
| "Pendi": "yellow", | |
| "On br": "white", | |
| "Unkno": "cyan", | |
| "Retur": "blue", | |
| "Airin": "green", | |
| "Conti": "green", | |
| } | |
| tvdb = tvdbapi.TVDB(API_KEY) | |
| account = MyPlexAccount.signin(USERNAME, PASSWORD) | |
| plex = account.resource(SERVER_NAME).connect() | |
| tv = plex.library.section('TV').all() | |
| for show in tv: | |
| result = tvdb.search(show.title, 'en') | |
| show_data = result[0] | |
| show_data.update() | |
| status = getattr(show_data, 'Status', 'Unknown') | |
| colour = status_colours[status[:5]] | |
| print show.title, colour_string(status, colour) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment