def getLineups(label, url, isSF, sfZip):
    path = OTT_PROFILE
    zipfile = os.path.join(path, 'lineups.zip')
    chandir = os.path.join(path, 'channels')

    line1 = 'Would you like to [COLOR orange]INSTALL[/COLOR] ' + label + ' line-up'
    line2 = 'or [COLOR orange]MERGE[/COLOR] it with your existing line-up?'
    line3 = ''
    nolabel = 'MERGE'
    yeslabel = 'INSTALL'

    if utils.DialogYesNo(line1, line2, line3, nolabel, yeslabel):
        if isSF == 'true':
            utils.DialogOK(
                label + ' requires some links added to your Super Favourites',
                'We will install these first and then install your line-up',
                'Thank you.')
            utils.installSF(sfZip)

        if os.path.isdir(chandir):
            sfile.rmtree(chandir)

        utils.deleteCFG()
        utils.download(url, path, zipfile)
        OTT_ADDON.setSetting('dixie.lineup', label)
        utils.DialogOK(label + ' line-up has been installed successfully.',
                       'It is now set as your active channel line-up.',
                       'Please restart On-Tapp.TV. Thank you.')

    else:
        tools.mergeLineups(label, isSF, sfZip, url)
def mergeLineups(label, isSF, sfZip, url):
    if not utils.DialogYesNo(
            'Are you sure you want to continue and merge channels?',
            'We highly recommend you back-up your channel line-up first',
            'THERE IS NO UNDO!'):
        return

    path = os.path.join(OTT_PROFILE, 'chanstomerge')
    zipfile = os.path.join(OTT_PROFILE, 'tomerge.zip')

    if isSF == 'true':
        utils.installSF(sfZip)

    utils.download(url, path, zipfile)

    toMerge = os.path.join(OTT_PROFILE, 'chanstomerge', 'channels')
    channels = getAllChannels(toMerge)

    merge = []
    for channel in channels:
        chTag = ''
        chTitle = channel[2].title
        chStream = channel[2].streamUrl

        merge.append([chTag, chTitle, chStream])

    OTT_ADDON.setSetting('dixie.lineup', label)

    return _mergeLineups(merge)
def makeAlphabetical():
    if utils.DialogYesNo(
            'Changing to alphabetical channel order CANNOT be undone.',
            'Do a back-up first to be safe.',
            'Are you sure you want to do this?'):
        channels = []

        try:
            current, dirs, files = sfile.walk(OTT_CHANNELS)
        except Exception, e:
            return channels

        for file in files:
            channels.append(file)

        sorted = []

        for id in channels:
            channel = getChannelFromFile(id)

            sorter = channel.title.lower()

            sorted.append([sorter, id, channel])

        sorted.sort()
        writeChannelsToFile(sorted)
        return
def getLogos(label, url):
    path = os.path.join(EXTRAS, 'logos')
    zipfile = os.path.join(path, 'logos.zip')

    if utils.DialogYesNo(
            'Would you like to install ' + label,
            'and make it your active logo-pack?',
            'It will be downloaded and installed into your system.'):
        utils.download(url, path, zipfile)
        utils.DialogOK(label + ' logo-pack has been installed successfully.',
                       'It is now set as your active logo-pack.',
                       'Please restart On-Tapp.TV. Thank you.')
        OTT_ADDON.setSetting('dixie.logo.folder', label)
def removeChannel(id):
    channel = getChannelFromFile(id)

    if not channel:
        return False

    if channel.userDef != 1 and channel.isClone != 1:
        return False

    if not utils.DialogYesNo(
            'Remove %s' % channel.title, noLabel='Cancel', yesLabel='Confirm'):
        return False

    path = os.path.join(OTT_CHANNELS, id)
    utils.deleteFile(path)

    return True
def fullBackup():
    if not utils.DialogYesNo(
            'Would you like to do a full back-up of On-Tapp.TV?', ''):
        return
    cmd = 'XBMC.RunScript(special://home/addons/script.tvguidedixie/backup.py, full)'
    xbmc.executebuiltin(cmd)
def backupChannels():
    if not utils.DialogYesNo(
            'Would you like to do a back-up of your channel line-up?', ''):
        return
    cmd = 'XBMC.RunScript(special://home/addons/script.tvguidedixie/backup.py, channel)'
    xbmc.executebuiltin(cmd)