mirror of
https://github.com/jellyfin/jellyfin-kodi.git
synced 2024-12-25 02:06:09 +00:00
self.item
This commit is contained in:
parent
16fb22792f
commit
065b8d84f0
1 changed files with 34 additions and 41 deletions
|
@ -116,17 +116,16 @@ class API():
|
||||||
}
|
}
|
||||||
|
|
||||||
def getMediaStreams(self):
|
def getMediaStreams(self):
|
||||||
item = self.item
|
|
||||||
videotracks = []
|
videotracks = []
|
||||||
audiotracks = []
|
audiotracks = []
|
||||||
subtitlelanguages = []
|
subtitlelanguages = []
|
||||||
|
|
||||||
try:
|
try:
|
||||||
media_streams = item['MediaSources'][0]['MediaStreams']
|
media_streams = self.item['MediaSources'][0]['MediaStreams']
|
||||||
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
if not item.get("MediaStreams"): return None
|
if not self.item.get("MediaStreams"): return None
|
||||||
media_streams = item['MediaStreams']
|
media_streams = self.item['MediaStreams']
|
||||||
|
|
||||||
for media_stream in media_streams:
|
for media_stream in media_streams:
|
||||||
# Sort through Video, Audio, Subtitle
|
# Sort through Video, Audio, Subtitle
|
||||||
|
@ -141,12 +140,12 @@ class API():
|
||||||
'codec': codec,
|
'codec': codec,
|
||||||
'height': media_stream.get('Height'),
|
'height': media_stream.get('Height'),
|
||||||
'width': media_stream.get('Width'),
|
'width': media_stream.get('Width'),
|
||||||
'video3DFormat': item.get('Video3DFormat'),
|
'video3DFormat': self.item.get('Video3DFormat'),
|
||||||
'aspect': 1.85
|
'aspect': 1.85
|
||||||
}
|
}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
container = item['MediaSources'][0]['Container'].lower()
|
container = self.item['MediaSources'][0]['Container'].lower()
|
||||||
except:
|
except:
|
||||||
container = ""
|
container = ""
|
||||||
|
|
||||||
|
@ -161,9 +160,9 @@ class API():
|
||||||
track['codec'] = "avc1"
|
track['codec'] = "avc1"
|
||||||
|
|
||||||
# Aspect ratio
|
# Aspect ratio
|
||||||
if item.get('AspectRatio'):
|
if self.item.get('AspectRatio'):
|
||||||
# Metadata AR
|
# Metadata AR
|
||||||
aspect = item['AspectRatio']
|
aspect = self.item['AspectRatio']
|
||||||
else: # File AR
|
else: # File AR
|
||||||
aspect = media_stream.get('AspectRatio', "0")
|
aspect = media_stream.get('AspectRatio', "0")
|
||||||
|
|
||||||
|
@ -180,8 +179,8 @@ class API():
|
||||||
else:
|
else:
|
||||||
track['aspect'] = 1.85
|
track['aspect'] = 1.85
|
||||||
|
|
||||||
if item.get("RunTimeTicks"):
|
if self.item.get("RunTimeTicks"):
|
||||||
track['duration'] = item.get("RunTimeTicks") / 10000000.0
|
track['duration'] = self.item.get("RunTimeTicks") / 10000000.0
|
||||||
|
|
||||||
videotracks.append(track)
|
videotracks.append(track)
|
||||||
|
|
||||||
|
@ -211,12 +210,11 @@ class API():
|
||||||
}
|
}
|
||||||
|
|
||||||
def getRuntime(self):
|
def getRuntime(self):
|
||||||
item = self.item
|
|
||||||
try:
|
try:
|
||||||
runtime = item['RunTimeTicks'] / 10000000.0
|
runtime = self.item['RunTimeTicks'] / 10000000.0
|
||||||
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
runtime = item.get('CumulativeRunTimeTicks', 0) / 10000000.0
|
runtime = self.item.get('CumulativeRunTimeTicks', 0) / 10000000.0
|
||||||
|
|
||||||
return runtime
|
return runtime
|
||||||
|
|
||||||
|
@ -234,15 +232,14 @@ class API():
|
||||||
|
|
||||||
def getStudios(self):
|
def getStudios(self):
|
||||||
# Process Studios
|
# Process Studios
|
||||||
item = self.item
|
|
||||||
studios = []
|
studios = []
|
||||||
|
|
||||||
try:
|
try:
|
||||||
studio = item['SeriesStudio']
|
studio = self.item['SeriesStudio']
|
||||||
studios.append(self.verifyStudio(studio))
|
studios.append(self.verifyStudio(studio))
|
||||||
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
studioList = item['Studios']
|
studioList = self.item['Studios']
|
||||||
for studio in studioList:
|
for studio in studioList:
|
||||||
|
|
||||||
name = studio['Name']
|
name = studio['Name']
|
||||||
|
@ -265,12 +262,11 @@ class API():
|
||||||
|
|
||||||
def getChecksum(self):
|
def getChecksum(self):
|
||||||
# Use the etags checksum and userdata
|
# Use the etags checksum and userdata
|
||||||
item = self.item
|
userdata = self.item['UserData']
|
||||||
userdata = item['UserData']
|
|
||||||
|
|
||||||
checksum = "%s%s%s%s%s%s%s" % (
|
checksum = "%s%s%s%s%s%s%s" % (
|
||||||
|
|
||||||
item['Etag'],
|
self.item['Etag'],
|
||||||
userdata['Played'],
|
userdata['Played'],
|
||||||
userdata['IsFavorite'],
|
userdata['IsFavorite'],
|
||||||
userdata.get('Likes',''),
|
userdata.get('Likes',''),
|
||||||
|
@ -282,9 +278,8 @@ class API():
|
||||||
return checksum
|
return checksum
|
||||||
|
|
||||||
def getGenres(self):
|
def getGenres(self):
|
||||||
item = self.item
|
|
||||||
all_genres = ""
|
all_genres = ""
|
||||||
genres = item.get('Genres', item.get('SeriesGenres'))
|
genres = self.item.get('Genres', self.item.get('SeriesGenres'))
|
||||||
|
|
||||||
if genres:
|
if genres:
|
||||||
all_genres = " / ".join(genres)
|
all_genres = " / ".join(genres)
|
||||||
|
@ -362,9 +357,8 @@ class API():
|
||||||
|
|
||||||
def getFilePath(self):
|
def getFilePath(self):
|
||||||
|
|
||||||
item = self.item
|
|
||||||
try:
|
try:
|
||||||
filepath = item['Path']
|
filepath = self.item['Path']
|
||||||
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
filepath = ""
|
filepath = ""
|
||||||
|
@ -375,8 +369,8 @@ class API():
|
||||||
filepath = filepath.replace("\\\\", "smb://")
|
filepath = filepath.replace("\\\\", "smb://")
|
||||||
filepath = filepath.replace("\\", "/")
|
filepath = filepath.replace("\\", "/")
|
||||||
|
|
||||||
if item.get('VideoType'):
|
if self.item.get('VideoType'):
|
||||||
videotype = item['VideoType']
|
videotype = self.item['VideoType']
|
||||||
# Specific format modification
|
# Specific format modification
|
||||||
if 'Dvd'in videotype:
|
if 'Dvd'in videotype:
|
||||||
filepath = "%s/VIDEO_TS/VIDEO_TS.IFO" % filepath
|
filepath = "%s/VIDEO_TS/VIDEO_TS.IFO" % filepath
|
||||||
|
@ -388,4 +382,3 @@ class API():
|
||||||
filepath = filepath.replace("/", "\\")
|
filepath = filepath.replace("/", "\\")
|
||||||
|
|
||||||
return filepath
|
return filepath
|
||||||
|
|
Loading…
Reference in a new issue