diff --git a/addons.xml b/addons.xml index 235231c..c626670 100644 --- a/addons.xml +++ b/addons.xml @@ -29,7 +29,7 @@ @@ -51,7 +51,7 @@ all 35647 Virtual Library Strm Generator - Generate Strms from your favourite plugins and upnp sources. + Generate Strms from Youtube, plugins and upnp sources. diff --git a/addons.xml.md5 b/addons.xml.md5 index ced843c..286e9f7 100644 --- a/addons.xml.md5 +++ b/addons.xml.md5 @@ -1 +1 @@ -c19ce151f7b04b702266952079e3bc0f \ No newline at end of file +a4e01b0112f262e3eda3e76e85b9ce63 \ No newline at end of file diff --git a/script.pseudo.library/FileAccess.py b/script.pseudo.library/FileAccess.py new file mode 100644 index 0000000..3bfe84c --- /dev/null +++ b/script.pseudo.library/FileAccess.py @@ -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 . + + +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 + + diff --git a/script.pseudo.library/addon.xml b/script.pseudo.library/addon.xml index bbf41a0..96c388a 100644 --- a/script.pseudo.library/addon.xml +++ b/script.pseudo.library/addon.xml @@ -1,7 +1,7 @@ @@ -23,6 +23,6 @@ all 35647 Virtual Library Strm Generator - Generate Strms from your favourite plugins and upnp sources. + Generate Strms from Youtube, plugins and upnp sources. diff --git a/script.pseudo.library/changelog.txt b/script.pseudo.library/changelog.txt index 32709c1..9fe89bb 100644 --- a/script.pseudo.library/changelog.txt +++ b/script.pseudo.library/changelog.txt @@ -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 \ No newline at end of file +Music type +#.0.0.7 +Library Scan and Clean options. +Service tweaks +SMB/NFS folder paths allowed. +#.0.0.8 +Service Fix \ No newline at end of file diff --git a/script.pseudo.library/default.py b/script.pseudo.library/default.py index abd23f1..4276399 100644 --- a/script.pseudo.library/default.py +++ b/script.pseudo.library/default.py @@ -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") \ No newline at end of file + REAL_SETTINGS.setSetting("SanityCheck","false") \ No newline at end of file diff --git a/script.pseudo.library/library.py b/script.pseudo.library/library.py index 0a00ed6..e9fa300 100644 --- a/script.pseudo.library/library.py +++ b/script.pseudo.library/library.py @@ -24,6 +24,7 @@ from urllib2 import unquote from xml.etree import ElementTree as ET from xml.dom.minidom import parse, parseString +from FileAccess import FileAccess # metahandler plugin import try: @@ -50,6 +51,9 @@ # Globals cache = StorageServer.StorageServer("plugin://script.pseudo.library/" + "cache",1) THUMB = REAL_SETTINGS.getAddonInfo('icon') +dlg = xbmcgui.Dialog() +Delay_INT = [0,5,10,15,20] +Refresh_INT = [2,4,6,12,24,48,72] class library: @@ -58,23 +62,25 @@ def __init__(self): self.discoveredWebServer = False self.background = True self.addonLST = [] - THUMB = REAL_SETTINGS.getAddonInfo('icon') if not REAL_SETTINGS.getSetting("STRM_LOC"): + #Set Default Strm Location Default_LOC = os.path.join(profile,'Strms') + #Set RealSetting Default STRM Location REAL_SETTINGS.setSetting("STRM_LOC",Default_LOC) def readSettings(self, config, background): - print 'readSettings' + print 'PseudoLibrary - readSettings' + #Check if readSettings already running (Service) REAL_SETTINGS.setSetting("SanityCheck","true") MSG = '' config = xbmc.translatePath(config) STRM_LOC = REAL_SETTINGS.getSetting('STRM_LOC') Settings2 = os.path.join(config,'settings2.xml') - print config, Settings2 + print 'PseudoLibrary - ' + Settings2 + #Enable XBMC Dialogue or null? self.background = background - self.updateCount = 0 # Clear Folder if REAL_SETTINGS.getSetting("Clear_Folder") == "true": @@ -88,30 +94,31 @@ def readSettings(self, config, background): if self.background == False: self.updateDialog = xbmcgui.DialogProgress() self.updateDialogProgress = 0 + self.updateDialogProgressCount = 0 self.updateDialog.create("PseudoLibrary", "Initializing") self.updateDialog.update(0, "Initializing") #parse internal list if not xbmcvfs.exists(Settings2): - print 'readSettings, creating settings2' + print 'PseudoLibrary - readSettings, creating settings2' + #create settings2.xml try: - f = open(Settings2, 'w') - f.write("Genre|Type|Source|Exclusion|Limit|NA|Name\n") + f = open(Settings2, "w") + f.write("Genre|Type|Source|Exclusion,Exclusion|Limit|ALTSwitch|Name|Rules\n") f.close except: MSG = "No Configuration File Found!, Check settings2.xml" pass else: #read from list - print 'readSettings, reading settings2' + print 'PseudoLibrary - readSettings, reading settings2' try: f = open(Settings2, 'r') Settings = f.readlines() f.close - self.updateDialogProgress = 1 if self.background == False: self.updateDialog.update(self.updateDialogProgress, "Reading Configurations", "Parsing Internal List", "") @@ -128,13 +135,12 @@ def readSettings(self, config, background): xbmc.executebuiltin("Notification( %s, %s, %d, %s)" % ("PseudoLibrary", MSG, 4000, THUMB) ) if REAL_SETTINGS.getSetting('CN_Enable') == 'true': - print 'readSettings, Recommended List Enabled' + print 'PseudoLibrary - readSettings, Recommended List Enabled' #parse external list genre_filter = [] url = 'https://pseudotv-live-community.googlecode.com/svn/addons.xml' url1 = 'https://pseudotv-live-community.googlecode.com/svn/playon.xml' - self.updateDialogProgress = 2 if self.background == False: self.updateDialog.update(self.updateDialogProgress, "Reading Configurations", "Parsing Internal List", "") @@ -179,16 +185,16 @@ def readSettings(self, config, background): for n in range(len(Settings)): line = ((Settings[n]).replace('\n','').replace('""',"")).split('|') StrmType = line[0] - BuildType = line[1] + BuildType = (line[1]).replace('15','Plugin').replace('16','Playon') setting1 = (line[2]).replace('plugin://','').replace('upnp://','') - setting2 = line[3] + setting2 = (line[3]).replace('plugin://','') setting3 = line[4] setting4 = line[5] FolderName = line[6] - if BuildType.lower() == 'plugin' or BuildType == '15': + if BuildType.lower() == 'plugin': setting1 = 'plugin://' + setting1 self.BuildPluginFileList(StrmType, BuildType, setting1, setting2, setting3, setting4, FolderName) - elif BuildType.lower() == 'playon' or BuildType.lower() == 'upnp' or BuildType == '16': + elif BuildType.lower() == 'playon' or BuildType.lower() == 'upnp': self.BuildPlayonFileList(StrmType, BuildType, setting1, setting2, setting3, setting4, FolderName) elif BuildType.lower() == 'youtube': self.createYoutubeFilelist(StrmType, BuildType, setting1, setting2, setting3, setting4, FolderName) @@ -199,6 +205,16 @@ def readSettings(self, config, background): REAL_SETTINGS.setSetting("SanityCheck","false") + if REAL_SETTINGS.getSetting("Automatic_Update_Folder") == "true": + xbmc.executebuiltin("UpdateLibrary(video,[%s])" % (STRM_LOC)) + # http://localhost:8080/jsonrpc?request={"jsonrpc":"2.0","method":"VideoLibrary.Scan","params":{"directory":"strmloc"},"id":3} + + if REAL_SETTINGS.getSetting("Automatic_Clean_Folder") == "true": + xbmc.executebuiltin("CleanLibrary(video)") + # http://localhost:8080/jsonrpc?request={"jsonrpc":"2.0","method":"VideoLibrary.Clean","params":{},"id":2} + + self.updateDialogProgress = 100 + def BuildPluginFileList(self, StrmType, BuildType, setting1, setting2, setting3, setting4, FolderName): print "BuildPluginFileList" @@ -207,6 +223,7 @@ def BuildPluginFileList(self, StrmType, BuildType, setting1, setting2, setting3, DetailLST_CHK = [] self.dircount = 0 self.filecount = 0 + # self.updateDialogProgressCount = self.updateDialogProgressCount + self.filecount + self.dircount limit = int(setting3) Pluginvalid = self.plugin_ok(setting1) @@ -253,8 +270,8 @@ def BuildPluginFileList(self, StrmType, BuildType, setting1, setting2, setting3, Match = False try: - for i in range(len(DetailLST)): - self.updateDialogProgress = self.updateDialogProgress + (i * 1) // 100 + for i in range(len(DetailLST)): + # self.updateDialogProgress = i * 1 // self.updateDialogProgressCount Detail = (DetailLST[i]).split(',') filetype = Detail[0] title = Detail[1] @@ -270,7 +287,7 @@ def BuildPluginFileList(self, StrmType, BuildType, setting1, setting2, setting3, if filetype == 'directory': CurDirect = self.CleanLabels(Directs[0]) if CurDirect.lower() == title.lower(): - print 'directory match' + print 'PseudoLibrary - directory match' LastName = CurDirect Directs.pop(0) #remove old directory, search next element plugin = file @@ -296,6 +313,7 @@ def BuildPlayonFileList(self, StrmType, BuildType, setting1, setting2, setting3, DetailLST_CHK = [] self.dircount = 0 self.filecount = 0 + # self.updateDialogProgressCount = self.updateDialogProgressCount + self.filecount + self.dircount limit = int(setting3) upnpID = self.playon_player() @@ -341,7 +359,7 @@ def BuildPlayonFileList(self, StrmType, BuildType, setting1, setting2, setting3, try: for i in range(len(DetailLST)): - self.updateDialogProgress = self.updateDialogProgress + (i * 1) // 100 + # self.updateDialogProgress = i * 1 // self.updateDialogProgressCount Detail = (DetailLST[i]).split(',') filetype = Detail[0] title = Detail[1] @@ -357,13 +375,13 @@ def BuildPlayonFileList(self, StrmType, BuildType, setting1, setting2, setting3, if filetype == 'directory': CurDirect = self.CleanLabels(Directs[0]) if CurDirect.lower() == title.lower(): - print 'directory match' + print 'PseudoLibrary - directory match' LastName = CurDirect Directs.pop(0) #remove old directory, search next element upnpID = file break except: - print 'BuildPlayonFileList, DetailLST Empty' + print 'PseudoLibrary - BuildPlayonFileList, DetailLST Empty' LastName = FolderName pass @@ -386,7 +404,7 @@ def PluginQuery(self, path): #Parse Plugin, return essential information. Not tmpstr def PluginInfo(self, path): - print 'PluginInfo' + print 'PseudoLibrary - PluginInfo' json_query = self.uni('{"jsonrpc":"2.0","method":"Files.GetDirectory","params":{"directory":"%s","properties":["genre","runtime","description"]},"id":1}' % ( (path),)) json_folder_detail = self.sendJSON(json_query) file_detail = re.compile( "{(.*?)}", re.DOTALL ).findall(json_folder_detail) @@ -440,7 +458,7 @@ def PluginInfo(self, path): Detail = ((filetype + ',' + title + ',' + genre + ',' + str(runtime) + ',' + description + ',' + file)).replace(',,',',') DetailLST.append(Detail) - print 'pluginInfo Return' + print 'PseudoLibrary - pluginInfo Return' return DetailLST @@ -482,6 +500,8 @@ def PluginWalk(self, path, excludeLST, limit, StrmType, BuildType, FleType, DirN labels = re.search('"label" *: *"(.*?)"', f) files = re.search('"file" *: *"(.*?)"', f) + # self.updateDialogProgressCount = self.updateDialogProgressCount + self.filecount + self.dircount + #if core variables have info proceed if filetypes and labels and files: filetype = filetypes.group(1) @@ -492,7 +512,7 @@ def PluginWalk(self, path, excludeLST, limit, StrmType, BuildType, FleType, DirN if label.lower() not in excludeLST and label != '': if filetype == 'directory': - print 'PluginWalk, directory' + print 'PseudoLibrary - PluginWalk, directory' #try to speed up parsing by not over searching directories when media limit is low if self.filecount < limit and self.dircount < dirlimit: @@ -500,7 +520,7 @@ def PluginWalk(self, path, excludeLST, limit, StrmType, BuildType, FleType, DirN if file[0:4] != 'upnp': #if no return, try unquote if not self.PluginInfo(file): - print 'unquote' + print 'PseudoLibrary - unquote' file = unquote(file).replace('",return)','') #remove unwanted reference to super.favorites plugin try: @@ -519,7 +539,7 @@ def PluginWalk(self, path, excludeLST, limit, StrmType, BuildType, FleType, DirN break elif filetype == 'file': - print 'PluginWalk, file' + print 'PseudoLibrary - PluginWalk, file' if self.filecount < limit: @@ -533,7 +553,7 @@ def PluginWalk(self, path, excludeLST, limit, StrmType, BuildType, FleType, DirN pass if file.startswith('plugin%3A%2F%2F'): - print 'unquote' + print 'PseudoLibrary - unquote' file = unquote(file).replace('",return)','') # If music duration returned, else 0 @@ -555,11 +575,11 @@ def PluginWalk(self, path, excludeLST, limit, StrmType, BuildType, FleType, DirN if dur == 18000: dur = 3600 - print 'PluginWalk, dur = ' + str(dur) + print 'PseudoLibrary - PluginWalk, dur = ' + str(dur) if dur > 0: self.filecount += 1 - self.updateDialogProgress = self.updateDialogProgress + (self.filecount * 1) // 100 + # self.updateDialogProgress = i * 1 // self.updateDialogProgressCount print "PluginWalk, filecount = " + str(self.filecount) +'/'+ str(limit) tmpstr = str(dur) + ',' @@ -709,10 +729,10 @@ def PluginWalk(self, path, excludeLST, limit, StrmType, BuildType, FleType, DirN showtitle = self.CleanLabels(showtitle) # if PlugCHK in DYNAMIC_PLUGIN_TV: - # print 'DYNAMIC_PLUGIN_TV' + # print 'PseudoLibrary - DYNAMIC_PLUGIN_TV' # if REAL_SETTINGS.getSetting('EnhancedGuideData') == 'true': - # print 'EnhancedGuideData' + # print 'PseudoLibrary - EnhancedGuideData' # if imdbnumber == 0: # imdbnumber = self.getTVDBID(showtitle, year) @@ -758,10 +778,10 @@ def PluginWalk(self, path, excludeLST, limit, StrmType, BuildType, FleType, DirN tmpstr += '' # if PlugCHK in DYNAMIC_PLUGIN_MOVIE: - # print 'DYNAMIC_PLUGIN_MOVIE' + # print 'PseudoLibrary - DYNAMIC_PLUGIN_MOVIE' # if REAL_SETTINGS.getSetting('EnhancedGuideData') == 'true': - # print 'EnhancedGuideData' + # print 'PseudoLibrary - EnhancedGuideData' # try: # showtitle = label.split(' (')[0] @@ -816,22 +836,24 @@ def PluginWalk(self, path, excludeLST, limit, StrmType, BuildType, FleType, DirN tmpstr = tmpstr + '\n' + file.replace("\\\\", "\\") self.WriteSTRM(tmpstr, StrmType, BuildType, PluginName, DirName, LastName) else: - print 'PluginWalk, filecount break' + print 'PseudoLibrary - PluginWalk, filecount break' self.filecount = 0 break for item in dirs: - print 'PluginWalk, recursive directory walk' + print 'PseudoLibrary - PluginWalk, recursive directory walk' if self.filecount >= limit: - print 'PluginWalk, recursive filecount break' + print 'PseudoLibrary - PluginWalk, recursive filecount break' break #recursively scan all subfolders self.PluginWalk(item, excludeLST, limit, StrmType, BuildType, FleType, DirName, LastName) - except: pass + + return + def log(msg, level =xbmc.LOGDEBUG): try: @@ -917,13 +939,7 @@ def determineWebServer(self): self.webUsername = '' self.webPassword = '' fle = xbmc.translatePath("special://profile/guisettings.xml") - - try: - xml = FileAccess.open(fle, "r") - except Exception,e: - print ("determineWebServer Unable to open the settings file") - self.httpJSON = False - return + self.httpJSON = False try: dom = parse(xml) @@ -1013,7 +1029,7 @@ def plugin_ok(self, plugin): else: addon = plugin - print 'addon', addon + print 'PseudoLibrary - addon', addon json_query = ('{"jsonrpc": "2.0", "method": "Addons.GetAddons", "params": {}, "id": 1}') json_folder_detail = self.sendJSON(json_query) @@ -1077,7 +1093,7 @@ def playon_player(self): break except: pass - print 'playon_player = ' + str(PlayonPath) + print 'PseudoLibrary - playon_player = ' + str(PlayonPath) return PlayonPath @@ -1173,7 +1189,7 @@ def getRating(self, type, title, year, imdbid): def getTVDBID(self, title, year): - print 'getTVDBID' + print 'PseudoLibrary - getTVDBID' tvdbid = 0 imdbid = 0 @@ -1208,7 +1224,7 @@ def getTVDBID(self, title, year): def getIMDBIDtv(self, title): - print 'getIMDBIDtv' + print 'PseudoLibrary - getIMDBIDtv' imdbid = 0 try: @@ -1234,7 +1250,7 @@ def getIMDBIDtv(self, title): def getTVDBIDbyIMDB(self, imdbid): - print 'getTVDBIDbyIMDB' + print 'PseudoLibrary - getTVDBIDbyIMDB' tvdbid = 0 try: @@ -1249,7 +1265,7 @@ def getTVDBIDbyIMDB(self, imdbid): def getIMDBIDmovie(self, showtitle, year): - print 'getIMDBIDmovie' + print 'PseudoLibrary - getIMDBIDmovie' imdbid = 0 try: print ("metahander") @@ -1275,7 +1291,7 @@ def getIMDBIDmovie(self, showtitle, year): def getTVDBIDbyZap2it(self, dd_progid): - print 'getTVDBIDbyZap2it' + print 'PseudoLibrary - getTVDBIDbyZap2it' tvdbid = 0 try: @@ -1292,7 +1308,7 @@ def getTVDBIDbyZap2it(self, dd_progid): def getTVINFObySubtitle(self, title, subtitle): - print 'getTVINFObySubtitle' + print 'PseudoLibrary - getTVINFObySubtitle' episode = '' episodeName = '' seasonNumber = 0 @@ -1313,7 +1329,7 @@ def getTVINFObySubtitle(self, title, subtitle): def getTVINFObySE(self, title, seasonNumber, episodeNumber): - print 'getTVINFObySE' + print 'PseudoLibrary - getTVINFObySE' episode = '' episodeName = '' episodeDesc = '' @@ -1341,7 +1357,7 @@ def getTVINFObySE(self, title, seasonNumber, episodeNumber): def getMovieINFObyTitle(self, title, year): - print 'getMovieINFObyTitle' + print 'PseudoLibrary - getMovieINFObyTitle' imdbid = 0 plot = '' tagline = '' @@ -1426,7 +1442,7 @@ def createYoutubeFilelist(self, StrmType, BuildType, setting1, setting2, setting startIndex = startIndex + 25 for i in range(len(feed['entries'])): - self.updateDialogProgress = self.updateDialogProgress + (i * 1) // 100 + # self.updateDialogProgress = i * 1 // self.updateDialogProgressCount try: showtitle = feed.channel.author_detail['name'] showtitle = showtitle.replace(":", "").replace('YouTube', setting1) @@ -1555,13 +1571,13 @@ def BuildMultiYoutubeChannelNetwork(self, StrmType, BuildType, setting1, setting def CleanLabels(self, label): - print 'CleanLabels' + print 'PseudoLibrary - CleanLabels' label = label.replace('[B]','').replace('[/B]','').replace('[/COLOR]','').replace('[COLOR=blue]','').replace('[COLOR=cyan]','').replace('[COLOR=red]','').replace('[COLOR=green]','').replace('[COLOR=yellow]','').replace(' [HD]', '').replace('(Sub) ','').replace('(Dub) ','').replace(' [cc]','').replace('\\',' ') return label def WriteSTRM(self, tmpstr, StrmType, BuildType, PluginName, DirName, LastName): - print 'WriteSTRM' + print 'PseudoLibrary - WriteSTRM' WriteNFO = False STRM_LOC = REAL_SETTINGS.getSetting('STRM_LOC') WriteNFO = REAL_SETTINGS.getSetting("Write_NFOS") == "true" @@ -1576,6 +1592,8 @@ def WriteSTRM(self, tmpstr, StrmType, BuildType, PluginName, DirName, LastName): genre = tmpstr[3] GenreLiveID = tmpstr[5] liveID = self.unpackLiveID(GenreLiveID) + DirName = re.sub('[\/:*?<>|!@#$/:]', '', DirName) + LastName = re.sub('[\/:*?<>|!@#$/:]', '', LastName) # print dur, title, eptitle, description, genre, GenreLiveID, liveID if StrmType.lower() == 'tvshow' or StrmType.lower() == 'tvshows' or StrmType.lower() == 'tv': @@ -1659,8 +1677,8 @@ def WriteSTRM(self, tmpstr, StrmType, BuildType, PluginName, DirName, LastName): else: FleFolder = os.path.join(Folder,PluginName,DirName) - Fle = os.path.join(FleFolder,FleName) - # print StrmType, FleName, Folder, FleFolder, Fle + Fle = (os.path.join(FleFolder,FleName)) + print 'PseudoLibrary - WriteSTRM - ' + Fle try: id = liveID[1] @@ -1677,11 +1695,16 @@ def WriteSTRM(self, tmpstr, StrmType, BuildType, PluginName, DirName, LastName): except: pass try: - f = open(Fle, "w") + f = FileAccess.open(Fle, "w") f.write("%s\n" % file) f.close except: pass + #todo #WriteNFO + #trigger xbmc library scan + #auto add folders as xbmc source + #source list switch for donors + \ No newline at end of file diff --git a/script.pseudo.library/resources/language/English/strings.xml b/script.pseudo.library/resources/language/English/strings.xml index dc0768b..623cd16 100644 --- a/script.pseudo.library/resources/language/English/strings.xml +++ b/script.pseudo.library/resources/language/English/strings.xml @@ -1,13 +1,13 @@ - - General Automatic Update Update Every (Hours) Startup Delay (Seconds) Run During Playback Clear Strm folder each run + Run Library Scan when finished + Clean Database when finished Create NFO's (ComingSoon) Sort Youtube into is own folder Strm Folder @@ -24,6 +24,10 @@ Help You can find help here Clear Strm Folder + Donor + Enable Donor Features + Enter Username:Password + Activate Donor Features diff --git a/script.pseudo.library/resources/settings.xml b/script.pseudo.library/resources/settings.xml index 1295e32..608672e 100644 --- a/script.pseudo.library/resources/settings.xml +++ b/script.pseudo.library/resources/settings.xml @@ -6,24 +6,33 @@ + + - - - - - - - - - + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/script.pseudo.library/service.py b/script.pseudo.library/service.py index 2c9918d..f57364e 100644 --- a/script.pseudo.library/service.py +++ b/script.pseudo.library/service.py @@ -35,6 +35,8 @@ def CHKSettings(): #create missing settings2.xml config = xbmc.translatePath(SETTINGS_LOC) Settings2 = config + '/settings2.xml' + REAL_SETTINGS.setSetting("SanityCheck","true") + if not xbmcvfs.exists(Settings2): try: f = open(Settings2, 'w') @@ -42,52 +44,60 @@ def CHKSettings(): f.close except: pass - - + + REAL_SETTINGS.setSetting("SanityCheck","false") + + +def DonorEnable(): + print 'DonorEnable' + Donor_UP = REAL_SETTINGS.getSetting('Donor_UP') + if REAL_SETTINGS.getSetting('Donor_Enable') == "true" and Donor_UP.lower() != 'user:password' and Donor_UP != '': + REAL_SETTINGS.setSetting("CN_Donor","true") + print 'DonorEnable = True' + else: + REAL_SETTINGS.setSetting("CN_Donor","false") + print 'DonorEnable = false' + + def AutomaticUpdate(): print 'AutomaticUpdate' - Delay_INT = [0,5,10,15,20] Update_Delay = Delay_INT[int(REAL_SETTINGS.getSetting('Automatic_Update_Delay'))] sleep(Update_Delay) while not xbmc.abortRequested: - if REAL_SETTINGS.getSetting('Automatic_Update') == 'true': + if REAL_SETTINGS.getSetting('Automatic_Update') == 'true' and REAL_SETTINGS.getSetting('SanityCheck') == 'false': now = datetime.datetime.today() - Refresh_INT = [2,4,6,12,24,48,72] Update_Refresh = Refresh_INT[int(REAL_SETTINGS.getSetting('Automatic_Update_Time'))] - # try: - Update_Timer_LastRun = REAL_SETTINGS.getSetting('Update_Timer_NextRun') - Update_Timer_LastRun = Update_Timer_LastRun.split('.')[0] - Update_Timer_LastRun = datetime.datetime.strptime(Update_Timer_LastRun, '%Y-%m-%d %H:%M:%S') - # except: - # Update_Timer_LastRun = now - # pass + try: + Update_Timer_NextRun = REAL_SETTINGS.getSetting('Update_Timer_NextRun') + Update_Timer_NextRun = Update_Timer_NextRun.split('.')[0] + Update_Timer_NextRun = datetime.datetime.strptime(Update_Timer_NextRun, '%Y-%m-%d %H:%M:%S') + except: + Update_Timer_NextRun = now + pass - if now >= Update_Timer_LastRun: + if now >= Update_Timer_NextRun: Update = True if REAL_SETTINGS.getSetting('Automatic_Update_Run') == 'false': if xbmc.Player().isPlaying(): Update = False if Update == True: - if REAL_SETTINGS.getSetting('SanityCheck') == 'false': - xbmc.executebuiltin("Notification( %s, %s, %d, %s)" % ("PseudoLibrary", "Background Service Starting", 4000, THUMB) ) + xbmc.executebuiltin("Notification( %s, %s, %d, %s)" % ("PseudoLibrary", "Background Service Starting", 4000, THUMB) ) - # Clear Folder - if REAL_SETTINGS.getSetting("Automatic_Clear_Folder") == "true": - REAL_SETTINGS.setSetting("Clear_Folder","true") - - library.readSettings(SETTINGS_LOC, True) - Update_Timer_NextRun = (Update_Timer_LastRun + datetime.timedelta(hours=Update_Refresh)) - print 'Update_Timer_LastRun', now - print 'Update_Timer_NextRun', Update_Timer_NextRun - REAL_SETTINGS.setSetting("Update_Timer_NextRun",str(Update_Timer_NextRun)) - xbmc.executebuiltin("Notification( %s, %s, %d, %s)" % ("PseudoLibrary", "Background Service Complete", 4000, THUMB) ) + # Clear Folder + if REAL_SETTINGS.getSetting("Automatic_Clear_Folder") == "true": + REAL_SETTINGS.setSetting("Clear_Folder","true") + + library.readSettings(SETTINGS_LOC, True) + Update_Timer_NextRun = (Update_Timer_NextRun + datetime.timedelta(hours=Update_Refresh)) + REAL_SETTINGS.setSetting("Update_Timer_NextRun",str(Update_Timer_NextRun)) + xbmc.executebuiltin("Notification( %s, %s, %d, %s)" % ("PseudoLibrary", "Background Service Complete", 4000, THUMB) ) xbmc.sleep(4000) - -REAL_SETTINGS.setSetting("SanityCheck","false") + CHKSettings() -AutomaticUpdate() \ No newline at end of file +DonorEnable() +AutomaticUpdate() diff --git a/zips/PTVLManager.exe b/zips/PTVLManager.exe new file mode 100644 index 0000000..f27604a Binary files /dev/null and b/zips/PTVLManager.exe differ diff --git a/zips/script.pseudo.library/script.pseudo.library-0.0.7.zip b/zips/script.pseudo.library/script.pseudo.library-0.0.7.zip new file mode 100644 index 0000000..d2e782d Binary files /dev/null and b/zips/script.pseudo.library/script.pseudo.library-0.0.7.zip differ diff --git a/zips/script.pseudo.library/script.pseudo.library-0.0.8.zip b/zips/script.pseudo.library/script.pseudo.library-0.0.8.zip new file mode 100644 index 0000000..1c3d758 Binary files /dev/null and b/zips/script.pseudo.library/script.pseudo.library-0.0.8.zip differ