Skip to content

Commit

Permalink
fix #9 (twitch support)
Browse files Browse the repository at this point in the history
  • Loading branch information
9001 committed Jan 2, 2024
1 parent 98002cf commit c5b8190
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions softchat/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,17 @@ def generate_font(emotes, font_fn, font_name, dont_write):
return fff.gen_fonts(*args)


def is_a_chatlog(jd):
try:
hits = 0
for je in jd[:32768]:
if "action_type" in je or "message" in je:
hits += 1
return hits > 0
except:
return False


class Okay(
argparse.ArgumentDefaultsHelpFormatter, argparse.RawDescriptionHelpFormatter
):
Expand Down Expand Up @@ -419,11 +430,8 @@ def main():
except:
pass

if not err:
try:
_ = jd2[0]["action_type"]
except:
err = "does not look like a chatlog"
if not err and not is_a_chatlog(jd2):
err = "does not look like a chatlog"

if err:
error(f"failed: {err}")
Expand Down Expand Up @@ -531,11 +539,8 @@ def main():
except:
pass

if not err:
try:
_ = jd2[0]["timestamp"]
except:
err = "does not look like a chatlog"
if not err and not is_a_chatlog(jd2):
err = "does not look like a chatlog"

if err:
error(f"failed: {err}")
Expand Down

0 comments on commit c5b8190

Please sign in to comment.