refactor(easel): remove TagUtil

This commit is contained in:
2026-09-08 23:22:05 +03:00
parent f76f33b501
commit fa0edca522
11 changed files with 131 additions and 205 deletions
+7 -11
View File
@@ -7,14 +7,13 @@ from fastapi.responses import HTMLResponse, RedirectResponse
from gallery.easel.core import AppRequest
from gallery.easel.depends.api import api_resolver
from gallery.easel.depends.date import DateDepends
from gallery.easel.depends.schedule import ScheduleApiDepends
from gallery.sketch.bundle import ApiBundle
from gallery.sketch.schedule.api import ScheduleApi
from gallery.sketch.schedule.model import Schedule
from ..common.utils.tag import TagType
from ..common.utils.template import build_templates
from ..depends.tag import TagDepends
from .bundle import GROUP_MAP
from .filters import timedelta_format
@@ -61,10 +60,10 @@ async def get_group_default(group_id: str):
return RedirectResponse(f"{parse.quote(group_id)}/today")
@router.get("/group/{group_id}/{tag}", response_class=HTMLResponse)
async def get_group(request: AppRequest, group_id: str, tag: TagDepends):
@router.get("/group/{group_id}/{date}", response_class=HTMLResponse)
async def get_group(request: AppRequest, group_id: str, date: DateDepends):
channels = GROUP_MAP.get(group_id, [tuple(item.split(":")) for item in group_id.split(",")])
responses = await _get_group_schedule(request.app.state.api, channels, tag.date)
responses = await _get_group_schedule(request.app.state.api, channels, date)
return templates.TemplateResponse(
request=request,
name="group.html",
@@ -77,12 +76,9 @@ async def get_channel_default(channel: str):
return RedirectResponse(f"{channel}/today")
@router.get("/{provider}/{channel}/{tag}", response_class=HTMLResponse)
async def get_channel_tag(request: AppRequest, schedule_api: ScheduleApiDepends, channel: str, tag: TagDepends):
if tag.type == TagType.DAY:
response = await schedule_api.get_schedule(channel, tag.date)
else:
raise ValueError(tag)
@router.get("/{provider}/{channel}/{date}", response_class=HTMLResponse)
async def get_channel(request: AppRequest, schedule_api: ScheduleApiDepends, channel: str, date: DateDepends):
response = await schedule_api.get_schedule(channel, date)
return templates.TemplateResponse(
request=request,
name="channel.html",