chore: Removed SQLite usage
This commit is contained in:
1 parent
1f216a8e8d
commit
35d63c3726
5 files changed
+7
-130
No files matched your search
@@ -5,7 +5,6 @@ from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
|
||||
import db
|
||||
from clients import jellyfin
|
||||
|
||||
app = Flask(__name__)
|
||||
@@ -94,7 +93,6 @@ def index():
|
||||
"JELLYFIN_API_KEY": os.environ.get("JELLYFIN_API_KEY", ""),
|
||||
"JELLYFIN_USER_ID": os.environ.get("JELLYFIN_USER_ID", ""),
|
||||
"TOTAL_EPISODES": os.environ.get("TOTAL_EPISODES", "1155"),
|
||||
"DB_PATH": os.environ.get("DB_PATH", "/app/data/episodes.db"),
|
||||
}
|
||||
latest = get_latest_sunday()
|
||||
previous = get_previous_sunday()
|
||||
@@ -111,10 +109,10 @@ def index():
|
||||
|
||||
@app.route("/api/report")
|
||||
def report():
|
||||
week_start, week_end, _ = current_week() # This is the week range for display (e.g., Feb 15-21)
|
||||
week_start, week_end, _ = current_week()
|
||||
total_episodes = int(os.environ.get("TOTAL_EPISODES", 1155))
|
||||
latest = get_latest_sunday() # e.g., 2026-02-21T16:00:00.000Z
|
||||
previous = get_previous_sunday() # e.g., 2026-02-14T16:00:00.000Z
|
||||
latest = get_latest_sunday()
|
||||
previous = get_previous_sunday()
|
||||
|
||||
jellyfin.clear_debug_logs()
|
||||
|
||||
@@ -135,19 +133,8 @@ def report():
|
||||
prev_ep_info = jellyfin.find_last_one_piece_before_previous_sunday(previous_sunday_dt, user_id)
|
||||
previous_episode = prev_ep_info["episode_number"]
|
||||
except Exception as e:
|
||||
_debug.add(f"✗ Could not find previous Sunday episode: {e}")
|
||||
_debug.add("✓ Falling back to DB seed or latest episode")
|
||||
prev = db.get_previous_episode(week_start.isoformat())
|
||||
previous_episode = prev["episode_number"] if prev else ep_info["episode_number"]
|
||||
|
||||
db.save_episode(
|
||||
episode_number=ep_info["episode_number"],
|
||||
week_start=week_start.isoformat(),
|
||||
week_end=week_end.isoformat(),
|
||||
item_id=ep_info.get("item_id"),
|
||||
media_name=ep_info.get("media_name"),
|
||||
watched_at=ep_info.get("watched_at"),
|
||||
)
|
||||
debug_output = jellyfin.get_debug_logs()
|
||||
return jsonify({"error": f"Could not find previous Sunday episode: {e}", "debug": debug_output}), 502
|
||||
|
||||
watched_this_week = ep_info["episode_number"] - previous_episode
|
||||
|
||||
@@ -179,11 +166,11 @@ def report():
|
||||
|
||||
@app.route("/api/history")
|
||||
def history():
|
||||
return jsonify(db.get_all_history())
|
||||
"""History endpoint removed — SQLite not used anymore. Use Jellyfin ActivityLog directly."""
|
||||
return jsonify({"message": "History tracking via SQLite has been removed. All data is fetched live from Jellyfin."})
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
db.init_db()
|
||||
port = int(os.environ.get("PORT", 5000))
|
||||
app.run(host="0.0.0.0", port=port, debug=False)
|
||||
|
||||
Reference in new issue
Block a user