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 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()
def RefreshPVR(m3uPath, epgPath, logoPath, forceUpdate=False, forceUpdateIPTV=False): if forceUpdateIPTV or common.getAutoIPTV(): UpdateIPTVSimpleSettings(m3uPath, epgPath, logoPath) kodi16 = True if common.GetKodiVer() < 17 else False if Addon.getSetting("autoPVR") == "true": if (not json.loads(xbmc.executeJSONRPC('{"jsonrpc":"2.0","method":"Addons.GetAddonDetails","params":{"addonid":"pvr.iptvsimple", "properties": ["enabled"]},"id":1}'))['result']['addon']['enabled'] or (kodi16 and not json.loads(xbmc.executeJSONRPC('{"jsonrpc":"2.0", "method":"Settings.GetSettingValue", "params":{"setting":"pvrmanager.enabled"},"id":1}'))['result']['value'])): tvOption = common.GetMenuSelected(localizedString(30317).encode('utf-8'), [localizedString(30318).encode('utf-8'), localizedString(30319).encode('utf-8')]) if tvOption != 0: if tvOption == 1: Addon.setSetting("useIPTV", "False") return False isIPTVnotRestarted = not EnableIptvClient() and not kodi16 isPVRnotRestarted = kodi16 and not EnablePVR() if isIPTVnotRestarted and forceUpdate: xbmc.executeJSONRPC('{"jsonrpc":"2.0","method":"Addons.SetAddonEnabled","params":{"addonid":"pvr.iptvsimple","enabled":false},"id":1}') xbmc.executeJSONRPC('{"jsonrpc":"2.0","method":"Addons.SetAddonEnabled","params":{"addonid":"pvr.iptvsimple","enabled":true},"id":1}') #iptvAddon = GetIptvAddon() #if iptvAddon is None: # return False #iptvAddon.setSetting("m3uPathType", iptvAddon.getSetting("m3uPathType")) if isPVRnotRestarted: xbmc.executebuiltin('StopPVRManager') xbmc.executebuiltin('StartPVRManager') return True else: return False
def RefreshPVR(m3uPath, epgPath, logoPath, autoIPTV=2): if autoIPTV == 0: Addon.setSetting("autoIPTV", "0") else: autoIPTV = int(Addon.getSetting("autoIPTV")) if autoIPTV == 2 or autoIPTV == 3: autoIPTV = common.GetMenuSelected(localizedString(30306).encode('utf-8'), [localizedString(30001).encode('utf-8'), localizedString(30002).encode('utf-8'), localizedString(30003).encode('utf-8'), localizedString(30004).encode('utf-8')]) if autoIPTV == -1: autoIPTV = 3 else: Addon.setSetting("autoIPTV", str(autoIPTV)) if autoIPTV == 0 or autoIPTV == 2: UpdateIPTVSimpleSettings(m3uPath, epgPath, logoPath) xbmc.executebuiltin('StartPVRManager')
def EnableIPVR(): try: if not json.loads( xbmc.executeJSONRPC( '{"jsonrpc":"2.0", "method":"Settings.GetSettingValue", "params":{"setting":"pvrmanager.enabled"},"id":1}' ))['result']['value']: tvOption = common.GetMenuSelected( localizedString(30317).encode('utf-8'), [ localizedString(30318).encode('utf-8'), localizedString(30319).encode('utf-8') ]) if tvOption == 0: xbmc.executeJSONRPC( '{"jsonrpc":"2.0", "method":"Settings.SetSettingValue", "params":{"setting":"pvrmanager.enabled", "value":true},"id":1}' ) return True elif tvOption == 1: Addon.setSetting("useIPTV", "False") except: pass return False
def RefreshPVR(m3uPath, epgPath, logoPath, forceUpdate=False): if forceUpdate or common.getAutoIPTV(): UpdateIPTVSimpleSettings(m3uPath, epgPath, logoPath) ver = xbmc.__version__.split('.') kodi17 = True if int(ver[0]) > 2 or int( ver[0]) == 2 and int(ver[1]) > 24 else False if Addon.getSetting("autoPVR") == "true": if (not json.loads( xbmc.executeJSONRPC( '{"jsonrpc":"2.0","method":"Addons.GetAddonDetails","params":{"addonid":"pvr.iptvsimple", "properties": ["enabled"]},"id":1}' ))['result']['addon']['enabled'] or (not kodi17 and not json.loads( xbmc.executeJSONRPC( '{"jsonrpc":"2.0", "method":"Settings.GetSettingValue", "params":{"setting":"pvrmanager.enabled"},"id":1}' ))['result']['value'])): tvOption = common.GetMenuSelected( localizedString(30317).encode('utf-8'), [ localizedString(30318).encode('utf-8'), localizedString(30319).encode('utf-8') ]) if tvOption != 0: if tvOption == 1: Addon.setSetting("useIPTV", "False") return False isIPTVnotRestarted = not EnableIptvClient() and kodi17 isPVRnotRestarted = not kodi17 and not EnablePVR() if isIPTVnotRestarted and forceUpdate: xbmc.executeJSONRPC( '{"jsonrpc":"2.0","method":"Addons.SetAddonEnabled","params":{"addonid":"pvr.iptvsimple","enabled":false},"id":1}' ) xbmc.executeJSONRPC( '{"jsonrpc":"2.0","method":"Addons.SetAddonEnabled","params":{"addonid":"pvr.iptvsimple","enabled":true},"id":1}' ) if isPVRnotRestarted: xbmc.executebuiltin('StopPVRManager') xbmc.executebuiltin('StartPVRManager') return True else: return False