This repository was archived by the owner on Apr 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathradarr.py
More file actions
41 lines (35 loc) · 1.42 KB
/
radarr.py
File metadata and controls
41 lines (35 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from os import environ, path
from backend import constants
import sqlite3
import datetime
import socket
# Path to the database
db_path = path.realpath(path.dirname(path.realpath(__file__)))+"/"+constants.DB_FILE
#Open the connection to the database
db = sqlite3.connect(db_path)
db_cursor = db.cursor()
# Get all the values from Radarr
tmdb_id = environ.get('radarr_movie_tmdbid')
movie_title = environ.get('radarr_movie_title')
quality = environ.get('radarr_moviefile_quality')
quality_version = environ.get('radarr_moviefile_qualityversion')
if(environ.get('radarr_isupgrade') == "True"):
is_upgrade = 1
else:
is_upgrade = 0
download_time = datetime.datetime.utcnow().timestamp()
metadata_id = str(tmdb_id)+";"+str(constants.NOTIFIER_MEDIA_TYPE_MOVIE)+";"+str(download_time)
# Insert the data into the metadata_movies table in the database
db_cursor.execute("""INSERT OR IGNORE INTO metadata_movies
(metadata_id, tmdb_id, movie_title, quality, quality_version, is_upgrade, download_time)
VALUES
(?, ?, ?, ?, ?, ?, ?)
""", (metadata_id, tmdb_id, movie_title, quality, quality_version, is_upgrade, download_time))
# Commit the changes and close the database
db.commit()
db.close()
# Send the metadata_id to the bot so it can send out notifications
client_socket = socket.socket()
client_socket.connect((constants.SOCKET_HOST, int(constants.SOCKET_PORT)))
client_socket.send(metadata_id.encode('utf-8'))
client_socket.close()