2018-10-31 19:34:40 +00:00
|
|
|
# coding=utf-8
|
2018-10-04 18:16:49 +00:00
|
|
|
|
|
|
|
import os
|
|
|
|
import sqlite3
|
|
|
|
import time
|
|
|
|
|
2018-10-31 19:34:40 +00:00
|
|
|
from get_args import args
|
|
|
|
|
|
|
|
|
2018-10-04 18:16:49 +00:00
|
|
|
def history_log(action, sonarrSeriesId, sonarrEpisodeId, description):
|
|
|
|
# Open database connection
|
2018-10-31 19:34:40 +00:00
|
|
|
db = sqlite3.connect(os.path.join(args.config_dir, 'db', 'bazarr.db'), timeout=30)
|
2018-10-04 18:16:49 +00:00
|
|
|
c = db.cursor()
|
|
|
|
|
|
|
|
# Get Sonarr API URL from database config table
|
2018-10-31 19:34:40 +00:00
|
|
|
history = c.execute(
|
|
|
|
'''INSERT INTO table_history(action, sonarrSeriesId, sonarrEpisodeId, timestamp, description) VALUES (?, ?, ?, ?, ?)''',
|
|
|
|
(action, sonarrSeriesId, sonarrEpisodeId, time.time(), description))
|
2018-10-04 18:16:49 +00:00
|
|
|
|
|
|
|
# Commit changes to DB
|
|
|
|
db.commit()
|
2018-10-31 19:34:40 +00:00
|
|
|
|
2018-10-04 18:16:49 +00:00
|
|
|
# Close database connection
|
|
|
|
db.close()
|
|
|
|
|
|
|
|
|
|
|
|
def history_log_movie(action, radarrId, description):
|
|
|
|
# Open database connection
|
2018-10-31 19:34:40 +00:00
|
|
|
db = sqlite3.connect(os.path.join(args.config_dir, 'db', 'bazarr.db'), timeout=30)
|
2018-10-04 18:16:49 +00:00
|
|
|
c = db.cursor()
|
|
|
|
|
2018-10-31 19:34:40 +00:00
|
|
|
history = c.execute(
|
|
|
|
'''INSERT INTO table_history_movie(action, radarrId, timestamp, description) VALUES (?, ?, ?, ?)''',
|
|
|
|
(action, radarrId, time.time(), description))
|
2018-10-04 18:16:49 +00:00
|
|
|
|
|
|
|
# Commit changes to DB
|
|
|
|
db.commit()
|
|
|
|
|
|
|
|
# Close database connection
|
|
|
|
db.close()
|