added notifications
added freepbx integration as notification source
This commit is contained in:
2
.cache
2
.cache
@@ -1 +1 @@
|
|||||||
{"access_token": "BQALcKusPjd5akQ3U_q5i2tQANIonOR6yv-Ec9WtGBjeip5n22b82jJQRzLHhDxQI8bztKCyuqHmiiY_gA3NUqANrbqZ2ei5cG1DySXnsMIQePD__mvGikehGbfBPHJkmKTTMk2xx56jiN9Xrg2JAtjSnTxckhgT5xqxyKbpZBvQIKEsX14VIDeGgA0ZvRxmrA9n0y67bWer5Lr411k", "token_type": "Bearer", "expires_in": 3600, "scope": "user-library-modify user-library-read user-modify-playback-state user-read-playback-state", "expires_at": 1686382188, "refresh_token": "AQAby3zEGc-H8o8zciCRMZm-O6Gj3FAup6Vb0sRrbtiO48VyMTJMzU4DoJ_wrhk8LmOiN8Hvt0Fb_Ag-09XVEDgQe3VUBDD3HdoMk6aZA1n02VLygxQNMNUQgAGw6oUUdI0"}
|
{"access_token": "BQDochOG-kBM3GV43moO6zgHlLbsleUy9lT5bYHi1bMBm621i-8AMWUjRDimSFAC2bUaRbh-Qv-5DA2DwwT8_hfT93s6CB1kivAESd8q7teETG2wfFFfWSv-bKvyZu5FNvDK8ofekKNy-pYwiKxeUhYuqnpMB2l0-R1ysKkkUgeqiAH3bIXrCn2HaZeya7_zrbA5uN97R38BaE22DIE", "token_type": "Bearer", "expires_in": 3600, "scope": "user-library-modify user-library-read user-modify-playback-state user-read-playback-state", "expires_at": 1689301138, "refresh_token": "AQAby3zEGc-H8o8zciCRMZm-O6Gj3FAup6Vb0sRrbtiO48VyMTJMzU4DoJ_wrhk8LmOiN8Hvt0Fb_Ag-09XVEDgQe3VUBDD3HdoMk6aZA1n02VLygxQNMNUQgAGw6oUUdI0"}
|
||||||
@@ -7,11 +7,11 @@ Control Spotify remotely with a nice and functional touchscreen interface
|
|||||||
|
|
||||||
## Running
|
## Running
|
||||||
- Get a Spotify API Client ID and Secret from the [Spotify Developer Dashboard](https://developer.spotify.com/). Put these in the config.json file.
|
- Get a Spotify API Client ID and Secret from the [Spotify Developer Dashboard](https://developer.spotify.com/). Put these in the config.json file.
|
||||||
- Clone the repository
|
- Install required dependencies
|
||||||
```sh
|
```sh
|
||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
```
|
```
|
||||||
- Configure the env variables
|
- Run
|
||||||
```sh
|
```sh
|
||||||
python spotifycontroller.py
|
python spotifycontroller.py
|
||||||
```
|
```
|
||||||
|
|||||||
30
_notify.py
Normal file
30
_notify.py
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
import tkinter as ttk
|
||||||
|
from tkinter import ttk as tk
|
||||||
|
from tkinter import PhotoImage
|
||||||
|
import os
|
||||||
|
import sv_ttk
|
||||||
|
|
||||||
|
def draw(cid, num, img, title="Notification"):
|
||||||
|
root = ttk.Tk()
|
||||||
|
root.title(title)
|
||||||
|
root.geometry("1280x50")
|
||||||
|
root.attributes("-topmost", True)
|
||||||
|
if os.name == 'posix':
|
||||||
|
root.overrideredirect(1)
|
||||||
|
try:
|
||||||
|
sv_ttk.use_dark_theme()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
phone = PhotoImage(file=img)
|
||||||
|
phone_image = tk.Label(root, image=phone)
|
||||||
|
cid_label = tk.Label(root, text=cid, font=("Arial", 32))
|
||||||
|
num_label = tk.Label(root, text=num, font=("Arial", 32))
|
||||||
|
|
||||||
|
phone_image.grid(row=0, column=0, padx=10)
|
||||||
|
cid_label.grid(row=0, column=1, padx=10)
|
||||||
|
num_label.grid(row=0, column=2, padx=10)
|
||||||
|
|
||||||
|
root.after(15000, lambda: root.destroy())
|
||||||
|
|
||||||
|
root.mainloop()
|
||||||
24
freepbx.py
Normal file
24
freepbx.py
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
from flask import Flask, request
|
||||||
|
import threading
|
||||||
|
from _notify import draw
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
@app.route('/hook', methods=['GET'])
|
||||||
|
def wait_for_call():
|
||||||
|
# Get information from URL variables
|
||||||
|
num = request.args.get('num')
|
||||||
|
cid = request.args.get('CID')
|
||||||
|
img = "phone.png"
|
||||||
|
|
||||||
|
# Process the received information (you can customize this part)
|
||||||
|
print(f"Received param1: {num}")
|
||||||
|
print(f"Received param2: {cid}")
|
||||||
|
# Add more processing logic as needed
|
||||||
|
threading.Thread(target=draw, args=(cid, num, img)).start()
|
||||||
|
|
||||||
|
# Respond to the webhook request (optional)
|
||||||
|
return 'Webhook received successfully!', 200
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
app.run(host='0.0.0.0', port=5000)
|
||||||
BIN
phone_orig.png
Normal file
BIN
phone_orig.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.5 KiB |
@@ -210,26 +210,29 @@ def get_devices():
|
|||||||
# unloadDevices_list()
|
# unloadDevices_list()
|
||||||
# loadSleep()
|
# loadSleep()
|
||||||
# root.after(3600, get_devices)
|
# root.after(3600, get_devices)
|
||||||
if spotify.current_playback() != None:
|
try:
|
||||||
count = 0
|
if spotify.current_playback() != None:
|
||||||
# unloadSearching_Devices()
|
count = 0
|
||||||
unloadDevices_list()
|
# unloadSearching_Devices()
|
||||||
loadNow_playing()
|
unloadDevices_list()
|
||||||
root.after(800, update_song_label)
|
loadNow_playing()
|
||||||
else:
|
root.after(800, update_song_label)
|
||||||
count += 1
|
|
||||||
if count > 420:
|
|
||||||
kill(kill=sleep)
|
|
||||||
# unloadSearching_Devices()
|
|
||||||
# loadDevices_list()
|
|
||||||
else:
|
else:
|
||||||
devices_list.delete(0, ttk.END)
|
count += 1
|
||||||
list_of_devices = spotify.devices()
|
if count > 420:
|
||||||
for num_of_device, garbage in enumerate(list_of_devices["devices"]):
|
kill(kill=sleep)
|
||||||
# exec(f'dev_{num_of_device} = tk.Button(root, text=list_of_devices["devices"][num_of_device]["name"], command=start_playback_on_device(device_id=num_of_device))')
|
# unloadSearching_Devices()
|
||||||
# exec(f'dev_{num_of_device}.grid(row={num_of_device}, column=1)')
|
# loadDevices_list()
|
||||||
devices_list.insert(num_of_device, list_of_devices["devices"][num_of_device]["name"])
|
else:
|
||||||
root.after(8500, get_devices)
|
devices_list.delete(0, ttk.END)
|
||||||
|
list_of_devices = spotify.devices()
|
||||||
|
for num_of_device, garbage in enumerate(list_of_devices["devices"]):
|
||||||
|
# exec(f'dev_{num_of_device} = tk.Button(root, text=list_of_devices["devices"][num_of_device]["name"], command=start_playback_on_device(device_id=num_of_device))')
|
||||||
|
# exec(f'dev_{num_of_device}.grid(row={num_of_device}, column=1)')
|
||||||
|
devices_list.insert(num_of_device, list_of_devices["devices"][num_of_device]["name"])
|
||||||
|
root.after(8500, get_devices)
|
||||||
|
except:
|
||||||
|
root.after(5000, get_devices)
|
||||||
|
|
||||||
# def wakeup():
|
# def wakeup():
|
||||||
# global count
|
# global count
|
||||||
@@ -563,6 +566,7 @@ def unloadNow_playing():
|
|||||||
song_label.grid_forget()
|
song_label.grid_forget()
|
||||||
previous_button.grid_forget()
|
previous_button.grid_forget()
|
||||||
play_button.grid_forget()
|
play_button.grid_forget()
|
||||||
|
pause_button.grid_forget()
|
||||||
next_button.grid_forget()
|
next_button.grid_forget()
|
||||||
progress_bar.grid_forget()
|
progress_bar.grid_forget()
|
||||||
lyrics_label.grid_forget()
|
lyrics_label.grid_forget()
|
||||||
|
|||||||
12
update.py
12
update.py
@@ -6,7 +6,8 @@ from time import sleep
|
|||||||
import subprocess
|
import subprocess
|
||||||
from pynput import mouse
|
from pynput import mouse
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from os import name, path, remove, system
|
from os import name, path, remove, system, kill, popen
|
||||||
|
import signal
|
||||||
|
|
||||||
|
|
||||||
# while True:
|
# while True:
|
||||||
@@ -53,7 +54,16 @@ while True:
|
|||||||
except urllib.error.HTTPError:
|
except urllib.error.HTTPError:
|
||||||
print("No update available.")
|
print("No update available.")
|
||||||
pass
|
pass
|
||||||
|
for line in popen("ps ax | grep " + "web.py" + " | grep -v grep"):
|
||||||
|
fields = line.split()
|
||||||
|
pid = fields[0]
|
||||||
|
kill(int(pid), signal.SIGKILL)
|
||||||
subprocess.Popen(['python3', 'web/web.py'])
|
subprocess.Popen(['python3', 'web/web.py'])
|
||||||
|
for line in popen("ps ax | grep " + "freepbx.py" + " | grep -v grep"):
|
||||||
|
fields = line.split()
|
||||||
|
pid = fields[0]
|
||||||
|
kill(int(pid), signal.SIGKILL)
|
||||||
|
subprocess.Popen(['python3', 'freepbx.py'])
|
||||||
subprocess.check_call(['python3', 'spotifycontroller.py'])
|
subprocess.check_call(['python3', 'spotifycontroller.py'])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if e.args[0] == 1:
|
if e.args[0] == 1:
|
||||||
|
|||||||
BIN
update.zip
Normal file
BIN
update.zip
Normal file
Binary file not shown.
Reference in New Issue
Block a user