예제 #1
0
def RemoveSelectedFavorties():
    allCategories = common.ReadList(categoriesFile)
    channels = common.ReadList(FAV)
    channelsNames = []
    for channel in channels:
        gp = [
            x["name"] for x in allCategories
            if x["id"] == channel.get("group", "")
        ]
        groupName = gp[0] if len(gp) > 0 else 'Favourites'
        channelsNames.append(
            u"[COLOR {0}][B]{1}[/B][/COLOR] [COLOR {2}][B][{3}][/B][/COLOR]".
            format(Addon.getSetting("chColor"), channel["name"],
                   Addon.getSetting("catColor"), groupName))
    selected = common.GetMultiChoiceSelected(
        localizedString(30209).encode('utf-8'), channelsNames)
    if len(selected) < 1:
        return
    xbmc.executebuiltin(
        'Notification({0}, Start removing channels from favourites, {1}, {2})'.
        format(AddonName, 5000, icon))
    removeFavorties(selected)
    common.MakeCatGuide(fullGuideFile, "Favourites")
    xbmc.executebuiltin(
        'Notification({0}, Channels removed trom favourites, {1}, {2})'.format(
            AddonName, 5000, __icon__))
예제 #2
0
def addFavorites(channelsIDs, categoryID, showNotification=True):
    channels = common.GetChannels(categoryID)
    favsList = common.ReadList(FAV)

    for channelID in channelsIDs:
        channel = [x for x in channels if x["id"] == channelID]
        if len(channel) < 1:
            if showNotification:
                xbmc.executebuiltin(
                    'Notification({0}, [COLOR {1}][B]{2}[/B][/COLOR]  Cannot add to favourites, {3}, {4})'
                    .format(AddonName, Addon.getSetting("chColor"),
                            channel["name"].encode("utf-8"), 5000, __icon2__))
            continue
        channel = channel[0]

        if any(f.get('id', '') == channel["id"] for f in favsList):
            if showNotification:
                xbmc.executebuiltin(
                    'Notification({0}, [COLOR {1}][B]{2}[/B][/COLOR]  Already in favourites, {3}, {4})'
                    .format(AddonName, Addon.getSetting("chColor"),
                            channel["name"].encode("utf-8"), 5000, __icon2__))
            continue

        favsList.append(channel)

    common.WriteList(FAV, favsList)
    common.MakeCatGuide(fullGuideFile, "Favourites")

    if showNotification:
        xbmc.executebuiltin(
            'Notification({0}, [COLOR {1}][B]{2}[/B][/COLOR]  added to favourites, {3}, {4})'
            .format(AddonName, Addon.getSetting("chColor"),
                    channel["name"].encode("utf-8"), 5000, __icon__))
예제 #3
0
def ImportFavourites():
    selectedDir = Addon.getSetting("imExFolder")
    if selectedDir is None or selectedDir == "":
        return
    files = [f for f in os.listdir(selectedDir) if f.endswith(".txt")]
    fileInd = common.GetMenuSelected(
        localizedString(30025).encode('utf-8'), files)
    if fileInd == -1:
        return
    fullPath = os.path.join(selectedDir.decode("utf-8"), files[fileInd])
    favsList = common.ReadList(fullPath)
    dialog = xbmcgui.Dialog()
    ok = dialog.yesno(localizedString(30215).encode('utf-8'),
                      localizedString(30216).encode('utf-8'),
                      line2=localizedString(30217).encode('utf-8').format(
                          len(favsList)),
                      line3=localizedString(30218).encode('utf-8'),
                      nolabel=localizedString(30002).encode('utf-8'),
                      yeslabel=localizedString(30001).encode('utf-8'))
    if not ok:
        return
    common.WriteList(FAV, favsList)
    common.MakeCatGuide(fullGuideFile, "Favourites")
    xbmc.executebuiltin(
        'Notification({0}, Favourites list is saved., {2}, {3})'.format(
            AddonName, fullPath, 5000, __icon__))

    iptvList = int(Addon.getSetting("iptvList"))
    if useIPTV and iptvList == 0:
        MakeIPTVlists()
        DownloadLogos()
예제 #4
0
def EmptyFavorties():
    xbmc.executebuiltin(
        'Notification({0}, Start removing channels from favourites, {1}, {2})'.
        format(AddonName, 5000, icon))
    common.WriteList(FAV, [])
    common.MakeCatGuide(fullGuideFile, "Favourites")
    xbmc.executebuiltin(
        'Notification({0}, Channels removed trom favourites, {1}, {2})'.format(
            AddonName, 5000, __icon__))
예제 #5
0
def AddCategoryToFavorites(categoryID):
    channels = common.GetChannels(categoryID)
    xbmc.executebuiltin(
        'Notification({0}, Start adding channels to favourites, {1}, {2})'.
        format(AddonName, 5000, icon))
    addFavorites([channel["id"] for channel in channels],
                 categoryID,
                 showNotification=False)
    common.MakeCatGuide(fullGuideFile, "Favourites")
    xbmc.executebuiltin(
        'Notification({0}, Channels added to favourites, {1}, {2})'.format(
            AddonName, 5000, __icon__))
예제 #6
0
def AddFavoritesFromCategory(categoryID):
    channels = common.GetChannels(categoryID)
    channelsNames = [
        u"[COLOR {0}][B]{1}[/B][/COLOR]".format(Addon.getSetting("chColor"),
                                                channel["name"])
        for channel in channels
    ]
    selected = common.GetMultiChoiceSelected(
        localizedString(30208).encode('utf-8'), channelsNames)
    if len(selected) < 1:
        return
    selectedList = [channels[index] for index in selected]
    xbmc.executebuiltin(
        'Notification({0}, Start adding channels to favourites, {1}, {2})'.
        format(AddonName, 5000, icon))
    addFavorites([channel["id"] for channel in selectedList],
                 categoryID,
                 showNotification=False)
    common.MakeCatGuide(fullGuideFile, "Favourites")
    xbmc.executebuiltin(
        'Notification({0}, Channels added to favourites, {1}, {2})'.format(
            AddonName, 5000, __icon__))
예제 #7
0
def removeFavorties(indexes):
    favsList = common.ReadList(FAV)
    for ind in range(len(indexes) - 1, -1, -1):
        favsList.remove(favsList[indexes[ind]])
    common.WriteList(FAV, favsList)
    common.MakeCatGuide(fullGuideFile, "Favourites")