예제 #1
0
def doDownload(file):
    utils.log('download url: %s' % file)
    dst = ADDON.getSetting('DOWNLOAD_FOLDER')

    import sfile
    sfile.makedirs(dst)

    if not sfile.isdir(dst):
        utils.DialogOK(GETTEXT(30256), GETTEXT(30257))
        utils.openSettings(ADDONID, 2.24)
        xbmc.sleep(500)
        while(xbmc.getCondVisibility('Window.IsActive(addonsettings)') == 1):
            xbmc.sleep(100)

    dst = ADDON.getSetting('DOWNLOAD_FOLDER')
    if not sfile.isdir(dst):
        utils.DialogOK(GETTEXT(30256))
        return

    dst = os.path.join(ADDON.getSetting('DOWNLOAD_FOLDER'), getDownloadTitle(file))  

    if utils.DialogYesNo(GETTEXT(30243), GETTEXT(30244)):            
        xbmc.Player().stop()
       
    import download            
    download.download(file, dst, 'Super Favourites')
예제 #2
0
def checkCacheDir():
    try:
        if sfile.isdir(CacheDir):
            return
    except:
        pass

    sfile.makedirs(CacheDir)
예제 #3
0
파일: cache.py 프로젝트: sokam/kodiprofile
def checkCacheDir():
    try:
        if sfile.isdir(CacheDir):
            return
    except:
        pass

    sfile.makedirs(CacheDir)
예제 #4
0
def clearCache():
    try:
        sfile.rmtree(CacheDir)
        while sfile.isdir(CacheDir):
            xbmc.sleep(50)
    except:
        pass

    checkCacheDir()
예제 #5
0
파일: cache.py 프로젝트: sokam/kodiprofile
def clearCache():
    try:
        sfile.rmtree(CacheDir)
        while sfile.isdir(CacheDir):
            xbmc.sleep(50)        
    except:
        pass

    checkCacheDir()
예제 #6
0
def delete(path, APPLICATION=None):
    path = path.replace(DELIMETER, os.sep)
    
    if sfile.isdir(path):        
        _DeleteFolder(path, APPLICATION)
    else:
        _DeleteFile(path, APPLICATION) 

    if APPLICATION:
        APPLICATION.containerRefresh()
def getCmd(path, fanart, desc, window, filename, isFolder, meta):
    import favourite

    if path.lower().startswith('addons://user/'):
        path = path.replace('addons://user/', 'plugin://')
        isFolder = True
        window = 10025

    if window == 10003:  #FileManager
        import sfile
        import os
        isFolder = sfile.isdir(path)
        if isFolder:
            #special paths fail to open - http://trac.kodi.tv/ticket/17333
            if path.startswith('special://'):
                path = xbmc.translatePath(path)
            path = path.replace('%s%s' % (os.sep, os.sep), os.sep)
            path = path.replace(os.sep, '/')
            folder = path
            if folder.endswith('/'):
                folder = folder[:-1]
            folder = folder.rsplit('/', 1)[-1]
            #if not utils.DialogYesNo(GETTEXT(30271) % folder, GETTEXT(30272)):
            #    return None

    if isFolder:
        cmd = 'ActivateWindow(%d,"%s' % (window, path)
    elif path.lower().startswith('script'):
        #if path[-1] == '/':
        #    path = path[:-1]
        cmd = 'RunScript("%s' % path.replace('script://', '')
    elif path.lower().startswith('videodb') and len(filename) > 0:
        cmd = 'PlayMedia("%s' % filename.replace('\\', '\\\\')
    #elif path.lower().startswith('musicdb') and len(filename) > 0:
    #    cmd = 'PlayMedia("%s")' % filename
    elif path.lower().startswith('androidapp'):
        cmd = 'StartAndroidActivity("%s")' % path.replace(
            'androidapp://sources/apps/', '', 1)
    else:
        cmd = 'PlayMedia("%s")' % path
        cmd = favourite.updateSFOption(cmd, 'winID', window)

    cmd = favourite.addFanart(cmd, fanart)
    cmd = favourite.updateSFOption(cmd, 'desc', desc)

    if meta:
        import urllib
        meta = utils.convertDictToURL(meta)
        cmd = favourite.updateSFOption(cmd, 'meta', urllib.quote_plus(meta))

    if isFolder:
        cmd = cmd.replace('")', '",return)')

    return cmd
