Exemplo n.º 1
0
def removeFavorties(url):
    dirs = common.ReadList(FAV)
    for item in dirs:
        if item["url"].lower() == url.lower():
            dirs.remove(item)
            common.WriteList(FAV, dirs)
            xbmc.executebuiltin("XBMC.Container.Refresh()")
Exemplo 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)
Exemplo n.º 3
0
def addFavorites(url, iconimage, name):
    dirs = common.ReadList(FAV)
    for item in dirs:
        if item["url"].lower() == url.lower():
            xbmc.executebuiltin(
                'Notification({0}, {1} Already in  favorites, {2}, {3})'.
                format(AddonName, name, 5000, __icon2__))
            return

    list = common.ReadList(tmpList)
    for item in list:
        #if urllib.unquote_plus(item["name"].lower()) == name.lower():
        if item["name"].encode("utf-8").lower() == name.lower():
            url = item["url"]
            iconimage = item["image"]
            type = item["type"]
    if not iconimage:
        iconimage = ""
    data = {
        "url": url,
        "image": iconimage,
        "name": name.decode("utf-8"),
        "type": type
    }
    dirs.append(data)
    common.WriteList(FAV, dirs)
    xbmc.executebuiltin(
        'Notification({0}, {1} added to favorites, {2}, {3})'.format(
            AddonName, name, 5000, __icon__))
Exemplo 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()
Exemplo 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__))
Exemplo n.º 6
0
def addFavorites(listIndex):
    item = common.ReadList(tmpList)[listIndex]
    dirs = common.ReadList(FAV)
    for favItem in dirs:
        if favItem["url"] == item["url"].replace("[COLOR yellow][B]",
                                                 "").replace(
                                                     "[/B][/COLOR]", ""):
            xbmc.executebuiltin(
                'Notification({0}, [COLOR {1}][B]{2}[/B][/COLOR] Already in  favorites, {3}, {4})'
                .format(AddonName, Addon.getSetting("chColor"),
                        item["name"].decode("utf-8"), 5000, __icon2__))
            return

    if item["image"] is None:
        item["image"] = ""

    name = item["name"].encode("utf-8")

    data = {
        "url": item["url"],
        "image": item["image"],
        "name": name.decode("utf-8"),
        "type": item["type"]
    }
    dirs.append(data)
    common.WriteList(FAV, dirs)
    xbmc.executebuiltin(
        'Notification({0}, [COLOR {1}][B]{2}[/B][/COLOR] added to favorites, {3}, {4})'
        .format(AddonName, Addon.getSetting("chColor"), name, 5000, __icon__))
Exemplo n.º 7
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__))
Exemplo n.º 8
0
def ListLive(name, iconimage=None):
    list = []
    list1 = common.GetListFromPlx(filterCat=name)
    listIndex = 0
    for item_data in list1:
        url = item_data['url']
        image = item_data['image']
        description = ""
        channelName = common.GetEncodeString(item_data['name'])
        background = None
        isTvGuide = False

        if item_data["type"] == 'video' or item_data["type"] == 'audio':
            if url.find(AddonID) > 0:
                itemMode = re.compile('url=([0-9]*).*?mode=([0-9]*).*?$',
                                      re.I + re.M + re.U + re.S).findall(url)
                if len(itemMode) > 0 and itemMode[0] != '':
                    mode = int(itemMode[0][1])
                if mode == 1:
                    mode = 3
            elif url.find('?mode=3') > 0 and not useIPTV:
                continue
            else:
                mode = 10

            displayName, description, background, isTvGuide = GetProgrammeDetails(
                channelName)

        elif item_data["type"] == 'playlist':
            mode = 2
            displayName = "[COLOR {0}][B][{1}][/B][/COLOR]".format(
                Addon.getSetting("catColor"), channelName)
            background = image
        else:
            continue

        if background is None or background == "":
            background = iconimage
        addDir(displayName,
               url,
               mode,
               image,
               description,
               channelName=channelName,
               background=background,
               isTvGuide=isTvGuide,
               listIndex=listIndex)
        list.append({
            "url": url,
            "image": image,
            "name": channelName.decode("utf-8"),
            "type": item_data["type"]
        })
        listIndex += 1

    common.WriteList(tmpList, list)
    SetViewMode()
Exemplo n.º 9
0
def ExportFavourites():
	selectedDir = Addon.getSetting("imExFolder")
	if selectedDir is None or selectedDir == "":
		return
	filename = common.GetKeyboardText(localizedString(30026).encode('utf-8'), "favorites").strip()
	if filename == "":
		return
	fullPath = os.path.join(selectedDir.decode("utf-8"), '{0}.txt'.format(filename))
	favsList = common.ReadList(FAV)
	common.WriteList(fullPath, favsList)
	xbmc.executebuiltin('Notification({0}, Favourites list is saved at {1}, {2}, {3})'.format(AddonName, fullPath, 10000, __icon__))
