mirror of
https://github.com/EstrellaXD/Auto_Bangumi.git
synced 2026-04-23 18:11:37 +08:00
feat: add calendar view with Bangumi.tv schedule integration
Add weekly broadcast schedule page showing subscribed anime grouped by day-of-week. Backend fetches air_weekday from Bangumi.tv calendar API and matches titles. Frontend displays responsive grid (desktop) and vertical list (mobile). Edit popup moved to parent layout to fix KeepAlive conflicts, and restyled with purple theme. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
import logging
|
||||
|
||||
from sqlalchemy import inspect, text
|
||||
from sqlmodel import Session, SQLModel
|
||||
|
||||
from module.models import Bangumi, User
|
||||
@@ -9,6 +12,8 @@ from .rss import RSSDatabase
|
||||
from .torrent import TorrentDatabase
|
||||
from .user import UserDatabase
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Database(Session):
|
||||
def __init__(self, engine=e):
|
||||
@@ -21,6 +26,20 @@ class Database(Session):
|
||||
|
||||
def create_table(self):
|
||||
SQLModel.metadata.create_all(self.engine)
|
||||
self._migrate_columns()
|
||||
|
||||
def _migrate_columns(self):
|
||||
"""Add new columns to existing tables if they don't exist."""
|
||||
inspector = inspect(self.engine)
|
||||
if "bangumi" in inspector.get_table_names():
|
||||
columns = [col["name"] for col in inspector.get_columns("bangumi")]
|
||||
if "air_weekday" not in columns:
|
||||
with self.engine.connect() as conn:
|
||||
conn.execute(
|
||||
text("ALTER TABLE bangumi ADD COLUMN air_weekday INTEGER")
|
||||
)
|
||||
conn.commit()
|
||||
logger.info("[Database] Migrated: added air_weekday column to bangumi table.")
|
||||
|
||||
def drop_table(self):
|
||||
SQLModel.metadata.drop_all(self.engine)
|
||||
|
||||
Reference in New Issue
Block a user