import os
import requests
import json
import time

with open("latest_id_seen") as latest_id_seen_file:
    latest_id_seen = latest_id_seen_file.read().strip()

while True:
    recent_bsocial = requests.get("https://blockpost.network/api/v1/posts/latestIds")
    latest_id = json.loads(recent_bsocial.text)["data"][0]["_id"]
    if latest_id != latest_id_seen:
        os.system("play mixkit-sci-fi-reject-notification-896.wav")
        with open("latest_id_seen", "w") as latest_id_seen_file:
            latest_id_seen_file.write(latest_id)
        latest_id_seen = latest_id
    time.sleep(10)

