def WriteSettings(settingsDictionary, iptvSettingsFile): xml = [] xml.append("<settings>\n") for k, v in settingsDictionary.items(): xml.append('\t<setting id="{0}" value="{1}" />\n'.format(k, v)) xml.append("</settings>\n") common.WriteFile("".join(xml), iptvSettingsFile)
def GetTVChannels(): if (IsLoggedIn()): username, password = GetCredentials() xml_link = URL_XML_FEED % (urllib.parse.quote(username), urllib.parse.quote(password)) local_xml = os.path.join(__XML__, "annatel.xml") doc = common.DownloadBinary(xml_link) if (doc is None): doc = common.ReadFile(local_xml) else: common.WriteFile(doc, local_xml, False, True) common.SetLastModifiedLocal(__XML__) if (doc is not None): response = [] parsed_doc = parseString(doc) for channel in parsed_doc.getElementsByTagName('channel'): name = channel.getElementsByTagName( 'name')[0].childNodes[0].data url = channel.getElementsByTagName('url')[0].childNodes[0].data logo = channel.getElementsByTagName( 'logo')[0].childNodes[0].data tv_channel = common.TV(url, name, name, tvg_logo=logo) response.append(tv_channel) return response else: return None else: return None
def register(): if request.method == 'POST': registerInfo = request.form.to_dict() # 1. check user exists # 2. check email ok(@) # 3. write data to disk print 'register post' username = registerInfo['username'] if re.match('^[a-zA-Z]+[0-9]*$', username) == None: print 'username uncorrect' return render_template( 'status.html', msginfo='username only contains letter and number!') email = registerInfo['email'] if re.match('\w+@\w+\.[a-z]+', email) == None: print 'email uncorrect' return render_template('status.html', msginfo='email format is not correct!') password = registerInfo['password'] if common.CheckUserExist(username, email) == 1: print 'user exist' return render_template( 'status.html', msginfo='Register failed! User or email exist.') registerInfo['login_failed'] = 0 common.WriteFile(registerInfo) print 'write file' return render_template('status.html', msginfo='User %s register success!' % username) else: return render_template('register.html')
def RefreshEPG(epg_list, is_very_new=False): if ((epg_list is not None) and (len(epg_list) > 0)): epgFile = os.path.join(__AddonDataPath__, 'epg.xml') restart_pvr = (not os.path.exists(epgFile)) epg_xml = MakeEPG(epg_list) common.WriteFile(epg_xml, epgFile) if (restart_pvr): UpdateIPTVSimpleSettings(restart_pvr=True) elif (is_very_new): RefreshIPTVSimple()
def GetEPG(): epg_xml = common.ReadZipUrl(URL_EPG_FEED, "xmltv.xml") local_epg = os.path.join(__EPG__, "tvguide.xml") if (epg_xml is not None): common.WriteFile(epg_xml, local_epg) common.SetLastModifiedLocal(__EPG__) else: epg_xml = common.ReadFile(local_epg) if (epg_xml is not None): epg = ParseEPG(epg_xml) FixEPGChannelsIDs(epg) return epg else: return None
def register(): if request.method == 'POST': registerInfo = request.form.to_dict() #print registerInfo # 1. check user exists if common.check_user_exists(registerInfo['username']): return render_template('user_exist.html') # 2. check email ok(@) if not common.check_email(registerInfo['email']): return render_template('email.html') else: # 3. write data to disk common.WriteFile(registerInfo) return render_template('success.html') else: return render_template('register.html')
def RefreshIPTVlinks(channel_list): iptvAddon = GetIptvAddon() if (iptvAddon is None): return False common.ShowNotification("Updating links...", 3000, addon=__Addon__) is_logo_extension = True finalM3Ulist = MakeM3U(channel_list, is_logo_extension) finalM3Ufilename = os.path.join(__AddonDataPath__, 'iptv.m3u') # The final m3u file location. current_file = common.ReadFile(finalM3Ufilename) print('update chanel', finalM3Ulist) if ((current_file is None) or (finalM3Ulist != current_file)): common.WriteFile(finalM3Ulist, finalM3Ufilename) UpdateIPTVSimpleSettings(iptvAddon, restart_pvr=True) else: UpdateIPTVSimpleSettings(iptvAddon, restart_pvr=False) # DeleteCache() common.ShowNotification("Updating is done.", 2000, addon=__Addon__) return True