Merge pull request #1107 from croneter/fix-replace
Fix DirectPaths when a video's folder name is identical to a video's filename (you will need to manually reset the Kodi database)
This commit is contained in:
commit
e8242e0bcf
4 changed files with 15 additions and 6 deletions
|
@ -5,7 +5,7 @@ from logging import getLogger
|
||||||
|
|
||||||
from .common import ItemBase
|
from .common import ItemBase
|
||||||
from ..plex_api import API
|
from ..plex_api import API
|
||||||
from .. import app, variables as v, plex_functions as PF
|
from .. import app, variables as v, plex_functions as PF, utils
|
||||||
|
|
||||||
LOG = getLogger('PLEX.movies')
|
LOG = getLogger('PLEX.movies')
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ class Movie(ItemBase):
|
||||||
else:
|
else:
|
||||||
# Network share
|
# Network share
|
||||||
filename = playurl.rsplit("/", 1)[1]
|
filename = playurl.rsplit("/", 1)[1]
|
||||||
path = playurl.replace(filename, "")
|
path = utils.rreplace(playurl, filename, "", 1)
|
||||||
kodi_pathid = self.kodidb.add_path(path,
|
kodi_pathid = self.kodidb.add_path(path,
|
||||||
content='movies',
|
content='movies',
|
||||||
scraper='metadata.local')
|
scraper='metadata.local')
|
||||||
|
|
|
@ -7,7 +7,7 @@ from .common import ItemBase
|
||||||
from ..plex_api import API
|
from ..plex_api import API
|
||||||
from ..plex_db import PlexDB, PLEXDB_LOCK
|
from ..plex_db import PlexDB, PLEXDB_LOCK
|
||||||
from ..kodi_db import KodiMusicDB, KODIDB_LOCK
|
from ..kodi_db import KodiMusicDB, KODIDB_LOCK
|
||||||
from .. import plex_functions as PF, db, timing, app, variables as v
|
from .. import plex_functions as PF, db, timing, app, variables as v, utils
|
||||||
|
|
||||||
LOG = getLogger('PLEX.music')
|
LOG = getLogger('PLEX.music')
|
||||||
|
|
||||||
|
@ -539,7 +539,7 @@ class Song(MusicMixin, ItemBase):
|
||||||
else:
|
else:
|
||||||
# Network share
|
# Network share
|
||||||
filename = playurl.rsplit("/", 1)[1]
|
filename = playurl.rsplit("/", 1)[1]
|
||||||
path = playurl.replace(filename, "")
|
path = utils.rreplace(playurl, filename, "", 1)
|
||||||
if do_indirect:
|
if do_indirect:
|
||||||
# Plex works a bit differently
|
# Plex works a bit differently
|
||||||
path = "%s%s" % (app.CONN.server, xml[0][0].get('key'))
|
path = "%s%s" % (app.CONN.server, xml[0][0].get('key'))
|
||||||
|
|
|
@ -5,7 +5,7 @@ from logging import getLogger
|
||||||
|
|
||||||
from .common import ItemBase, process_path
|
from .common import ItemBase, process_path
|
||||||
from ..plex_api import API
|
from ..plex_api import API
|
||||||
from .. import plex_functions as PF, app, variables as v
|
from .. import plex_functions as PF, app, variables as v, utils
|
||||||
|
|
||||||
LOG = getLogger('PLEX.tvshows')
|
LOG = getLogger('PLEX.tvshows')
|
||||||
|
|
||||||
|
@ -434,7 +434,7 @@ class Episode(TvShowMixin, ItemBase):
|
||||||
else:
|
else:
|
||||||
# Network share
|
# Network share
|
||||||
filename = playurl.rsplit("/", 1)[1]
|
filename = playurl.rsplit("/", 1)[1]
|
||||||
path = playurl.replace(filename, "")
|
path = utils.rreplace(playurl, filename, "", 1)
|
||||||
parent_path_id = self.kodidb.parent_path_id(path)
|
parent_path_id = self.kodidb.parent_path_id(path)
|
||||||
kodi_pathid = self.kodidb.add_path(path,
|
kodi_pathid = self.kodidb.add_path(path,
|
||||||
id_parent_path=parent_path_id)
|
id_parent_path=parent_path_id)
|
||||||
|
|
|
@ -249,6 +249,15 @@ def ERROR(txt='', hide_tb=False, notify=False, cancel_sync=False):
|
||||||
return short
|
return short
|
||||||
|
|
||||||
|
|
||||||
|
def rreplace(s, old, new, occurrence=-1):
|
||||||
|
"""
|
||||||
|
Replaces the string old [str, unicode] with new from the RIGHT given a
|
||||||
|
string s.
|
||||||
|
"""
|
||||||
|
li = s.rsplit(old, occurrence)
|
||||||
|
return new.join(li)
|
||||||
|
|
||||||
|
|
||||||
class AttributeDict(dict):
|
class AttributeDict(dict):
|
||||||
"""
|
"""
|
||||||
Turns an etree xml response's xml.attrib into an object with attributes
|
Turns an etree xml response's xml.attrib into an object with attributes
|
||||||
|
|
Loading…
Reference in a new issue