Ejemplo n.º 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.MakeFavouritesGuide(fullGuideFile)
    xbmc.executebuiltin(
        'Notification({0}, Channels removed trom favourites, {1}, {2})'.format(
            AddonName, 5000, __icon__))
Ejemplo n.º 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)

        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__))

    common.WriteList(FAV, favsList)
    common.MakeFavouritesGuide(fullGuideFile)
Ejemplo n.º 3
0
def AddCategoryToFavorites(categoryID):
    allCatList = common.ReadList(categoriesFile)
    category = [
        u"[COLOR {0}][B][{1}][/B][/COLOR]".format(Addon.getSetting("catColor"),
                                                  item["name"])
        for item in allCatList if item['id'] == categoryID
    ]
    channels = common.GetChannels(categoryID)
    if not common.YesNoDialog(localizedString(30210).encode('utf-8'),
                              localizedString(30221).encode('utf-8'),
                              localizedString(30222).encode('utf-8').format(
                                  category[0].encode('utf-8'), len(channels)),
                              localizedString(30223).encode('utf-8'),
                              nolabel=localizedString(30002).encode('utf-8'),
                              yeslabel=localizedString(30001).encode('utf-8')):
        return
    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.MakeFavouritesGuide(fullGuideFile)
    xbmc.executebuiltin(
        'Notification({0}, Channels added to favourites, {1}, {2})'.format(
            AddonName, 5000, __icon__))
Ejemplo n.º 4
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)
    if not common.YesNoDialog(
            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')):
        return
    common.WriteList(FAV, favsList)
    common.MakeFavouritesGuide(fullGuideFile)
    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()
Ejemplo n.º 5
0
def EmptyFavorties():
	if not common.YesNoDialog(localizedString(30213).encode('utf-8'), localizedString(30220).encode('utf-8'), "", "", nolabel=localizedString(30002).encode('utf-8'), yeslabel=localizedString(30001).encode('utf-8')):
		return
	xbmc.executebuiltin('Notification({0}, Start removing channels from favourites, {1}, {2})'.format(AddonName, 5000, icon))
	common.WriteList(FAV, [])
	common.MakeFavouritesGuide(fullGuideFile)
	xbmc.executebuiltin('Notification({0}, Channels removed trom favourites, {1}, {2})'.format(AddonName, 5000, __icon__))
Ejemplo n.º 6
0
def AddFavoritesFromCategory(categoryID):
	channels = common.GetChannels(categoryID)
	channels = [channel for channel in channels if channel["type"] == "video" or channel["type"] == "audio"]
	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(selectedList, showNotification=False)
	common.MakeFavouritesGuide(fullGuideFile)
	xbmc.executebuiltin('Notification({0}, Channels added to favourites, {1}, {2})'.format(AddonName, 5000, __icon__))
Ejemplo n.º 7
0
def addFavorites(channels, showNotification=True):
	favsList = common.ReadList(FAV)
	
	for channel in channels:
		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)
		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__))
	common.WriteList(FAV, favsList)
	common.MakeFavouritesGuide(fullGuideFile)
Ejemplo n.º 8
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.MakeFavouritesGuide(fullGuideFile)