Exemplo n.º 10
0
def AddCategories():
	if not os.path.isfile(categoriesFile):
		common.UpdateChList()
	allCatList = common.ReadList(categoriesFile)
	selectedCatList = common.ReadList(selectedCategoriesFile)
	categories = common.GetUnSelectedList(allCatList, selectedCatList)
	categoriesNames = [u"[COLOR {0}][B][{1}][/B][/COLOR]".format(Addon.getSetting("catColor"), item["name"]) for item in categories]
	selected = common.GetMultiChoiceSelected(localizedString(30503).encode('utf-8'), categoriesNames)
	if len(selected) < 1:
		return
	selectedList = [categories[item] for item in selected]
	common.WriteList(selectedCategoriesFile, selectedCatList + selectedList)
Exemplo n.º 11
0
def RemoveCategories():
	if not os.path.isfile(categoriesFile):
		common.UpdateChList()
	
	selectedCatList = common.ReadList(selectedCategoriesFile)
	categories = [u"[COLOR {0}][B][{1}][/B][/COLOR]".format(Addon.getSetting("catColor"), item["name"]) for item in selectedCatList]
	selected = common.GetMultiChoiceSelected(localizedString(30503).encode('utf-8'), categories)
	if len(selected) < 1:
		return
	for ind in range(len(selected)-1, -1, -1):
		selectedCatList.remove(selectedCatList[selected[ind]])
		
	common.WriteList(selectedCategoriesFile, selectedCatList)
Exemplo n.º 12
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)
Exemplo n.º 13
0
def AddUserChannelToFavorites():
	chName = common.GetKeyboardText(localizedString(30225).encode('utf-8')).strip()
	if len(chName) < 1:
		return
	chUrl = common.GetKeyboardText(localizedString(30226).encode('utf-8')).strip()
	if len(chUrl) < 1:
		return
	
	if not os.path.isfile(categoriesFile):
		common.UpdateChList()
	categories = common.ReadList(categoriesFile)
	categoriesNames = [u"[COLOR {0}][B][{1}][/B][/COLOR]".format(Addon.getSetting("catColor"), item["name"]) for item in categories]
	categoryInd = common.GetMenuSelected(localizedString(30227).encode('utf-8'), categoriesNames)
	if categoryInd == -1:
		return
	group = categories[categoryInd]["id"]
	chTypeInd = common.GetMenuSelected(localizedString(30232).encode('utf-8'), [localizedString(30233).encode('utf-8'), localizedString(30234).encode('utf-8')])
	if chTypeInd == 0:
		chType = "video"
	elif chTypeInd == 1: 
		chType = "audio"
	else:
		return
	logoInd = common.GetMenuSelected(localizedString(30228).encode('utf-8'), [localizedString(30229).encode('utf-8'), localizedString(30230).encode('utf-8'), localizedString(30231).encode('utf-8')])
	if logoInd == 0:
		logoFile = common.GetKeyboardText(localizedString(30229).encode('utf-8')).strip()
		if len(logoFile) < 1:
			return
	elif logoInd == 1:
		logoFile = xbmcgui.Dialog().browse(2, localizedString(30230).encode('utf-8'), 'myprograms')
		if logoFile is None or len(logoFile) < 1:
			return
	elif logoInd == 2:
		logoFile = ""
	else:
		return
		
	favsList = common.ReadList(FAV)
	for channel in favsList:
		if channel["url"].lower() == chUrl.lower():
			xbmc.executebuiltin('Notification({0}, [COLOR {1}][B]{2}[/B][/COLOR]  Already in favourites, {3}, {4})'.format(AddonName, Addon.getSetting("chColor"), chName, 5000, __icon2__))
			return
		
	data = {"url": chUrl.decode("utf-8"), "group": group, "image": logoFile.decode("utf-8"), "type": chType, "name": chName.decode("utf-8")}
	
	favsList.append(data)
	if common.WriteList(FAV, favsList):
		xbmc.executebuiltin('Notification({0}, [COLOR {1}][B]{2}[/B][/COLOR]  added to favourites, {3}, {4})'.format(AddonName, Addon.getSetting("chColor"), chName, 5000, __icon__))
Exemplo n.º 14
0
def MoveInList(index, step, listFile):
	theList = common.ReadList(listFile)
	if index + step >= len(theList) or index + step < 0:
		return
	
	if step == 0:
		step = GetIndexFromUser(len(theList), index)
		
	
	if step < 0:
		tempList = theList[0:index + step] + [theList[index]] + theList[index + step:index] + theList[index + 1:]
	elif step > 0:
		tempList = theList[0:index] + theList[index +  1:index + 1 + step] + [theList[index]] + theList[index + 1 + step:]
	else:
		return

	common.WriteList(listFile, tempList)
	xbmc.executebuiltin("XBMC.Container.Refresh()")
