Skip to content

Commit

Permalink
feat: add multiple manifest notify
Browse files Browse the repository at this point in the history
  • Loading branch information
lekoOwO committed Apr 1, 2021
1 parent 7026a92 commit 349e704
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
28 changes: 26 additions & 2 deletions index.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,17 @@ def clear_chat():
video_id: {
"fregments": {},
"skipPrivateCheck": False,
"skipOnliveNotify": False
"skipOnliveNotify": False,
"multiManifestNotify": 1
}
}

if video_id not in fetched[channel_name]:
fetched[channel_name][video_id] = {
"fregments": {},
"skipPrivateCheck": False,
"skipOnliveNotify": False
"skipOnliveNotify": False,
"multiManifestNotify": 1
}

filepath = os.path.join(const.BASE_JSON_DIR, f"{m3u8_id}.json")
Expand Down Expand Up @@ -250,6 +252,28 @@ def clear_chat():
"create_time": time.time()
}

if len(fetched[channel_name][video_id]["fregments"]) > 1:
if "multiManifestNotify" not in fetched[channel_name][video_id]:
fetched[channel_name][video_id]["multiManifestNotify"] = 1
if len(fetched[channel_name][video_id]["fregments"]) > fetched[channel_name][video_id]["multiManifestNotify"]:
fetched[channel_name][video_id]["multiManifestNotify"] = len(fetched[channel_name][video_id]["fregments"])

files = [fetched[channel_name][video_id]["fregments"][m3u8_id]["file"] for m3u8_id in fetched[channel_name][video_id]["fregments"]]
message = text.MULTI_MANIFEST_MESSAGE.format(video_id=video_id, channel_name=channel_name, channel_id=channel_id)

if const.ENABLED_MODULES["discord"]:
threading.Thread(target=discord.send, args=(const.DISCORD_WEBHOOK_URL, message), kwargs={
"version": const.VERSION,
"files": files if const.DISCORD_SEND_FILES else None
}, daemon=True).start()
if const.ENABLED_MODULES["telegram"]:
if const.TELEGRAM_SEND_FILES:
threading.Thread(target=telegram.send_files, args=(const.TELEGRAM_BOT_TOKEN, const.TELEGRAM_CHAT_ID, message, files), daemon=True).start()
else:
threading.Thread(target=telegram.send, args=(const.TELEGRAM_BOT_TOKEN, const.TELEGRAM_CHAT_ID, message)).start()

utils.log(f"[INFO] {message}")

save()
else:
utils.log(f"[{channel_name}] Not on live.")
Expand Down
2 changes: 2 additions & 0 deletions text.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ def get_private_check_text(status):

ON_LIVE_MESSAGE = "[{video_id}](https://youtu.be/{video_id}) is live on [{channel_name}](https://www.youtube.com/channel/{channel_id})!"

MULTI_MANIFEST_MESSAGE = "[{video_id}](https://youtu.be/{video_id}) has multiple manifest on [{channel_name}](https://www.youtube.com/channel/{channel_id})!"

PUSHALERT_TITLE = "🔴 Hololive Live Alert"
PUSHALERT_MESSAGE = "{channelName} is Live now!"

Expand Down

0 comments on commit 349e704

Please sign in to comment.