Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions addons.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

<addon
id="script.pseudo.library"
version="0.0.6"
version="0.0.8"
name="PseudoLibrary"
provider-name="Lunatixz">
<requires>
Expand All @@ -51,7 +51,7 @@
<platform>all</platform>
<minversion>35647</minversion>
<summary lang="en">Virtual Library Strm Generator</summary>
<description lang="en">Generate Strms from your favourite plugins and upnp sources.</description>
<description lang="en">Generate Strms from Youtube, plugins and upnp sources.</description>
</extension>
</addon>

Expand Down
2 changes: 1 addition & 1 deletion addons.xml.md5
Original file line number Diff line number Diff line change
@@ -1 +1 @@
c19ce151f7b04b702266952079e3bc0f
a4e01b0112f262e3eda3e76e85b9ce63
219 changes: 219 additions & 0 deletions script.pseudo.library/FileAccess.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
# Copyright (C) 2013 Jason Anderson, Lunatixz
#
#
# This file is part of PseudoLibrary.
#
# PseudoLibrary is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# PseudoLibrary is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with PseudoLibrary. If not, see <http://www.gnu.org/licenses/>.


import xbmc
import os, shutil
import codecs
import xbmcvfs
import xbmcaddon
VFS_AVAILABLE = True

__addon__ = xbmcaddon.Addon(id='script.pseudo.library')
__addonid__ = __addon__.getAddonInfo('id')


def ascii(string):
if isinstance(string, basestring):
if isinstance(string, unicode):
string = string.encode('ascii', 'ignore')

return string

class FileAccess:
@staticmethod
def log(txt):
if __addon__.getSetting( "logEnabled" ) == "true":
if isinstance (txt,str):
txt = txt.decode("utf-8")
message = u'%s: %s' % (__addonid__, txt)
xbmc.log(msg=message.encode("utf-8"), level=xbmc.LOGDEBUG)


@staticmethod
def open(filename, mode, encoding = "utf-8"):
fle = 0
FileAccess.log("trying to open " + filename)

try:
return VFSFile(filename, mode)
except UnicodeDecodeError:
return FileAccess.open(ascii(filename), mode, encoding)

return fle


@staticmethod
def copy(orgfilename, newfilename):
FileAccess.log('copying ' + orgfilename + ' to ' + newfilename)
xbmcvfs.copy(orgfilename, newfilename)
return True


@staticmethod
def exists(filename):
try:
return xbmcvfs.exists(filename)
except UnicodeDecodeError:
return FileAccess.exists(ascii(filename))

return False


@staticmethod
def openSMB(filename, mode, encoding = "utf-8"):
fle = 0

if os.name.lower() == 'nt':
newname = '\\\\' + filename[6:]

try:
fle = codecs.open(newname, mode, encoding)
except:
fle = 0

return fle


@staticmethod
def existsSMB(filename):
if os.name.lower() == 'nt':
filename = '\\\\' + filename[6:]
return FileAccess.exists(filename)

return False


@staticmethod
def rename(path, newpath):
FileAccess.log("rename " + path + " to " + newpath)

try:
if xbmcvfs.rename(path, newpath):
return True
except:
pass

if path[0:6].lower() == 'smb://' or newpath[0:6].lower() == 'smb://':
if os.name.lower() == 'nt':
FileAccess.log("Modifying name")
if path[0:6].lower() == 'smb://':
path = '\\\\' + path[6:]

if newpath[0:6].lower() == 'smb://':
newpath = '\\\\' + newpath[6:]

try:
os.rename(path, newpath)
FileAccess.log("os.rename")
return True
except:
pass

try:
shutil.move(path, newpath)
FileAccess.log("shutil.move")
return True
except:
pass

FileAccess.log("OSError")
raise OSError()


@staticmethod
def makedirs(directory):
try:
os.makedirs(directory)
except:
FileAccess._makedirs(directory)


@staticmethod
def _makedirs(path):
if len(path) == 0:
return False

if(xbmcvfs.exists(path)):
return True

success = xbmcvfs.mkdir(path)

if success == False:
if path == os.path.dirname(path):
return False

if FileAccess._makedirs(os.path.dirname(path)):
return xbmcvfs.mkdir(path)

return xbmcvfs.exists(path)



class VFSFile:
def __init__(self, filename, mode):
# log("VFSFile: trying to open " + filename)

if mode == 'w':
self.currentFile = xbmcvfs.File(filename, 'wb')
else:
self.currentFile = xbmcvfs.File(filename)

# log("VFSFile: Opening " + filename, xbmc.LOGDEBUG)

if self.currentFile == None:
log("VFSFile: Couldnt open " + filename, xbmc.LOGERROR)


def read(self, bytes):
return self.currentFile.read(bytes)


def write(self, data):
if isinstance(data, unicode):
data = bytearray(data, "utf-8")
data = bytes(data)

return self.currentFile.write(data)


def close(self):
return self.currentFile.close()


def seek(self, bytes, offset):
return self.currentFile.seek(bytes, offset)


def size(self):
loc = self.currentFile.size()
return loc


def readlines(self):
return self.currentFile.read().split('\n')

def writelines(self):
return self.currentFile.write().split('\n')


def tell(self):
loc = self.currentFile.seek(0, 1)
return loc


4 changes: 2 additions & 2 deletions script.pseudo.library/addon.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon
id="script.pseudo.library"
version="0.0.6"
version="0.0.8"
name="PseudoLibrary"
provider-name="Lunatixz">
<requires>
Expand All @@ -23,6 +23,6 @@
<platform>all</platform>
<minversion>35647</minversion>
<summary lang="en">Virtual Library Strm Generator</summary>
<description lang="en">Generate Strms from your favourite plugins and upnp sources.</description>
<description lang="en">Generate Strms from Youtube, plugins and upnp sources.</description>
</extension>
</addon>
8 changes: 7 additions & 1 deletion script.pseudo.library/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,10 @@ Youtube Sort? Place Youtube into it's own folder.
Clear Strm Folder (Purge all files and folders).
Service Loop fix!
New plugin detection
Music type
Music type
#.0.0.7
Library Scan and Clean options.
Service tweaks
SMB/NFS folder paths allowed.
#.0.0.8
Service Fix
5 changes: 1 addition & 4 deletions script.pseudo.library/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,11 @@

import xbmc, xbmcgui, xbmcaddon, xbmcvfs
import os

from library import *

dlg = xbmcgui.Dialog()
library = library()

if dlg.yesno("PseudoLibrary", "Generate Strm's ?"):
SETTINGS_LOC = REAL_SETTINGS.getAddonInfo('profile')
if REAL_SETTINGS.getSetting('SanityCheck') == 'false':
library.readSettings(SETTINGS_LOC, False)
REAL_SETTINGS.setSetting("SanityCheck","false")
REAL_SETTINGS.setSetting("SanityCheck","false")
Loading