def UpdateChannelsLists(): xbmc.executebuiltin( "XBMC.Notification({0}, Updating Channels Lists..., {1}, {2})".format( AddonName, 300000, icon)) common.UpdateChList() xbmc.executebuiltin( "XBMC.Notification({0}, Channels Lists updated., {1}, {2})".format( AddonName, 5000, icon))
def DownloadLogos(): if myIPTV.GetIptvType() > 1: return xbmc.executebuiltin("XBMC.Notification({0}, Downloading channels logos..., {1}, {2})".format(AddonName, 300000 ,icon)) if not os.path.isfile(listsFile): common.UpdateChList() myIPTV.SaveChannelsLogos(iptvLogosDir) xbmc.executebuiltin("XBMC.Notification({0}, Channels logos saved., {1}, {2})".format(AddonName, 5000 ,icon))
def MakeIPTVlists(): xbmc.executebuiltin("XBMC.Notification({0}, Making IPTV channels list..., {1}, {2})".format(AddonName, 300000 ,icon)) if not os.path.isfile(listsFile): common.UpdateChList() myIPTV.makeIPTVlist(iptvChannelsFile) xbmc.executebuiltin("XBMC.Notification({0}, Making IPTV TV-guide..., {1}, {2})".format(AddonName, 300000 ,icon)) myIPTV.MakeChannelsGuide(fullGuideFile, iptvGuideFile) myIPTV.RefreshPVR(iptvChannelsFile, iptvGuideFile, iptvLogosDir, forceUpdate=True) xbmc.executebuiltin("XBMC.Notification({0}, IPTV channels list and TV-guide created., {1}, {2})".format(AddonName, 5000 ,icon))
def Update(): # Update channels-lists files common.UpdateChList(forceUpdate=False) # Update EPG files for selected LiveTV channels first isGuideUpdated = False if Addon.getSetting("useEPG") == "true": epg = common.ReadList(fullGuideFile) if len(epg) > 0: isGuideUpdated = True fullCategoriesList = [] selectedCategoriesList = [] categoriesList = [] iptvList = Addon.getSetting("iptvList") if iptvList == "0": # Favourites categoriesList = [{"id": "Favourites"}] elif iptvList == "1": # No filter categoriesList = fullCategoriesList = common.ReadList( os.path.join(user_dataDir, "lists", "categories.list")) elif iptvList == "2": # Selected categories categoriesList = selectedCategoriesList = common.ReadList( os.path.join(user_dataDir, "lists", "selectedCategories.list")) common.MakeCatGuides(categoriesList, epg) useIPTV = common.getUseIPTV() # Update LiveTV channels and EPG if useIPTV: import myIPTV myIPTV.makeIPTVlist(iptvChannelsFile) myIPTV.MakeChannelsGuide(fullGuideFile, iptvGuideFile) myIPTV.RefreshPVR(iptvChannelsFile, iptvGuideFile, iptvLogosDir) # Update EPG files for non-selected LiveTV channels if isGuideUpdated: if fullCategoriesList == []: fullCategoriesList = common.ReadList( os.path.join(user_dataDir, "lists", "categories.list")) if iptvList == "0": # Favourites categoriesList = fullCategoriesList elif iptvList == "1": # No filter categoriesList = [{"id": "Favourites"}] elif iptvList == "2": # Selected categories categoriesList = common.GetUnSelectedList(fullCategoriesList, selectedCategoriesList) categoriesList.append({"id": "Favourites"}) common.MakeCatGuides(categoriesList, epg) # Update channels-logos files if useIPTV and myIPTV.GetIptvType() < 2: myIPTV.SaveChannelsLogos(iptvLogosDir) checkInterval = 720 # 12 hours = 720 minutes xbmc.executebuiltin( "XBMC.AlarmClock({0},XBMC.RunPlugin(plugin://plugin.video.israelive/default.py?mode=100&url=checkUpdates),{1},silent)" .format("IsraeLiveUpdates", checkInterval))
def UpdateChannelsLists(): xbmc.executebuiltin("XBMC.Notification({0}, Updating Channels Lists..., {1}, {2})".format(AddonName, 300000 ,icon)) common.UpdateFile(remoteSettingsFile, "remoteSettingsZip", zip=True, forceUpdate=True) remoteSettings = common.ReadList(remoteSettingsFile) if remoteSettings == []: xbmc.executebuiltin('Notification({0}, Cannot load settings, {1}, {2})'.format(AddonName, 5000, icon)) sys.exit() common.UpdateChList(remoteSettings) xbmc.executebuiltin("XBMC.Notification({0}, Channels Lists updated., {1}, {2})".format(AddonName, 5000 ,icon))
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)
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)
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__))
def Update(): remoteSettings = common.GetRemoteSettings() refresh = common.GetSubKeyValue(remoteSettings, "remoteSettingsZip", "refresh") forceUpdate = True if refresh is None or common.isFileOld(remoteSettingsFile, refresh * 3600) else False common.UpdateFile(remoteSettingsFile, "remoteSettingsZip", remoteSettings, zip=True, forceUpdate=forceUpdate) remoteSettings = common.ReadList(remoteSettingsFile) if remoteSettings == []: xbmc.executebuiltin('StartPVRManager') else: common.CheckNewVersion(remoteSettings) # Update channels-lists files refresh = common.GetSubKeyValue(remoteSettings, "lists", "refresh") if not refresh is None: common.UpdateChList(remoteSettings, refreshInterval = refresh * 3600, forceUpdate = False) # Update EPG files for selected LiveTV channels first isGuideUpdated = False if Addon.getSetting("useEPG") == "true": refresh = common.GetSubKeyValue(remoteSettings, "fullGuide", "refresh") if refresh is not None and common.isFileOld(fullGuideFile, refresh * 3600) and common.UpdateFile(fullGuideFile, "fullGuide", remoteSettings, zip=True): isGuideUpdated = True epg = common.ReadList(fullGuideFile) fullCategoriesList = [] selectedCategoriesList = [] categoriesList = [] iptvList = Addon.getSetting("iptvList") if iptvList == "0": # Favourites categoriesList = [{"id": "Favourites"}] elif iptvList == "1": # No filter categoriesList = fullCategoriesList = common.ReadList(os.path.join(user_dataDir, "lists", "categories.list")) elif iptvList == "2": # Selected categories categoriesList = selectedCategoriesList = common.ReadList(os.path.join(user_dataDir, "lists", "selectedCategories.list")) common.MakeCatGuides(categoriesList, epg) useIPTV = common.getUseIPTV() # Update LiveTV channels and EPG if useIPTV: import myIPTV myIPTV.makeIPTVlist(iptvChannelsFile) myIPTV.MakeChannelsGuide(fullGuideFile, iptvGuideFile) myIPTV.RefreshPVR(iptvChannelsFile, iptvGuideFile, iptvLogosDir) # Update EPG files for non-selected LiveTV channels if isGuideUpdated: if fullCategoriesList == []: fullCategoriesList = common.ReadList(os.path.join(user_dataDir, "lists", "categories.list")) if iptvList == "0": # Favourites categoriesList = fullCategoriesList elif iptvList == "1": # No filter categoriesList = [{"id": "Favourites"}] elif iptvList == "2": # Selected categories categoriesList = common.GetUnSelectedList(fullCategoriesList, selectedCategoriesList) categoriesList.append({"id": "Favourites"}) common.MakeCatGuides(categoriesList, epg) # Update channels-logos files if useIPTV and myIPTV.GetIptvType() < 2: myIPTV.SaveChannelsLogos(iptvLogosDir) checkInterval = 720 # 12 hours = 720 minutes try: checkInterval = remoteSettings["checkInterval"] * 60 # hours to minutes except: pass xbmc.executebuiltin("XBMC.AlarmClock({0},XBMC.RunPlugin(plugin://plugin.video.israelive/default.py?mode=100&url=checkUpdates),{1},silent)".format("IsraeLiveUpdates", checkInterval))
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 epg = None cat = None catname = None
remoteSettingsFile = os.path.join(user_dataDir, "remoteSettings.txt") if not os.path.isfile(remoteSettingsFile): common.UpdateFile(remoteSettingsFile, "remoteSettingsZip", remoteSettings, zip=True, forceUpdate=True) remoteSettings = common.ReadList(remoteSettingsFile) if remoteSettings == []: xbmc.executebuiltin( 'Notification({0}, Cannot load settings, {1}, {2})'.format( AddonName, 5000, icon)) sys.exit() listsFile = os.path.join(user_dataDir, "israelive.list") if not os.path.isfile(listsFile): common.UpdateChList(remoteSettings) 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 epg = None cat = None catname = None