Simplify code to get path and filename
This commit is contained in:
parent
98975ff23d
commit
db0f7f283e
1 changed files with 3 additions and 6 deletions
|
@ -22,12 +22,9 @@ def kodiid_from_filename(path, kodi_type=None, db_type=None):
|
||||||
"""
|
"""
|
||||||
kodi_id = None
|
kodi_id = None
|
||||||
path = utils.try_decode(path)
|
path = utils.try_decode(path)
|
||||||
try:
|
path, filename = path_ops.path.split(path)
|
||||||
filename = path.rsplit('/', 1)[1]
|
# Make sure path ends in either '/' or '\'
|
||||||
path = path.rsplit('/', 1)[0] + '/'
|
path = path_ops.path.join(path, '')
|
||||||
except IndexError:
|
|
||||||
filename = path.rsplit('\\', 1)[1]
|
|
||||||
path = path.rsplit('\\', 1)[0] + '\\'
|
|
||||||
if kodi_type == v.KODI_TYPE_SONG or db_type == 'music':
|
if kodi_type == v.KODI_TYPE_SONG or db_type == 'music':
|
||||||
with KodiMusicDB(lock=False) as kodidb:
|
with KodiMusicDB(lock=False) as kodidb:
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in a new issue