Exemplo n.º 15
0
def AddCategories():
    if not os.path.isfile(categoriesFile):
        common.UpdatePlx(plxFile, "plx", forceUpdate=True)

    allCatList = common.ReadList(categoriesFile)
    selectedCatList = common.ReadList(selectedCategoriesFile)
    showCat = []
    for index, cat in enumerate(allCatList):
        if not any(f["id"] == cat.get("id", "") for f in selectedCatList):
            showCat.append(cat)

    categories = [
        u"[COLOR {0}][B][{1}][/B][/COLOR]".format(Addon.getSetting("catColor"),
                                                  item["name"])
        for item in showCat
    ]
    selected = common.GetMultiChoiceSelected(
        localizedString(30503).encode('utf-8'), categories)
    if len(selected) < 1:
        return

    selectedList = [showCat[item] for item in selected]
    common.WriteList(selectedCategoriesFile, selectedCatList + selectedList)
Exemplo n.º 16
0
            .format(item['addonid']))

localizedString = Addon.getLocalizedString
AddonName = Addon.getAddonInfo("name")
icon = Addon.getAddonInfo('icon')
artDir = os.path.join(addonPath, 'resources', 'art')
__icon__ = os.path.join(artDir, "check2.png")
__icon2__ = os.path.join(artDir, "signQuestionMark.png")

user_dataDir = xbmc.translatePath(
    Addon.getAddonInfo("profile")).decode("utf-8")
if not os.path.exists(user_dataDir):
    os.makedirs(user_dataDir)
FAV = os.path.join(user_dataDir, 'favorites.txt')
if not (os.path.isfile(FAV)):
    common.WriteList(FAV, [])
listsFile = os.path.join(user_dataDir, "israelive.list")
if not os.path.isfile(listsFile):
    common.UpdateChList()
fullGuideFile = os.path.join(user_dataDir, 'fullGuide.txt')
iptvChannelsFile = os.path.join(user_dataDir, "iptv.m3u")
iptvGuideFile = os.path.join(user_dataDir, "guide.xml")
iptvLogosDir = os.path.join(user_dataDir, "logos")
categoriesFile = os.path.join(user_dataDir, 'lists', 'categories.list')
selectedCategoriesFile = os.path.join(user_dataDir, 'lists',
                                      'selectedCategories.list')
useCategories = Addon.getSetting("useCategories") == "true"
showProgNames = Addon.getSetting("showProgNames") == "true"
useEPG = Addon.getSetting("useEPG") == "true"
if useEPG and not os.path.isfile(fullGuideFile):
    useEPG = False
Exemplo n.º 17
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)
Exemplo n.º 18
0
def ListLive(name, iconimage=None):
    list = []
    list1 = common.GetListFromPlx(filterCat=name)
    for item_data in list1:
        url = item_data['url']
        image = item_data['image']
        description = ""
        channelName = common.GetEncodeString(item_data['name'])
        background = None
        isTvGuide = False

        if item_data["type"] == 'video' or item_data["type"] == 'audio':
            channelName = "[COLOR yellow][B]{0}[/B][/COLOR]".format(
                channelName)
            displayName = channelName
            chNum = None
            filmon = False

            if url.find('plugin.video.israelive') > 0:
                itemMode = re.compile('url=([0-9]*).*?mode=([0-9]*)(.*?)$',
                                      re.I + re.M + re.U + re.S).findall(url)
                if len(itemMode) > 0 and itemMode[0] != '':
                    mode = int(itemMode[0][1])
                if mode == 1:
                    mode = 3
                    chNum = itemMode[0][0]
                    if itemMode[0][2] != "&ignorefilmonguide=1":
                        filmon = True
            elif url.find('plugin.video.f4mTester') > 0:
                mode = 12
            elif url.find('?mode=2') > 0:
                mode = 14
                #url = url[:url.find('?mode')]
            else:
                mode = 10

            displayName, description, background, isTvGuide = GetProgrammeDetails(
                channelName, chNum, filmon=filmon)

        elif item_data["type"] == 'playlist':
            mode = 2
            displayName = "[COLOR blue][B][{0}][/B][/COLOR]".format(
                channelName)
            background = image
        else:
            continue

        if background is None or background == "":
            background = iconimage
        addDir(displayName,
               url,
               mode,
               image,
               description,
               channelName=channelName,
               background=background,
               isTvGuide=isTvGuide)
        list.append({
            "url": url,
            "image": image,
            "name": channelName.decode("utf-8"),
            "type": item_data["type"]
        })

    common.WriteList(tmpList, list)
    SetViewMode()