New API method to retrieve only filename
This commit is contained in:
parent
bfd4415fa1
commit
d7891d6ec2
2 changed files with 18 additions and 14 deletions
|
@ -112,6 +112,22 @@ class API(object):
|
||||||
"""
|
"""
|
||||||
return self.item[self.mediastream][self.part]
|
return self.item[self.mediastream][self.part]
|
||||||
|
|
||||||
|
def file_name(self, force_first_media=False):
|
||||||
|
"""
|
||||||
|
Returns only the filename, e.g. 'movie.mkv' as unicode or None if not
|
||||||
|
found
|
||||||
|
"""
|
||||||
|
ans = self.file_path(force_first_media=force_first_media)
|
||||||
|
if ans is None:
|
||||||
|
return
|
||||||
|
if "\\" in ans:
|
||||||
|
# Local path
|
||||||
|
filename = ans.rsplit("\\", 1)[1]
|
||||||
|
else:
|
||||||
|
# Network share
|
||||||
|
filename = ans.rsplit("/", 1)[1]
|
||||||
|
return filename
|
||||||
|
|
||||||
def file_path(self, force_first_media=False):
|
def file_path(self, force_first_media=False):
|
||||||
"""
|
"""
|
||||||
Returns the direct path to this item, e.g. '\\NAS\movies\movie.mkv'
|
Returns the direct path to this item, e.g. '\\NAS\movies\movie.mkv'
|
||||||
|
|
|
@ -288,13 +288,7 @@ class Movies(Items):
|
||||||
scraper='metadata.local')
|
scraper='metadata.local')
|
||||||
if do_indirect:
|
if do_indirect:
|
||||||
# Set plugin path and media flags using real filename
|
# Set plugin path and media flags using real filename
|
||||||
filename = api.file_path(force_first_media=True)
|
filename = api.file_name(force_first_media=True)
|
||||||
if "\\" in filename:
|
|
||||||
# Local path
|
|
||||||
filename = filename.rsplit("\\", 1)[1]
|
|
||||||
else:
|
|
||||||
# Network share
|
|
||||||
filename = filename.rsplit("/", 1)[1]
|
|
||||||
path = 'plugin://%s.movies/' % v.ADDON_ID
|
path = 'plugin://%s.movies/' % v.ADDON_ID
|
||||||
filename = ('%s?plex_id=%s&plex_type=%s&mode=play&filename=%s'
|
filename = ('%s?plex_id=%s&plex_type=%s&mode=play&filename=%s'
|
||||||
% (path, itemid, v.PLEX_TYPE_MOVIE, filename))
|
% (path, itemid, v.PLEX_TYPE_MOVIE, filename))
|
||||||
|
@ -857,13 +851,7 @@ class TVShows(Items):
|
||||||
else:
|
else:
|
||||||
# Set plugin path - do NOT use "intermediate" paths for the show
|
# Set plugin path - do NOT use "intermediate" paths for the show
|
||||||
# as with direct paths!
|
# as with direct paths!
|
||||||
filename = api.file_path(force_first_media=True)
|
filename = api.file_name(force_first_media=True)
|
||||||
if "\\" in filename:
|
|
||||||
# Local path
|
|
||||||
filename = filename.rsplit("\\", 1)[1]
|
|
||||||
else:
|
|
||||||
# Network share
|
|
||||||
filename = filename.rsplit("/", 1)[1]
|
|
||||||
path = 'plugin://%s.tvshows/' % v.ADDON_ID
|
path = 'plugin://%s.tvshows/' % v.ADDON_ID
|
||||||
filename = ('%s?plex_id=%s&plex_type=%s&mode=play&filename=%s'
|
filename = ('%s?plex_id=%s&plex_type=%s&mode=play&filename=%s'
|
||||||
% (path, itemid, v.PLEX_TYPE_EPISODE, filename))
|
% (path, itemid, v.PLEX_TYPE_EPISODE, filename))
|
||||||
|
|
Loading…
Reference in a new issue