Parcel #48u35l32fmer3xf

Created by Anonymous
Public

Created May 12, 2025 Expires in 10 days

Loading editor...

import time
import sqlite3
import os

list_of_spotify_links = []

def read_chat_db():
    # Expand the path to chat.db
    db_path = os.path.expanduser("~/Library/Messages/chat.db")

    # Connect to the database
    conn = sqlite3.connect(db_path)
    cursor = conn.cursor()

    # Example query to get messages
    cursor.execute('''
    SELECT
    datetime(message.date / 1000000000 + strftime("%s", "2001-01-01"), "unixepoch", "localtime") AS formatted_date,
    chat.chat_identifier AS chat_id,
    handle.id AS contact,
    message.text AS message_content
    FROM message
    LEFT JOIN handle ON message.handle_id = handle.ROWID
    LEFT JOIN chat_message_join ON message.ROWID = chat_message_join.message_id
    LEFT JOIN chat ON chat_message_join.chat_id = chat.ROWID
    WHERE chat.chat_identifier = 'UPDATE_THIS_FIELD'
    AND message.text IS NOT NULL
    AND handle.id IS NOT NULL
    AND message.text LIKE '%open.spotify.com%'
    ORDER BY message.date DESC
    LIMIT 5
    ''')

    # Fetch and print results
    for row in cursor.fetchall():
        #print(row) # print total row
        spotify_link = row[3]
        if spotify_link in list_of_spotify_links:
            break
        else:
            list_of_spotify_links.append(spotify_link)
        print(row[3])

    # Close the connection
    conn.close()


while True:
    read_chat_db()
    time.sleep(2)