Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def load(self):
"""Load mission from json.
If failing to load missions, create json backup .
"""
try:
self._load()
except Exception:
print("Failed to load session!")
backup(profile("*.json"))
raise
self.cleanup()
def do_download():
debug_log("do_download")
with load_episodes(mission):
download(mission, profile(mission.module.config["savepath"]))
def _load(self):
"""Load missions from json. Called by MissionManager.load."""
pool = json_load(profile("pool.json")) or []
view = json_load(profile("view.json")) or []
library = json_load(profile("library.json")) or []
for m_data in pool:
# reset state
if m_data["state"] in ("DOWNLOADING", "ANALYZING"):
m_data["state"] = "ERROR"
# build episodes
# compatible 2016.6.4
if m_data["episodes"]:
episodes = []
for ep_data in m_data["episodes"]:
# compatible 2016.4.3
if "total" not in ep_data:
if not ep_data["current_url"]:
ep_data["total"] = 0
def _load(self):
"""Load missions from json. Called by MissionManager.load."""
pool = json_load(profile("pool.json")) or []
view = json_load(profile("view.json")) or []
library = json_load(profile("library.json")) or []
for m_data in pool:
# reset state
if m_data["state"] in ("DOWNLOADING", "ANALYZING"):
m_data["state"] = "ERROR"
# build episodes
# compatible 2016.6.4
if m_data["episodes"]:
episodes = []
for ep_data in m_data["episodes"]:
# compatible 2016.4.3
if "total" not in ep_data:
if not ep_data["current_url"]:
ep_data["total"] = 0
elif ep_data["url"] == ep_data["current_url"]:
def tvOpen():
for mission in table.selected():
savepath = profile(mission.module.config["savepath"])
folder = os.path.join(savepath, safefilepath(mission.title))
folder = os.path.expanduser(folder)
if not os.path.isdir(folder):
os.makedirs(folder)
desktop.open(folder)
def save(self):
"""Save missions to json."""
if not self.edit:
return
with mission_lock:
json_dump(list(self.pool.values()), profile("pool.json"))
json_dump(list(self.view), profile("view.json"))
json_dump(list(self.library), profile("library.json"))
self.edit = False
print("Session saved")
def grabber_log(*args):
if setting.getboolean("errorlog"):
content = time.strftime("%Y-%m-%dT%H:%M:%S%z") + "\n" + pformat(args) + "\n\n"
content_write(profile("grabber.log"), content, append=True)
def make_ep_path(id):
"""Construct ep path with id"""
return profile_get("pool/" + safefilepath(id + ".json"))