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

    import sfile
    sfile.makedirs(dst)

    if not sfile.exists(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.exists(dst):
        utils.DialogOK(GETTEXT(30256))
        return

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

    if utils.DialogYesNo(GETTEXT(30243), GETTEXT(30244)):
        xbmc.executebuiltin('Action(Stop)')

    import download
    download.download(file, dst, utils.TITLE)
Example #2
0
def doDownload(file):
    utils.log('download url: %s' % file)
    dst = ADDON.getSetting('DOWNLOAD_FOLDER')

    import sfile
    sfile.makedirs(dst)

    if not sfile.exists(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.exists(dst):
        utils.DialogOK(GETTEXT(30256))
        return

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

    if utils.DialogYesNo(GETTEXT(30243), GETTEXT(30244)):            
        xbmc.executebuiltin('Action(Stop)')
       
    import download            
    download.download(file, dst, utils.TITLE)
Example #3
0
def RetrieveURL(url, type, isServer):
    if len(url) == 0:
        return

    if type == VIDEO_ADDON:
        AddDir(1, url, 0)

    root = utils.getDownloadLocation()

    if type == SERVER_FILE:
        dst = urllib.quote_plus(url)
        dst = os.path.join(root, dst)

        if not sfile.exists(dst):
            try:    sfile.copy(url, dst)
            except: pass
        AddDir(1, dst, 0)

    if type == AMAZON_FILE:
        src = url.lower().endswith('.txt') or url.lower().endswith('.%s' % SRC)
        url = urllib.quote_plus(url)
        dst = os.path.join(root, url)

        import download
        url = s3.getURL(url)
        url = s3.convertToCloud(url)
        utils.Log('Amazon URL : %s' % url)        

        if src:
            url = utils.GetHTML(url, maxAge=7*86400)
            url = urllib.quote_plus(url)
            dst = os.path.join(root, url)
            url = s3.getURL(url)
            url = s3.convertToCloud(url)                
            utils.Log('Real Amazon URL : %s' % url) 
            
        downloading = sfile.exists(dst+'.part')

        if downloading:
            if False:#isServer:
                AddDir(1, dst, 0)
            else:
                AddDir(1, url, 0)

            return

        if sfile.exists(dst):
            AddDir(1, dst, 0)
            return

        download.download(url, dst)

        #if isServer:
        #    while sfile.size(dst) == 0:
        #        xbmc.sleep(100)
        #    AddDir(1, dst, 0)
        #    return

        AddDir(1, url, 0)
Example #4
0
def downloadDefaults(url):
    import download
    import extract

    url1 = url + 'ott/skins.zip'
    url2 = url + 'ottepg/skins.zip'
    url3 = url + 'ottepg/logos.zip'
    # url4 = url + 'ottepg/channels.zip'

    path1 = xbmc.translatePath(PROFILE)  # /addon_data/script.on-tapp.tv/
    path2 = os.path.join(epgpath,
                         'extras')  # /addon_data/script.tvguidedixie/extras/
    path3 = os.path.join(path2, 'skins')
    path4 = os.path.join(path2, 'logos')

    zip1 = os.path.join(path1, 'skins.zip')
    zip2 = os.path.join(path2, 'skins.zip')
    zip3 = os.path.join(path2, 'logos.zip')
    # zip4  = os.path.join(epgpath, 'channels.zip')

    if not sfile.exists(epgpath):
        sfile.makedirs(epgpath)

    if not sfile.exists(path1):
        sfile.makedirs(path1)
    download.download(url1, zip1)
    extract.all(zip1, path1, dp='Installing OTT skins')
    sfile.remove(zip1)

    if not sfile.exists(path2):
        sfile.makedirs(path2)
    download.download(url2, zip2)
    extract.all(zip2, path2, dp='Installing EPG skins')
    sfile.remove(zip2)

    if not sfile.exists(path4):
        sfile.makedirs(path2)
    download.download(url3, zip3)
    extract.all(zip3, path2)
    sfile.remove(zip3)

    # if not sfile.exists(epgpath):
    #     sfile.makedirs(epgpath)
    # download.download(url4, zip4)
    # extract.all(zip4, epgpath)
    # sfile.remove(zip4)

    Addon.setSetting('dixie.skin', 'EPG-Skin')
    Addon.setSetting('playlist.url', '')
    utils.setSetting('SKIN', 'OTT-Skin')

    if utils.DialogYesNo('Would you like to assign a button ',
                         'on your remote control or keybord',
                         'to activate the On-Tapp.TV Mini-Guide?'):
        xbmc.executebuiltin(
            'RunScript(special://home/addons/script.tvguidedixie/keyProgrammer.py)'
        )

    utils.setSetting('FIRSTRUN', 'true')
Example #5
0
def downloadDefaults(url):
    import download
    import extract

    url1 = url + 'tvp/skins.zip'
    url2 = url + 'tvpepg/skins.zip'
    url3 = url + 'tvpepg/logos.zip'
    url4 = url + 'tvpepg/channels.zip'

    path1 = xbmc.translatePath(PROFILE)  # /addon_data/script.community.portal/
    path2 = os.path.join(epgpath,
                         'extras')  # /addon_data/script.tvportal.epg/extras/
    path3 = os.path.join(path2, 'skins')
    path4 = os.path.join(path2, 'logos')

    zip1 = os.path.join(path1, 'skins.zip')
    zip2 = os.path.join(path2, 'skins.zip')
    zip3 = os.path.join(path2, 'logos.zip')
    zip4 = os.path.join(epgpath, 'channels.zip')

    if not sfile.exists(epgpath):
        sfile.makedirs(epgpath)

    if not sfile.exists(path1):
        sfile.makedirs(path1)
    download.download(url1, zip1)
    extract.all(zip1, path1, dp='Installing TVP skins')
    sfile.remove(zip1)

    if not sfile.exists(path2):
        sfile.makedirs(path2)
    download.download(url2, zip2)
    extract.all(zip2, path2, dp='Installing EPG skins')
    sfile.remove(zip2)

    if not sfile.exists(path4):
        sfile.makedirs(path2)
    download.download(url3, zip3)
    extract.all(zip3, path2)
    sfile.remove(zip3)

    if not sfile.exists(epgpath):
        sfile.makedirs(epgpath)
    download.download(url4, zip4)
    extract.all(zip4, epgpath)
    sfile.remove(zip4)

    if isDSF():
        Addon.setSetting('common.skin', 'EPG-Skin')
        Addon.setSetting('playlist.url', '')
        setSetting('SKIN', 'TVP-Skin')
    else:
        Addon.setSetting('common.skin', 'FXB v4.0')
        setSetting('SKIN', 'FXB78')

    setSetting('FIRSTRUN', 'true')
def downloadDefaults(url):
    import download
    import extract

    url1 = url + "ott/skins.zip"
    url2 = url + "ottepg/skins.zip"
    url3 = url + "ottepg/logos.zip"
    url4 = url + "ottepg/channels.zip"

    path1 = xbmc.translatePath(PROFILE)  # /addon_data/script.on-tapp.tv/
    path2 = os.path.join(epgpath, "extras")  # /addon_data/script.tvguidedixie/extras/
    path3 = os.path.join(path2, "skins")
    path4 = os.path.join(path2, "logos")

    zip1 = os.path.join(path1, "skins.zip")
    zip2 = os.path.join(path2, "skins.zip")
    zip3 = os.path.join(path2, "logos.zip")
    zip4 = os.path.join(epgpath, "channels.zip")

    if not sfile.exists(epgpath):
        sfile.makedirs(epgpath)

    if not sfile.exists(path1):
        sfile.makedirs(path1)
    download.download(url1, zip1)
    extract.all(zip1, path1, dp="Installing OTT skins")
    sfile.remove(zip1)

    if not sfile.exists(path2):
        sfile.makedirs(path2)
    download.download(url2, zip2)
    extract.all(zip2, path2, dp="Installing EPG skins")
    sfile.remove(zip2)

    if not sfile.exists(path4):
        sfile.makedirs(path2)
    download.download(url3, zip3)
    extract.all(zip3, path2)
    sfile.remove(zip3)

    if not sfile.exists(epgpath):
        sfile.makedirs(epgpath)
    download.download(url4, zip4)
    extract.all(zip4, epgpath)
    sfile.remove(zip4)

    if OTTURL == "OTHER":
        Addon.setSetting("dixie.url", "Other")
        Addon.setSetting("dixie.skin", "EPG-Skin")
        setSetting("SKIN", "OTT-Skin")
    else:
        Addon.setSetting("dixie.url", "All Channels")
        Addon.setSetting("dixie.skin", "FXB v4.0")
        setSetting("SKIN", "FXB78")

    setSetting("FIRSTRUN", "true")
def downloadDefaults(url):
    import download
    import extract

    url1 = url + 'ott/skins.zip'
    url2 = url + 'ottepg/skins.zip'
    url3 = url + 'ottepg/logos.zip'
    url4 = url + 'ottepg/channels.zip'
    
    path1 = xbmc.translatePath(PROFILE)     # /addon_data/script.on-tapp.tv/
    path2 = os.path.join(epgpath, 'extras') # /addon_data/script.tvguidedixie/extras/
    path3 = os.path.join(path2,   'skins')
    path4 = os.path.join(path2,   'logos')
    
    zip1  = os.path.join(path1,   'skins.zip')
    zip2  = os.path.join(path2,   'skins.zip')
    zip3  = os.path.join(path2,   'logos.zip')
    zip4  = os.path.join(epgpath, 'channels.zip')

    if not sfile.exists(epgpath):
        sfile.makedirs(epgpath)
    
    if not sfile.exists(path1):
        sfile.makedirs(path1)
    download.download(url1, zip1)
    extract.all(zip1, path1, dp='Installing OTT skins')
    sfile.remove(zip1)
    
    if not sfile.exists(path2):
        sfile.makedirs(path2)
    download.download(url2, zip2)
    extract.all(zip2, path2, dp='Installing EPG skins')
    sfile.remove(zip2)
    
    if not sfile.exists(path4):
        sfile.makedirs(path2)
    download.download(url3, zip3)
    extract.all(zip3, path2)
    sfile.remove(zip3)
    
    if not sfile.exists(epgpath):
        sfile.makedirs(epgpath)
    download.download(url4, zip4)
    extract.all(zip4, epgpath)
    sfile.remove(zip4)

    if OTTURL == 'OTHER':
        Addon.setSetting('dixie.url', 'Other')
        Addon.setSetting('dixie.skin', 'EPG-Skin')
        setSetting('SKIN', 'OTT-Skin')
    else:
        Addon.setSetting('dixie.url', 'All Channels')
        Addon.setSetting('dixie.skin', 'FXB v4.0')
        setSetting('SKIN', 'FXB78')
    
    setSetting('FIRSTRUN', 'true')
def downloadDefaults(url):
    import download
    import extract

    url1 = url + 'ott/skins.zip'
    url2 = url + 'ottepg/skins.zip'
    url3 = url + 'ottepg/logos.zip'
    url4 = url + 'ottepg/channels.zip'
    
    path1 = xbmc.translatePath(PROFILE)     # /addon_data/script.on-tapp.tv/
    path2 = os.path.join(epgpath, 'extras') # /addon_data/script.tvguidedixie/extras/
    path3 = os.path.join(path2,   'skins')
    path4 = os.path.join(path2,   'logos')
    
    zip1  = os.path.join(path1,   'skins.zip')
    zip2  = os.path.join(path2,   'skins.zip')
    zip3  = os.path.join(path2,   'logos.zip')
    zip4  = os.path.join(epgpath, 'channels.zip')

    if not sfile.exists(epgpath):
        sfile.makedirs(epgpath)
    
    if not sfile.exists(path1):
        sfile.makedirs(path1)
    download.download(url1, zip1)
    extract.all(zip1, path1, dp='Installing OTT skins')
    sfile.remove(zip1)
    
    if not sfile.exists(path2):
        sfile.makedirs(path2)
    download.download(url2, zip2)
    extract.all(zip2, path2, dp='Installing EPG skins')
    sfile.remove(zip2)
    
    if not sfile.exists(path4):
        sfile.makedirs(path2)
    download.download(url3, zip3)
    extract.all(zip3, path2)
    sfile.remove(zip3)
    
    if not sfile.exists(epgpath):
        sfile.makedirs(epgpath)
    download.download(url4, zip4)
    extract.all(zip4, epgpath)
    sfile.remove(zip4)

    if isDSF():
        Addon.setSetting('dixie.skin', 'EPG-Skin')
        Addon.setSetting('playlist.url', '')
        setSetting('SKIN', 'OTT-Skin')
    else:
        Addon.setSetting('dixie.skin', 'FXB v4.0')
        setSetting('SKIN', 'FXB78')
    
    setSetting('FIRSTRUN', 'true')
def downloadDefaults(url):
    import download
    import extract

    url1 = url + 'ott/skins.zip'
    url2 = url + 'ottepg/skins.zip'
    url3 = url + 'ottepg/logos.zip'
    # url4 = url + 'ottepg/channels.zip'
    
    path1 = xbmc.translatePath(PROFILE)     # /addon_data/script.on-tapp.tv/
    path2 = os.path.join(epgpath, 'extras') # /addon_data/script.tvguidedixie/extras/
    path3 = os.path.join(path2,   'skins')
    path4 = os.path.join(path2,   'logos')
    
    zip1  = os.path.join(path1,   'skins.zip')
    zip2  = os.path.join(path2,   'skins.zip')
    zip3  = os.path.join(path2,   'logos.zip')
    # zip4  = os.path.join(epgpath, 'channels.zip')

    if not sfile.exists(epgpath):
        sfile.makedirs(epgpath)
    
    if not sfile.exists(path1):
        sfile.makedirs(path1)
    download.download(url1, zip1)
    extract.all(zip1, path1, dp='Installing OTT skins')
    sfile.remove(zip1)
    
    if not sfile.exists(path2):
        sfile.makedirs(path2)
    download.download(url2, zip2)
    extract.all(zip2, path2, dp='Installing EPG skins')
    sfile.remove(zip2)
    
    if not sfile.exists(path4):
        sfile.makedirs(path2)
    download.download(url3, zip3)
    extract.all(zip3, path2)
    sfile.remove(zip3)
    
    # if not sfile.exists(epgpath):
    #     sfile.makedirs(epgpath)
    # download.download(url4, zip4)
    # extract.all(zip4, epgpath)
    # sfile.remove(zip4)

    Addon.setSetting('dixie.skin', 'EPG-Skin')
    Addon.setSetting('playlist.url', '')
    utils.setSetting('SKIN', 'OTT-Skin')
    
    if utils.DialogYesNo('Would you like to assign a button ', 'on your remote control or keybord', 'to activate the On-Tapp.TV Mini-Guide?'):
        xbmc.executebuiltin('RunScript(special://home/addons/script.tvguidedixie/keyProgrammer.py)')
    
    utils.setSetting('FIRSTRUN', 'true')
def downloadDefaults(url):
    DialogOK('Welcome to On-Tapp.TV 3.0',
             'We will now install some needed files.',
             'This may take a few minutes, so please be patient.')

    import download
    import extract

    url1 = url + 'ott/skins.zip'
    url2 = url + 'ottepg/skins.zip'
    url3 = url + 'ottepg/logos.zip'

    path1 = xbmc.translatePath(PROFILE)  # /addon_data/script.on-tapp.tv/
    path2 = os.path.join(epgpath,
                         'extras')  # /addon_data/script.tvguidedixie/extras/
    path3 = os.path.join(path2, 'skins')
    path4 = os.path.join(path2, 'logos')

    zip1 = os.path.join(path1, 'skins.zip')
    zip2 = os.path.join(path2, 'skins.zip')
    zip3 = os.path.join(path2, 'logos.zip')
    zip4 = os.path.join(epgpath, 'channels.zip')

    if not sfile.exists(epgpath):
        sfile.makedirs(epgpath)

    if not sfile.exists(path1):
        sfile.makedirs(path1)
    download.download(url1, zip1)
    extract.all(zip1, path1, dp='Installing OTT skins')
    sfile.remove(zip1)

    if not sfile.exists(path2):
        sfile.makedirs(path2)
    download.download(url2, zip2)
    extract.all(zip2, path2, dp='Installing EPG skins')
    sfile.remove(zip2)

    if not sfile.exists(path4):
        sfile.makedirs(path2)
    download.download(url3, zip3)
    extract.all(zip3, path2)
    sfile.remove(zip3)

    Addon.setSetting('dixie.skin', 'FXB v4.0')
    setSetting('SKIN', 'FXB78')

    installSFPlugin()

    # if DialogYesNo('Would you like to assign a button ', 'on your remote control or keybord', 'to activate the On-Tapp.TV Mini-Guide?'):
    #     xbmc.executebuiltin('RunScript(special://home/addons/script.tvguidedixie/keyProgrammer.py), True')

    setSetting('FIRSTRUN', 'true')
def resetChannels():
    AddonID =  'script.trtv'
    dialog  = xbmcgui.Dialog()
    path    = dixie.GetChannelFolder()
    chan    = os.path.join(path, 'channels')
    chanchk = xbmc.translatePath(os.path.join('special://profile/addon_data/',AddonID,'chan.xml'))
    catsxml = xbmc.translatePath(os.path.join('special://profile/addon_data/',AddonID,'cats.xml'))
    success = 0

    try:
        os.remove(chanchk)
    except:
        dixie.log("### IMPORTANT ### Failed to remove the chanchk file in addon_data, please manually remove if it's still there")

    if sfile.exists(chan):
        xbmc.executebuiltin('Dialog.Show(busydialog)')
        sfile.rmtree(chan)
        xbmc.executebuiltin('Dialog.Close(busydialog)')
        success = 1

    if success == 1:
        dialog.ok('TRTV - Reset Channels', 'TRTV Channels successfully reset.', 'They will be re-created next time', 'you start the guide')

    if success == 0:
        dialog.ok('TRTV - Reset Channels', 'There was nothing to reset, please try running the add-on again so it can repopulate your channels.')

    if os.path.exists(catsxml):
        choice = dialog.yesno('Do You Need To Reset Categories?','It\'s highly unlikely you\'ll need to use this but if your main categories list has become corrupt it can cause problems. Would you like to reset the categories to the defaults?')
        if choice == 1:
            try:
                os.remove(catsxml)
                dialog.ok('TRTV - Reset Categories', 'TRTV Categories successfully reset to addon defaults. Any customisations you previously had are now lost.')
            except:
                dialog.ok('TRTV - Reset Categories', 'There was nothing to reset, please try running the add-on again so it can repopulate your categories.')
                dixie.log("### IMPORTANT ### Unable to remove the cats.xml file in your addon_data folder. Please manually delete")
Example #12
0
def checkLatest(current, latest):
    if current == latest:
        return CURRENT

    if not utils.DialogYesNo(utils.GETTEXT(30115), utils.GETTEXT(30116)):
        return DECLINED

    filename = 'addon-%s.zip' % latest

    url   = s3.getFile(ROOT, filename)
    dest  = os.path.join(PROFILE, filename)
    title = utils.GETTEXT(30117)
    dp    = utils.DialogProgress(utils.GETTEXT(30079) % title, utils.GETTEXT(30080))

    import download
    download.doDownload(url, dest, title=title, referrer='', dp=dp, silent=False)

    if not sfile.exists(dest):
        return FAILED

    extracted = extract(dest, dp)

    try:    sfile.delete(dest)
    except: pass

    if not extracted:
        return FAILED

    import xbmcgui
    xbmcgui.Window(10000).setProperty('LB_RELAUNCH', 'true')

    cmd = 'UpdateLocalAddons'
    xbmc.executebuiltin(cmd)

    return UPDATED
Example #13
0
def VerifyKeymapHot():
    if ADDON.getSetting('HOTKEY') == GETTEXT(30111):  #i.e. programmable
        return False

    dest = os.path.join('special://profile/keymaps', KEYMAP_HOT)

    if sfile.exists(dest):
        return False

    key = ADDON.getSetting('HOTKEY')

    valid = []
    for i in range(30028, 30040):
        valid.append(GETTEXT(i))
    valid.append(GETTEXT(30058))

    includeKey = key in valid

    if not includeKey:
        DeleteKeymap(KEYMAP_HOT)
        return True

    if isATV():
        DialogOK(GETTEXT(30118), GETTEXT(30119))
        return False

    return WriteKeymap(key.lower(), key.lower())
def getCategoryList(path):
    import StringIO
    from xml.etree import ElementTree

    xml = None
    cat = dict()
    try:
        if sfile.exists(path):
            xml = sfile.read(path)
    except:
        pass

    if not xml:
        return {}

    xml = StringIO.StringIO(xml)
    xml = ElementTree.iterparse(xml, events=("start", "end"))

    for event, elem in xml:
        try:
            if event == 'end':
                if elem.tag == 'cats':
                    channel = elem.findtext('channel')
                    category = elem.findtext('category')
                    if channel != '' and category != '':
                        cat[channel] = category
        except:
            pass

    return cat
Example #15
0
def updateAdvancedSettings(input):
    try:
        filename = 'advancedsettings.xml'
        source   = os.path.join('special://userdata', filename)

        if sfile.exists(source):
            contents = sfile.read(source)
            if input in contents:
                Log('%s already in %s' % (input, filename))
                return True

            Log('Updating %s with %s' % (filename, input))
            start = input.replace('>', ' >').split(' ', 1)[0].strip()
            end   = '</' + input.rsplit('</', 1)[-1].strip()

            start = contents.split(start, 1)[0]
            end   = contents.split(end, 1)[-1]

            contents = start
            if start != end:
                contents += end

            contents = contents.replace('</advancedsettings>', '%s</advancedsettings>' % input)
        else:
            Log('Creating %s with %s' % (filename, input))
            contents = '<advancedsettings>%s</advancedsettings>' % input
    except:
        Log('Error updating %s with %s' % (filename, input))
        Log('Resetting %s with %s' % (filename, input))
        contents = '<advancedsettings>%s</advancedsettings>' % input

    sfile.write(source, contents)
    
    return False
Example #16
0
    def createChannel(self, channel):
        path = os.path.join(channelPath, channel.id)

        if sfile.exists(path):
            return

        self.addChannel(channel)
Example #17
0
    def createChannel(self, channel):
        path = os.path.join(channelPath, channel.id)

        if sfile.exists(path):
            return

        self.addChannel(channel)
Example #18
0
def isPlayable(path, ignore, maxAge=-1):
    if not sfile.exists(path):
        return False

    if sfile.isfile(path):
        playable = isFilePlayable(path, maxAge)
        return playable

    try:
        if sfile.getfilename(path)[0] in ignore:
            return False
    except:
        pass
         
    current, dirs, files = sfile.walk(path)

    for file in files:
        if isPlayable(os.path.join(current, file), ignore, maxAge):
            return True

    for dir in dirs:
        try: 
            if isPlayable(os.path.join(current, dir), ignore, maxAge):
                return True
        except:
            pass

    return False
Example #19
0
    def getCategories(self):        
        cat  = dict()
        path = os.path.join(datapath, 'cats.xml')
        dixie.log("Checking for category XML path at: "+path)
        try:
            if sfile.exists(path):
                xml = sfile.read(path)
        except:
            dixie.log("### cats.xml does not exist")
#        xml = xml.replace('&', '&amp;')
        xml = StringIO.StringIO(xml)
        xml = ElementTree.iterparse(xml, events=("start", "end"))

        for event, elem in xml:
            try:
                if event == 'end':
                    if elem.tag == 'cats':
                        channel  = elem.findtext('channel')
                        category = elem.findtext('category')
                        if channel != '' and category != '':
                            cat[channel] = category
            except:
                pass

        return cat
Example #20
0
def checkForExternalDrive():
    extDrive = getExternalDrive()
    if sfile.exists(extDrive):
        return True

    DialogOK(GETTEXT(30087), GETTEXT(30088))
    return False
Example #21
0
    def getCategories(self):
        cat = dict()
        path = os.path.join(datapath, 'cats.xml')
        try:
            if sfile.exists(path):
                xml = sfile.read(path)
        except:
            pass

        xml = xml.replace('&', '&amp;')
        xml = StringIO.StringIO(xml)
        xml = ElementTree.iterparse(xml, events=("start", "end"))

        for event, elem in xml:
            try:
                if event == 'end':
                    if elem.tag == 'cats':
                        channel = elem.findtext('channel')
                        category = elem.findtext('category')
                        if channel != '' and category != '':
                            cat[channel] = category
            except:
                pass

        return cat
Example #22
0
 def removeCleanChannel(self, id):
     path = os.path.join(OTT_CHANNELS, id)
     if sfile.exists(path):
         try:
             sfile.remove(path)
         except:
             pass
Example #23
0
def MigrateChannels(dst):
    dst = os.path.join(dst, 'channels')
    src = os.path.join(datapath, 'channels')

    if not sfile.exists(dst):
        try:    sfile.copytree(src, dst)
        except: pass
    def getDataFromExternal(self, date, progress_callback=None):
        categoryPath = os.path.join(datapath, 'cats.xml')
        channels = os.path.join(datapath, 'chan.xml')

        categories = dixie.getCategoryList(categoryPath)

        xml = None

        try:
            if sfile.exists(channels):
                xml = sfile.read(channels)
        except:
            dixie.log('Error reading chan.xml')

        if not xml:
            return []

        if not self.xml:
            self.xml = xml

        io = StringIO.StringIO(self.xml)

        context = ElementTree.iterparse(io, events=("start", "end"))
        return parseXMLTV(context, io, len(self.xml), progress_callback,
                          self.offset, categories)
Example #25
0
 def removeCleanChannel(self, id):
     path = os.path.join(OTT_CHANNELS, id)
     if sfile.exists(path):
         try:
             sfile.remove(path)
         except:
             pass
Example #26
0
def VerifyKeymapHot():
    if ADDON.getSetting('HOTKEY') == GETTEXT(30111): #i.e. programmable
        return False    

    dest = os.path.join('special://profile/keymaps', KEYMAP_HOT)

    if sfile.exists(dest):
        return False

    key = ADDON.getSetting('HOTKEY')

    valid = []
    for i in range(30028, 30040):
        valid.append(GETTEXT(i))
    valid.append(GETTEXT(30058))

    includeKey = key in valid

    if not includeKey:
        DeleteKeymap(KEYMAP_HOT)
        return True

    if isATV():
        DialogOK(GETTEXT(30118), GETTEXT(30119))
        return False

    return WriteKeymap(key.lower(), key.lower())
Example #27
0
def resetChannels():
    AddonID = 'script.trtv'
    dialog = xbmcgui.Dialog()
    path = dixie.GetChannelFolder()
    chan = os.path.join(path, 'channels')
    chanchk = xbmc.translatePath(
        os.path.join('special://profile/addon_data/', AddonID, 'chan.xml'))
    catsxml = xbmc.translatePath(
        os.path.join('special://profile/addon_data/', AddonID, 'cats.xml'))
    success = 0

    try:
        os.remove(chanchk)
    except:
        dixie.log(
            "### IMPORTANT ### Failed to remove the chanchk file in addon_data, please manually remove if it's still there"
        )

    if sfile.exists(chan):
        xbmc.executebuiltin('Dialog.Show(busydialog)')
        sfile.rmtree(chan)
        xbmc.executebuiltin('Dialog.Close(busydialog)')
        success = 1

    if success == 1 and showdialogs:
        dialog.ok('TRTV - Reset Channels', 'TRTV Channels successfully reset.',
                  'They will be re-created next time', 'you start the guide')

    if success == 0 and showdialogs:
        dialog.ok(
            'TRTV - Reset Channels',
            'There was nothing to reset, please try running the add-on again so it can repopulate your channels.'
        )

    if os.path.exists(catsxml):
        if showdialogs:
            choice = dialog.yesno(
                'Do You Need To Reset Categories?',
                'It\'s highly unlikely you\'ll need to use this but if your main categories list has become corrupt it can cause problems. Would you like to reset the categories to the defaults?'
            )
        else:
            choice = 1
        if choice == 1:
            try:
                os.remove(catsxml)
                if showdialogs:
                    dialog.ok(
                        'TRTV - Reset Categories',
                        'TRTV Categories successfully reset to addon defaults. Any customisations you previously had are now lost.'
                    )
            except:
                if showdialogs:
                    dialog.ok(
                        'TRTV - Reset Categories',
                        'There was nothing to reset, please try running the add-on again so it can repopulate your categories.'
                    )
                dixie.log(
                    "### IMPORTANT ### Unable to remove the cats.xml file in your addon_data folder. Please manually delete"
                )
Example #28
0
def verifyPlugins():
    folder = os.path.join(ROOT, 'Plugins')

    if sfile.exists(folder):
        return

    try:    sfile.makedirs(folder)
    except: pass
    def createChannel(self, channel):
        path = os.path.join(channelPath, CleanFilename(channel.id))

        if sfile.exists(path):
            # TODO self.updateChannel(channel)
            return

        self.addChannel(channel)
Example #30
0
    def addCleanChannel(self, channel, id):
        path = os.path.join(channelPath, id)

        if id not in self.channelDict:
            self.channelDict[id] = channel.clone()

        if not sfile.exists(path):
            channel.writeToFile(path)
Example #31
0
def extract(src, dp):
    success = False
    try:
        src = xbmc.translatePath(src)
        import zipfile

        update = os.path.join(PROFILE, 'update')
        update = xbmc.translatePath(update)
        sfile.makedirs(update)

        zin   = zipfile.ZipFile(src, 'r')
        nItem = float(len(zin.infolist()))

        index = 0
        for item in zin.infolist():
            index += 1

            percent  = int(index / nItem *100)
            #filename = item.filename

            zin.extract(item, update)
  
            if dp:
                dp.update(percent, utils.GETTEXT(30118), utils.GETTEXT(30080))

        addons = os.path.join('special://home', 'addons')
        current, folders, files = sfile.walk(update)

        for folder in folders:
            ori = os.path.join(addons, folder)
            src = os.path.join(current, folder)
            dst = os.path.join(addons, folder + '.temp')
            sfile.copytree(src, dst)
            sfile.rmtree(ori)
            while not sfile.exists(dst):
                xbmc.sleep(100)
            while sfile.exists(ori):
                xbmc.sleep(100)
            sfile.rename(dst, ori)   

        success = True
    except:
        success = False

    sfile.delete(update)
    return success
Example #32
0
def deleteFile(path, name):
    if not utils.DialogYesNo(GETTEXT(30044) % name, GETTEXT(30045)):
        return

    import sfile
    sfile.delete(path)
    if sfile.exists(path):
        utils.DialogOK(GETTEXT(30046) % name)
Example #33
0
    def removeCleanChannel(self, id):
        try:    del self.channelDict[id]
        except: pass

        path = os.path.join(channelPath, id)
        if sfile.exists(path):
            try:    sfile.remove(path)
            except: pass            
Example #34
0
def verifyPlugins():
    folder = os.path.join(ROOT, 'Plugins')

    if sfile.exists(folder):
        return

    try:    sfile.makedirs(folder)
    except: pass
Example #35
0
def DeleteFile(path):
    tries = 5
    while sfile.exists(path) and tries > 0:
        tries -= 1 
        try: 
            sfile.remove(path) 
        except: 
            xbmc.sleep(500)
Example #36
0
def DeleteFile(path):
    tries = 5
    while sfile.exists(path) and tries > 0:
        tries -= 1
        try:
            sfile.remove(path)
        except:
            xbmc.sleep(500)
Example #37
0
    def addCleanChannel(self, channel, id):
        path = os.path.join(channelPath, id) 

        if id not in self.channelDict:           
            self.channelDict[id] = channel.clone()

        if not sfile.exists(path): 
            channel.writeToFile(path)
Example #38
0
    def removeCleanChannel(self, id):
        try:    del self.channelDict[id]
        except: pass

        path = os.path.join(channelPath, id)
        if sfile.exists(path):
            try:    sfile.remove(path)
            except: pass            
Example #39
0
    def getChannelFromFile(self, id):
        path = os.path.join(OTT_CHANNELS, id)

        if not sfile.exists(path):
            return None

        cfg = sfile.readlines(path)

        return Channel(cfg)
    def getChannelFromFile(self, id):
        path = os.path.join(OTT_CHANNELS, id)

        if not sfile.exists(path):
            return None

        cfg = sfile.readlines(path)

        return Channel(cfg)
def MigrateChannels(dst):
    dst = os.path.join(dst, 'channels')
    src = os.path.join(datapath, 'channels')

    if not sfile.exists(dst):
        try:
            sfile.copytree(src, dst)
        except:
            pass
Example #42
0
def getFavourites(file, limit=10000, validate=True, superSearch=False):
    import xbmcgui

    xml  = '<favourites></favourites>'
    if sfile.exists(file):
        xml = sfile.read(file)

    items = []

    faves = re.compile('<favourite(.+?)</favourite>').findall(xml)

    for fave in faves:
        fave = fave.replace('&quot;', '&_quot_;')
        fave = fave.replace('\'', '"')
        fave = utils.unescape(fave)

        fave = fave.replace('name=""', '')
        try:    name = re.compile('name="(.+?)"').findall(fave)[0]
        except: name = ''

        try:    thumb = re.compile('thumb="(.+?)"').findall(fave)[0]
        except: thumb = ''

        try:    cmd   = fave.split('>', 1)[-1]
        except: cmd = ''

        #name  = utils.Clean(name.replace( '&_quot_;', '"'))
        name  = name.replace( '&_quot_;', '"')
        thumb = thumb.replace('&_quot_;', '"')
        cmd   = cmd.replace(  '&_quot_;', '"')

        add = False

        if superSearch:
            add = isValid(cmd)
        elif (SHOWUNAVAIL) or (not validate) or isValid(cmd):
            add = True

        if add:
            cmd = upgradeCmd(cmd)

            if cmd.startswith('PlayMedia'):
                option = 'mode'
                try:                        
                    mode = int(favourite.getOption(cmd, option))
                except:
                    win  = xbmcgui.getCurrentWindowId()
                    cmd  = updateSFOption(cmd, 'winID', win)

            cmd = patch(cmd)

            items.append([name, thumb, cmd])
            if len(items) > limit:
                return items

    return items
Example #43
0
    def SetSeriesImage(self, name, image):
        targetFile = self.GetSeriesImage(name)
        if not sfile.exists(targetFile):
	    import urllib2
            req = urllib2.Request(image)
            req.add_header('User-Agent', utils.getUserAgent())
            response = urllib2.urlopen(req)
            sfile.write(targetFile, response.read())
            response.close()
        return targetFile
def getChannelFromFile(id, folder):
    from channel import Channel
    path = os.path.join(folder, id)

    if not sfile.exists(path):
        return None

    cfg = sfile.readlines(path)

    return Channel(cfg)
Example #45
0
 def SetSeriesImage(self, name, image):
     targetFile = self.GetSeriesImage(name)
     if not sfile.exists(targetFile):
         import urllib2
         req = urllib2.Request(image)
         req.add_header('User-Agent', utils.getUserAgent())
         response = urllib2.urlopen(req)
         sfile.write(targetFile, response.read())
         response.close()
     return targetFile
Example #46
0
def CheckPlugin():
    filename  = 'OTTV Mini-Guide.py'

    sfaves = xbmcaddon.Addon('plugin.program.super.favourites')
    path   = sfaves.getAddonInfo('profile')
    file   = os.path.join(path, 'Plugins', filename)
    
    if not sfile.exists(file):
        if dixie.DialogYesNo('Would you like to install the ', 'On-Tapp.TV Mini-Guide?', 'Access our listings anywhere in Kodi!'):
            xbmc.executebuiltin('XBMC.RunScript(special://home/addons/script.tvguidedixie/install.py)')
        else: pass
Example #47
0
def getChannelFromFile(id):
    path = os.path.join(TVP_CHANNELS, id)

    if not sfile.exists(path):
        return None

#    f = open(path, mode='r')
    cfg = sfile.readlines(path)
#    f.close

    return Channel(cfg)
Example #48
0
def GetTitleAndImage(path):
    root  = removeExtension(path)
    title = root.rsplit(os.sep, 1)[-1]
    title = title.rsplit(DELIMETER, 1)[-1]

    for ext in IMG_EXT:            
        image = root + ext
        if sfile.exists(image):               
            return title.replace('_', ' '), image

    return title.replace('_', ' '), ICON
Example #49
0
def getChannelFromFile(id):
    path = os.path.join(OTT_CHANNELS, id)

    if not sfile.exists(path):
        return None

    # f = open(path, mode='r')
    cfg = sfile.readlines(path)
    # f.close

    return Channel(cfg)
Example #50
0
def removeKepmap():
    try:
        file = 'zOTT_Keymap.xml'
        dst  = os.path.join('special://profile/keymaps', file)

        if sfile.exists(dst):
            sfile.remove(dst)
            xbmc.sleep(1000)

        xbmc.executebuiltin('Action(reloadkeymaps)')
    except Exception, e:
        pass
Example #51
0
def CheckForChannels():
    dir    = dixie.GetChannelFolder()
    folder = os.path.join(dir, 'channels')
    files  = []
    try:    current, dirs, files = sfile.walk(folder)
    except: pass
    if len(files) == 0:
        dixie.SetSetting('updated.channels', -1) # force refresh of channels
    
    backup = os.path.join(dir, 'channels-backup')
    if not sfile.exists(backup):
        dixie.BackupChannels()
def removeKepmap():
    try:
        file = 'zOTT_Keymap.xml'
        dst = os.path.join('special://profile/keymaps', file)

        if sfile.exists(dst):
            sfile.remove(dst)
            xbmc.sleep(1000)

        xbmc.executebuiltin('Action(reloadkeymaps)')
    except Exception, e:
        pass
Example #53
0
    def getChannelFromFile(self, id):
        path = os.path.join(channelPath, id)
        if not sfile.exists(path):
            return None

        cfg = sfile.readlines(path)
        
        return Channel(cfg)

        ch = Channel(cfg[0], cfg[1], cfg[2], cfg[3], cfg[4], cfg[5], cfg[6])

        return ch
Example #54
0
    def getChannelFromFile(self, id):
        path = os.path.join(channelPath, id)
        if not sfile.exists(path):
            return None

        cfg = sfile.readlines(path)
        
        return Channel(cfg)

        ch = Channel(cfg[0], cfg[1], cfg[2], cfg[3], cfg[4], cfg[5], cfg[6])

        return ch
Example #55
0
def doZipfile(outputFile, includeSettings=True):
    zip = None

    source  = os.path.join(HOME, 'SF_Temp')

    if sfile.exists(source):
        sfile.rmtree(source)

    sfile.copytree(ROOT, source)

    relroot = os.path.abspath(os.path.join(source, os.pardir))

    ignore = ['c', 'downloads']

    for root, dirs, files in os.walk(source):

        if zip == None:
            zip = zipfile.ZipFile(outputFile, 'w', zipfile.ZIP_DEFLATED)

        local = os.path.relpath(root, relroot).split(os.sep, 1)
        if len(local) < 2:
            continue
        local = local[-1]

        # add directory (this is needed for empty dirs)
        if local.lower() in ignore:
            continue
        zip.write(root, local)

        for file in files:    
            if file == 'settings.xml':
                continue

            #ignore python obj
            if len(file.split('.py')[-1]) == 1:
                continue

            arcname  = os.path.join(local, file)
            filename = os.path.join(root, file)           
            zip.write(filename, arcname)

    if includeSettings:
        if zip == None:
            zip = zipfile.ZipFile(output_filename, 'w', zipfile.ZIP_DEFLATED)

        arcname  = 'settings.xml'
        filename = os.path.join(ADDON.getAddonInfo('profile'), arcname)
        filename = xbmc.translatePath(filename) #has to be a real path

        zip.write(filename, arcname)

    sfile.rmtree(source)
Example #56
0
def play(cmd):
    import sfile
    if cmd.lower().startswith('activatewindow'):
        playlist = cmd.split(',', 1)
        playlist = playlist[-1][:-1]
        cmd = 'PlayMedia(%s)' % playlist

    elif sfile.exists(cmd):
        #cmd = 'PlayMedia(%s)' % cmd
        playFile(cmd)
        return

    xbmc.executebuiltin(cmd)
def loadKepmap():
    try:
        file = 'zOTT_Keymap.xml'
        src = os.path.join(HOME, 'resources', file)
        dst = os.path.join('special://profile/keymaps', file)

        if not sfile.exists(dst):
            sfile.copy(src, dst)
            xbmc.sleep(1000)

        xbmc.executebuiltin('Action(reloadkeymaps)')
    except Exception, e:
        pass
Example #58
0
    def cloneFilename(self, filename):
        if '_clone_' in filename:
            return filename, ''

        index = 1
        root = filename
        filename = root + '_clone_%d' % index

        while sfile.exists(filename):
            index += 1
            filename = root + '_clone_%d' % index

        return filename, '_clone_%d' % index
Example #59
0
def CheckForChannels():
    dir = dixie.GetChannelFolder()
    folder = os.path.join(dir, 'channels')
    files = []
    try:
        current, dirs, files = sfile.walk(folder)
    except:
        pass
    if len(files) == 0:
        dixie.SetSetting('updated.channels', -1)  # force refresh of channels

    backup = os.path.join(dir, 'channels-backup')
    if not sfile.exists(backup):
        dixie.BackupChannels()