Revert "Music: use strm files for addon paths"

This reverts commit 2d3f19b536.
This commit is contained in:
tomkat83 2017-04-14 17:57:36 +02:00
parent ca2a64e41c
commit 600b48d7aa

View file

@ -6,12 +6,10 @@ import logging
from urllib import urlencode from urllib import urlencode
from ntpath import dirname from ntpath import dirname
from datetime import datetime from datetime import datetime
from xbmc import sleep, translatePath from xbmc import sleep
from os import path as os_path, makedirs
import artwork import artwork
from utils import tryEncode, tryDecode, window, kodiSQL, CatchExceptions, \ from utils import tryEncode, tryDecode, window, kodiSQL, CatchExceptions
settings
import plexdb_functions as plexdb import plexdb_functions as plexdb
import kodidb_functions as kodidb import kodidb_functions as kodidb
@ -24,12 +22,6 @@ import variables as v
log = logging.getLogger("PLEX."+__name__) log = logging.getLogger("PLEX."+__name__)
MARK_PLAYED_AT = 0.90 MARK_PLAYED_AT = 0.90
if settings('enableMusic') == "true":
SONG_STREAM_DIR = ('special://userdata/addon_data/%s/musicstreamfiles/'
% v.ADDON_ID)
if not os_path.exists(translatePath(SONG_STREAM_DIR)):
makedirs(translatePath(SONG_STREAM_DIR))
############################################################################### ###############################################################################
@ -1629,31 +1621,32 @@ class Music(Items):
moods.append(entry.attrib['tag']) moods.append(entry.attrib['tag'])
mood = ' / '.join(moods) mood = ' / '.join(moods)
# GET THE FILE AND PATH #####
doIndirect = not self.directpath
if self.directpath: if self.directpath:
# Direct paths is set the Kodi way # Direct paths is set the Kodi way
playurl = API.getFilePath(forceFirstMediaStream=True) playurl = API.getFilePath(forceFirstMediaStream=True)
playurl = API.validatePlayurl(playurl, API.getType())
if playurl is None: if playurl is None:
return False # Something went wrong, trying to use non-direct paths
if "\\" in playurl: doIndirect = True
# Local path
filename = playurl.rsplit("\\", 1)[1]
else: else:
# Network share playurl = API.validatePlayurl(playurl, API.getType())
filename = playurl.rsplit("/", 1)[1] if playurl is None:
path = playurl.replace(filename, "") return False
else: if "\\" in playurl:
# now using .strm files instead to circumvent the inability to # Local path
# launch plugins directly from the library for music files filename = playurl.rsplit("\\", 1)[1]
filename = '%s.strm' % songid else:
with open(translatePath( # Network share
'%s%s' % (SONG_STREAM_DIR, filename)), 'w') as file: filename = playurl.rsplit("/", 1)[1]
file.write('plugin://%s?dbid=%s&mode=play&id=%s' path = playurl.replace(filename, "")
% (v.ADDON_ID, songid, itemid)) if doIndirect:
# Avoid telling kodi in which folder the music files are, so the # Plex works a bit differently
# scraper can't find them (and delete them) path = "%s%s" % (self.server, item[0][0].attrib.get('key'))
path = '' path = API.addPlexCredentialsToUrl(path)
filename = '%s%s' % (SONG_STREAM_DIR, filename) filename = path.rsplit('/', 1)[1]
path = path.replace(filename, '')
# UPDATE THE SONG ##### # UPDATE THE SONG #####
if update_item: if update_item:
log.info("UPDATE song itemid: %s - Title: %s with path: %s" log.info("UPDATE song itemid: %s - Title: %s with path: %s"