예제 #8
0
def GetFolder(title):
    default = ''
    folder  = xbmc.translatePath(PROFILE)

    if not sfile.isdir(folder):
        sfile.makedirs(folder) 

    folder = xbmcgui.Dialog().browse(3, title, 'files', '', False, False, default)
    if folder == default:
        return None

    return xbmc.translatePath(folder)
예제 #9
0
def getLocalContent(url, ext):
    filename = None
    try:
        if sfile.isfile(url):
            filename = removeExtension(url) + '.' + ext
        
        if sfile.isdir(url):
            filename = url + '.' + ext

        if filename:
            return sfile.read(filename)

    except:
        pass

    return ''
예제 #10
0
def CheckVersion():
    prev = ADDON.getSetting('VERSION')
    curr = VERSION

    if prev == curr:        
        return

    ADDON.setSetting('VERSION', curr)

    if prev == '0.0.0' or prev == '1.0.0':
        folder  = xbmc.translatePath(PROFILE)
        if not sfile.isdir(folder):
            try:    sfile.makedirs(folder) 
            except: pass

    #call showChangeLog like this to workaround bug in openElec
    script = os.path.join(HOME, 'showChangelog.py')
    cmd    = 'AlarmClock(%s,RunScript(%s),%d,True)' % ('changelog', script, 0)
    xbmc.executebuiltin(cmd)
예제 #11
0
def CheckVersion():
    prev = ADDON.getSetting("VERSION")
    curr = VERSION

    if prev == curr:
        return

    ADDON.setSetting("VERSION", curr)

    if prev == "0.0.0" or prev == "1.0.0":
        folder = xbmc.translatePath(PROFILE)
        try:
            if not sfile.isdir(folder):
                sfile.makedirs(folder)
        except:
            pass

    # call showChangeLog like this to workaround bug in openElec
    script = os.path.join(HOME, "showChangelog.py")
    cmd = "AlarmClock(%s,RunScript(%s),%d,True)" % ("changelog", script, 0)
    xbmc.executebuiltin(cmd)
예제 #12
0
def _getCmd(path, fanart, desc, window, filename, isFolder, meta, picture):
    if path.lower().startswith('addons://user/'):
        path     = path.replace('addons://user/', 'plugin://')
        isFolder = True
        window   = 10025

    window = fixWindowID(window)

    if window == 10003:#FileManager
        import sfile
        import os

        isFolder = sfile.isdir(path)
        if isFolder:
            #special paths fail to open - http://trac.kodi.tv/ticket/17333
            if path.startswith('special://'):
                path = xbmc.translatePath(path)
            path = path.replace('%s%s' % (os.sep, os.sep), os.sep)
            path = path.replace(os.sep, '/')
            folder = path
            if folder.endswith('/'):
                folder = folder[:-1]
            folder = folder.rsplit('/', 1)[-1]
            #if not utils.DialogYesNo(GETTEXT(30271) % folder, GETTEXT(30272)):
            #    return None
        else:
            if not sfile.isfile(path):
                return None

    if favourite.isKodiCommand(path):
        return path
    elif len(picture) > 0:
        cmd = 'ShowPicture("%s")'  % picture
    elif isFolder:
        cmd =  'ActivateWindow(%d,"%s' % (window, path)
    elif path.lower().startswith('script'):
        #if path[-1] == '/':
        #    path = path[:-1]
        cmd = 'RunScript("%s' % path.replace('script://', '')
    elif path.lower().startswith('videodb') and len(filename) > 0:
        cmd = 'PlayMedia("%s' % filename.replace('\\', '\\\\')
    #elif path.lower().startswith('musicdb') and len(filename) > 0:
    #    cmd = 'PlayMedia("%s")' % filename
    elif path.lower().startswith('androidapp'):
        cmd = 'StartAndroidActivity("%s")' % path.replace('androidapp://sources/apps/', '', 1)
    else:            
        cmd = 'PlayMedia("%s")' % path
        cmd = favourite.updateSFOption(cmd, 'winID', window)

    cmd = favourite.addFanart(cmd, fanart)
    cmd = favourite.updateSFOption(cmd, 'desc', desc)

    if meta:
        import urllib
        meta = utils.convertDictToURL(meta)
        cmd  = favourite.updateSFOption(cmd, 'meta', urllib.quote_plus(meta))

    if isFolder:
        cmd = cmd.replace('")', '",return)')

    return cmd