mirror of
https://github.com/KevinMidboe/Node-Com-Handler.git
synced 2025-10-29 17:50:27 +00:00
Seperated movie and show into two functions.
This commit is contained in:
@@ -9,6 +9,39 @@ from requests import get
|
|||||||
|
|
||||||
plexBaseURL = "http://10.0.0.41:32400/"
|
plexBaseURL = "http://10.0.0.41:32400/"
|
||||||
|
|
||||||
|
def getMovieInfo(item):
|
||||||
|
title = item["title"]
|
||||||
|
year = item["year"]
|
||||||
|
rating = item["rating"]
|
||||||
|
art = item["art"]
|
||||||
|
thumb = item["thumb"]
|
||||||
|
|
||||||
|
for mediaInfo in item["_children"]:
|
||||||
|
if mediaInfo["_elementType"] == "Media":
|
||||||
|
container = mediaInfo["container"]
|
||||||
|
resolution = mediaInfo["videoResolution"]
|
||||||
|
bitrate = mediaInfo["bitrate"]
|
||||||
|
videoCodec = mediaInfo["videoCodec"]
|
||||||
|
videoFrameRate = mediaInfo["videoFrameRate"]
|
||||||
|
|
||||||
|
return {"title":title, "year":year, "rating":rating, "container":container,
|
||||||
|
"resolution":resolution, "bitrate":bitrate, "videoCodec":videoCodec,
|
||||||
|
"videoFrameRate":videoFrameRate, "art":art, "thumb":thumb}
|
||||||
|
|
||||||
|
def getShowInfo(item):
|
||||||
|
media = []
|
||||||
|
|
||||||
|
title = item["title"]
|
||||||
|
year = item["year"]
|
||||||
|
rating = item["rating"]
|
||||||
|
art = item["art"]
|
||||||
|
thumb = item["thumb"]
|
||||||
|
seasons = item["childCount"]
|
||||||
|
episodes = item["leafCount"]
|
||||||
|
|
||||||
|
return {"title":title, "year":year, "seasons":seasons, "episodes":episodes, "rating":rating,
|
||||||
|
"art":art, "thumb":thumb}
|
||||||
|
|
||||||
def plexSearch(query):
|
def plexSearch(query):
|
||||||
requestType = "search?"
|
requestType = "search?"
|
||||||
requestQuery = "query=" + str(query)
|
requestQuery = "query=" + str(query)
|
||||||
@@ -23,32 +56,10 @@ def plexSearch(query):
|
|||||||
|
|
||||||
for child in resContent["_children"]:
|
for child in resContent["_children"]:
|
||||||
cType = child["type"]
|
cType = child["type"]
|
||||||
if cType == "movie" or cType == "show":
|
if cType == "movie":
|
||||||
title = child["title"]
|
media.append(getMovieInfo(child))
|
||||||
year = child["year"]
|
elif cType == "show":
|
||||||
rating = child["rating"]
|
media.append(getShowInfo(child))
|
||||||
art = child["art"]
|
|
||||||
thumb = child["thumb"]
|
|
||||||
|
|
||||||
if cType == "movie":
|
|
||||||
for mediaInfo in child["_children"]:
|
|
||||||
if mediaInfo["_elementType"] == "Media":
|
|
||||||
container = mediaInfo["container"]
|
|
||||||
resolution = mediaInfo["videoResolution"]
|
|
||||||
bitrate = mediaInfo["bitrate"]
|
|
||||||
videoCodec = mediaInfo["videoCodec"]
|
|
||||||
videoFrameRate = mediaInfo["videoFrameRate"]
|
|
||||||
|
|
||||||
media.append({"title":title, "year":year, "rating":rating, "container":container,
|
|
||||||
"resolution":resolution, "bitrate":bitrate, "videoCodec":videoCodec,
|
|
||||||
"videoFrameRate":videoFrameRate, "art":art, "thumb":thumb})
|
|
||||||
|
|
||||||
if cType == "show":
|
|
||||||
seasons = child["childCount"]
|
|
||||||
episodes = child["leafCount"]
|
|
||||||
|
|
||||||
media.append({"title":title, "year":year, "seasons":seasons, "episodes":episodes, "rating":rating,
|
|
||||||
"art":art, "thumb":thumb})
|
|
||||||
|
|
||||||
return media
|
return media
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user