def login(): headers = { "Origin": routines.decrypt_string(MAIN_URL), "Accept-Encoding": "gzip, deflate, br", "X-CSRF-TOKEN": utils.get_setting("csrf_token"), "Accept-Language": "hu-HU,hu;q=0.9,en-US;q=0.8,en;q=0.7", "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8", "Accept": "*/*", "Referer": "%s/csatornak" % (routines.decrypt_string(MAIN_URL)), "X-Requested-With": "XMLHttpRequest", "Connection": "keep-alive", } data = { "email": utils.get_setting("username"), "password": utils.get_setting("password"), "accept": "1", # the privacy rules } response = routines.request_page( "%s/login" % (routines.decrypt_string(MAIN_URL)), headers=headers, user_agent=utils.get_setting("user_agent"), cookies=cookie_builder(), data=data, allow_redirects=False, ) update_cookies(response) if response.status_code != 302: utils.create_ok_dialog("Helytelen bejelentkezési adatok! (Kód: %i)" % (response.status_code)) utils.open_settings() exit() utils.create_notification("Sikeres bejelentkezés!")
def live_window(): response = routines.request_page( "%sv2/channels/live" % (routines.decrypt_string(API_BASE)), user_agent=utils.get_setting("user_agent"), headers={ "Referer": "%scsatornak" % (routines.decrypt_string(MAIN_URI)), "x-application-id": routines.decrypt_string(APP_ID), "x-access-token": get_token(), }, ) for channel in response.json()["data"]["available"]: if channel.get("epg") and channel["epg"].get("title"): name = "%s[CR][COLOR gray]%s[/COLOR]" % ( channel.get("name").encode("utf-8"), channel["epg"]["title"].encode("utf-8"), ) else: name = channel.get("name").encode("utf-8") routines.add_item(*sys.argv[:2], name=name, action="translate_link", icon=channel.get("logoLink"), id=channel.get("id"), extra=channel.get("slug"), fanart=utils.fanart, type="video", refresh=True, is_directory=False, is_livestream=True) setContent(int(sys.argv[1]), "tvshows")
def extend_token(): response = routines.request_page( "%sv1/user/session/extend" % (routines.decrypt_string(API_BASE)), user_agent=utils.get_setting("user_agent"), headers=HEADERS, additional_headers={"Referer": routines.decrypt_string(MAIN_URI)}, data={ "refreshToken": utils.get_setting("refresh_token"), "platform": "web", "app_version": VERSION, }, ) if response.status_code != 200: utils.create_ok_dialog( "Sikertelen a token frissítése. Próbálkozzon jelszót változtatni!\n" "Amennyiben a probléma továbbra is fennállna, jelezze a fejlesztőnek." ) exit(1) try: data = response.json() except Exception as e: raise routines.Error(e) utils.set_setting("refresh_token", data["refreshToken"].encode("utf-8")) utils.set_setting("token", data["token"].encode("utf-8")) utils.create_notification("Sikeres token frissítés") return data["token"].encode("utf-8")
def run(self): utils = self.utils before_playing_wait = 0.0 while not self.player.isPlaying(): xbmc.sleep(int(NOT_PLAYING_WAIT_TIME * 1000)) if before_playing_wait >= 5: self.end() return # couldn't start playing in 5 seconds before_playing_wait += NOT_PLAYING_WAIT_TIME while self.player.isPlaying(): xbmc.log("Lejátszás folyamatban...") try: if not decrypt_string("470098bXNyZXBvIGh0dHBzOi8vb25saW5lLmRpZ2kuaHU=") in self.player.getPlayingFile(): xbmc.log("Nem a mienk...") self.stop() break try: c_id = self.player.getPlayingFile().split("playlist/", 1)[1].split("/", 1)[0] except: xbmc.log("Sikertelen csatornanév kinyerés", xbmc.LOGERROR) self.stop() break headers = { "Accept-Encoding": "gzip, deflate, br", "Accept-Language": "hu-HU,hu;q=0.9,en-US;q=0.8,en;q=0.7", "Accept": "*/*", "Referer": "%s/player/%s" % (decrypt_string(MAIN_URL), c_id), "X-Requested-With": "XMLHttpRequest", "Connection": "keep-alive", } cookies = { "XSRF-TOKEN": utils.get_setting("xsrf_token"), "laravel_session": utils.get_setting("laravel_session"), "acc_pp": utils.get_setting("acc_pp"), } response = request_page( POLLER_URL_PREFIX, params={"id": c_id}, cookies=cookies, headers=headers, ) xbmc.log("%s [%s] %s" % (response.url, response.status_code, response.content)) for k, v in response.cookies.items(): if k == "XSRF-TOKEN": utils.set_setting("xsrf_token", v) elif k == "laravel_session": utils.set_setting("laravel_session", v) elif k == "acc_pp": utils.set_setting("acc_pp", v) xbmc.log("Kérés elküldve...") except RuntimeError: pass xbmc.sleep(int(PLAYING_WAIT_TIME * 1000)) self.end()
def translate_link(id, slug, name, icon): response = routines.request_page( "%sv2/streams/live?content_id=%s&language=hu&type=hls" % (routines.decrypt_string(API_BASE), id), user_agent=utils.get_setting("user_agent"), headers={ "Referer": "%scsatornak/%s" % (routines.decrypt_string(MAIN_URI), slug), "x-application-id": routines.decrypt_string(APP_ID), "x-access-token": get_token(), }, ) if response.status_code == 400: message = ["A szerver nem tudott mit kezdeni a kéréssel."] if response.json().get("errorCode") == 10930: message.append( "Túl gyorsan váltogatsz a csatornák közt, várj 5 mp-et!") if response.json().get("errorMessage"): message.append("Hibaüzenet: [COLOR darkred]%s[/COLOR]" % (response.json()["errorMessage"].encode("utf-8"))) utils.create_ok_dialog("[CR]".join(message)) exit() elif response.status_code != 200: utils.create_ok_dialog( "Lejátszás sikertelen ismeretlen okból.\nA szerver válasza: (%i) %s" % (response.status_code, response.content.encode("utf-8"))) exit(1) try: data = response.json() except Exception as e: raise routines.Error(e) if not data.get("data", {}).get("url"): utils.create_ok_dialog( "Ehhez a médiához nem tartozik lejátszási link.") exit() if data["data"].get("drmkey"): utils.create_notification( "DRM védett tartalom. Az addon ezek lejátszására nem képes.") exit() routines.play( int(sys.argv[1]), data["data"]["url"], "video", user_agent=utils.get_setting("user_agent"), name=name, icon=icon, )
def login(): if not all([utils.get_setting("username"), utils.get_setting("password")]): utils.create_notification("Kérlek add meg email címed és jelszavad!") utils.open_settings() exit(0) response = routines.request_page( "%sv2/user/login" % (routines.decrypt_string(API_BASE)), user_agent=utils.get_setting("user_agent"), headers=HEADERS, additional_headers={ "Referer": "%s?popup=bejelentkezes" % (routines.decrypt_string(MAIN_URI)) }, data={ "email": utils.get_setting("username"), "password": utils.get_setting("password"), "platform": "web", "app_version": VERSION, }, ) if response.status_code in [400, 404]: utils.create_ok_dialog( "Bejelentkezésed sikertelen volt. Biztosan jól adtad meg az email címed és jelszavad?" ) utils.open_settings() exit(1) elif response.status_code != 200: utils.create_ok_dialog( "Ennek a hibának nem kellett volna előfordulnia. Kérlek jelezd a fejlesztőnek" ", hogy az addon hibára futott bejelentkezésnél. A szerver válasza: %i\nEsetleg próbáld újra kásőbb, lehet, hogy a szerver túlterhelt." % (response.status_code)) exit(1) try: data = response.json() except Exception as e: raise routines.Error(e) utils.set_setting("refresh_token", data["refreshToken"].encode("utf-8")) utils.set_setting("token", data["token"].encode("utf-8")) utils.create_notification("Sikeres bejelentkezés") utils.set_setting("token_updated_at", str(int(time()))) return data["token"].encode("utf-8")
def live_window(): if not utils.get_setting("user_agent"): utils.set_setting("user_agent", routines.random_uagent()) headers = { "Connection": "keep-alive", "Upgrade-Insecure-Requests": "1", "Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3", "Accept-Encoding": "gzip, deflate, br", "Accept-Language": "hu-HU,hu;q=0.9,en-US;q=0.8,en;q=0.7", } response = routines.request_page( "%s/csatornak" % (routines.decrypt_string(MAIN_URL)), user_agent=utils.get_setting("user_agent"), headers=headers, ) update_cookies(response) login() for channel in parsedom.parseDOM(response.content, name="div", attrs={"class": '[^"]+channel'}): try: url = "%s/player/%s" % ( routines.decrypt_string(MAIN_URL), parsedom.parseDOM( channel, "a", attrs={"data-id": '[^"]+' }, ret="data-id")[0], ) except: continue # if we have no way to stream, why would we even bother showing it try: logo = parsedom.parseDOM( parsedom.parseDOM(channel, name="div", attrs={"class": ".+?channels__logo"})[0], name="img", ret="src", )[0] except: logo = "" try: program_name = (parsedom.replaceHTMLCodes( parsedom.parseDOM( parsedom.parseDOM( channel, name="div", attrs={"class": ".+?channels__program_name"}, )[0], name="a", )[0]).encode("utf-8").strip()) except: program_name = "" try: name = (parsedom.replaceHTMLCodes( parsedom.parseDOM(channel, name="div", attrs={"class": "channels__name.+?" })[0]).encode("utf-8").strip()) except: name = "" description = [] try: timing = parsedom.removeHTMLCodes( parsedom.replaceHTMLCodes( parsedom.parseDOM(channel, name="p", attrs={"class": "timing.+?" })[0]).encode("utf-8")).strip() except: timing = None try: progress = parsedom.parseDOM( channel, name="div", attrs={"class": "progress-bar"}, ret="aria-valuenow", )[0].split(".", 1)[0] except: pass if timing and progress: description.append( "Sugárzási idő: %s (Jelenleg: %s%%)" % (timing.encode("utf-8"), progress.encode("utf-8"))) elif timing: description.append("Sugárzási idő: %s" % (timing.encode("utf-8"))) else: description.append("Jelenleg: %s%%" % (progress.encode("utf-8"))) try: description.append( parsedom.replaceHTMLCodes( parsedom.parseDOM(channel, name="p", attrs={"class": "description" })[0]).encode("utf-8").strip()) except: pass try: description.append( "[COLOR yellow]Korhatár besorolás: %s[/COLOR]" % (parsedom.parseDOM(channel, name="span", attrs={"class": 'age-[^"]+'}, ret="class")[0].encode("utf-8").replace( "age-", ""))) except: pass try: description.append("[I]%s[/I]" % (parsedom.replaceHTMLCodes( parsedom.parseDOM(channel, name="div", attrs={"class": "next_program" })[0]).encode("utf-8").strip())) except: pass if program_name and name: final_name = "%s[CR][COLOR gray]%s[/COLOR]" % (name, program_name) else: final_name = name or program_name routines.add_item(*sys.argv[:2], name=final_name, icon=logo, action="play", extra=url, description="[CR][CR]".join(description), fanart=utils.fanart, is_directory=False, refresh=True) setContent(int(sys.argv[1]), "tvshows")
name=name, description=description, icon=icon, ) if __name__ == "__main__": params = dict(parse_qsl(sys.argv[2].replace("?", ""))) action = params.get("action") if action is None: if utils.get_setting("is_firstrun") == "true": from utils.information import text, eula utils.create_textbox(text % (utils.addon_name, utils.version)) if not utils.create_yesno_dialog( eula % (routines.decrypt_string(EULA_URL)), yes="Elfogadom", no="Kilépek", ): exit() utils.set_setting("is_firstrun", "false") utils.create_ok_dialog( "Kérlek jelentkezz be az addon használatához!") utils.open_settings() exit() main_window() endOfDirectory(int(sys.argv[1])) if action == "channels": live_window() endOfDirectory(int(sys.argv[1])) if action == "clear_creds":
# -*- coding: utf-8 -*- import sys import threading import re import xbmc from mrdini.routines.routines import decrypt_string, request_page NOT_PLAYING_WAIT_TIME = 0.2 PLAYING_WAIT_TIME = 5 * 60 # wait 5 minutes between each poll event MAIN_URL = "470098bXNyZXBvIGh0dHBzOi8vZGlnaW9ubGluZS5odQ==" # TODO: better organize this POLLER_URL_PREFIX = "%s/refresh" % (decrypt_string(MAIN_URL)) class PlaybackMonitorThread(threading.Thread): def __init__(self, utils): super(PlaybackMonitorThread, self).__init__() self._stopped = threading.Event() self._ended = ( threading.Event() ) # probably not useful in livestreams' case but who knows self.utils = utils self.player = xbmc.Player() self.daemon = True self.start() def run(self): utils = self.utils before_playing_wait = 0.0
import sys from time import time from urlparse import parse_qsl from mrdini.routines import routines import xbmcaddon from xbmcplugin import endOfDirectory, setContent utils = routines.Utils(xbmcaddon.Addon()) API_BASE = "470098bXNyZXBvIGh0dHBzOi8vYXBpLm1pbmRpZ28uaHUvYXBpLw==" MAIN_URI = "470098bXNyZXBvIGh0dHBzOi8vdHYubWluZGlnby5odS8=" APP_ID = "470098bXNyZXBvIGVubjlpbW1kbTF2eXU3eXVwZG5raWVkY2g1d21naTRj" VERSION = "1.0.22" HEADERS = { "x-application-id": routines.decrypt_string(APP_ID), "x-app-version": VERSION, "x-platform": "web", "x-os-name": "Windows", "x-os-version": "10", "x-browser-name": "undefined", "x-browser-version": "undefined", "Origin": routines.decrypt_string(MAIN_URI), } def get_token(): if int(time()) - int(utils.get_setting("token_updated_at")) < int( utils.get_setting("token_lifetime") or 86400): return utils.get_setting("token") if not utils.get_setting("refresh_token"):