def updateDb(url): initTitles() Print.info("Downloading new title database " + url) try: if url == '' or not url: return if "http://" not in url and "https://" not in url: try: url = base64.b64decode(url) except Exception as e: Print.info("\nError decoding url: ", e) return r = requests.get(url) r.encoding = 'utf-8-sig' if r.status_code == 200: Titles.loadTitleBuffer(r.text, False) else: Print.info('Error updating database: ', repr(r)) except Exception as e: Print.info('Error downloading:' + str(e)) raise
def updateDb(url, c=0): initTitles() c += 1 if c > 3: return False Print.info("Downloading new title database " + url) try: if url == '' or not url: return if "http://" not in url and "https://" not in url: try: url = base64.b64decode(url) except Exception as e: Print.info("\nError decoding url: ", e) return r = requests.get(url) r.encoding = 'utf-8-sig' if r.status_code == 200: try: m = re.search(r'<a href="([^"]*)">Proceed</a>', r.text) if m: return updateDb(m.group(1), c) except: pass Titles.loadTitleBuffer(r.text, False) else: Print.info('Error updating database: ', repr(r)) except Exception as e: Print.info('Error downloading:' + str(e)) raise