Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from plexapi.server import PlexServer
- plex = PlexServer("http://localhost:32400", "you API token") #set API token and change server IP if needed
- y = 0
- def time(seconds):
- m, s = divmod(seconds / 1000, 60)
- h, m = divmod(m, 60)
- d, h = divmod(h, 24)
- return("%d days : %d hours : %d minutes : %d seconds" % (d, h, m, s))
- def calcTV(library):
- t = 0
- global y
- for m in plex.library.section(library).all():
- for x in m.episodes():
- if type(x.duration) is int:
- t += x.duration
- y += t
- return time(t) + " in %s" % (library)
- def calcMusic(library):
- t = 0
- global y
- for m in plex.library.section(library).all():
- for x in m.tracks():
- if type(x.duration) is int:
- t += x.duration
- y += t
- return time(t) + " in %s" % (library)
- def calcMovie(library):
- t = 0
- global y
- for m in plex.library.section(library).all():
- if type(m.duration) is int:
- t += m.duration
- y += t
- return time(t) + " in %s" % (library)
- print(calcMusic("Music")) #change string to your music library name
- print(calcMovie("Films")) #change string to your Movie library name
- print(calcTV("TV")) #change string to your TV library name
- print(time(y) + " in total")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement