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