39 lines
1.2 KiB
Python
39 lines
1.2 KiB
Python
import json
|
|
import re
|
|
|
|
import fHDHR.exceptions
|
|
|
|
|
|
class OriginService():
|
|
|
|
def __init__(self, fhdhr):
|
|
self.fhdhr = fhdhr
|
|
|
|
self.base_url = 'http://www.xumo.tv'
|
|
|
|
self.login()
|
|
|
|
def login(self):
|
|
self.fhdhr.logger.info("Fetching XUMO token")
|
|
self.geoID, self.geoLST = self.getID()
|
|
if not self.geoID or self.geoLST:
|
|
raise fHDHR.exceptions.OriginSetupError("XUMO Setup Failed")
|
|
else:
|
|
self.fhdhr.logger.info("XUMO Setup Success")
|
|
self.status_dict["Login"] = "Success"
|
|
self.fhdhr.config.write(self.fhdhr.config.dict["main"]["dictpopname"], 'token', self.token)
|
|
return True
|
|
|
|
def getID(self):
|
|
pagereq = self.fhdhr.web.session.get(self.base_url).read()
|
|
results = json.loads(re.findall('__JOBS_REHYDRATE_STATE__=(.+?);</script>', (pagereq), flags=re.DOTALL)[0])
|
|
print(results["jobs"]["1"]["data"]["geoId"])
|
|
print(results["jobs"]["1"]["data"]["channelListId"])
|
|
return results["jobs"]["1"]["data"]["geoId"], results["jobs"]["1"]["data"]["channelListId"]
|
|
|
|
def get_status_dict(self):
|
|
ret_status_dict = {
|
|
"Login": "Success",
|
|
}
|
|
return ret_status_dict
|