feat(shcedule): add channels list
This commit is contained in:
@@ -32,12 +32,35 @@ def mount(app: FastAPI):
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@app.get("/schedule/tag/{tag}", response_class=HTMLResponse)
|
||||||
|
async def get_schedule_tag(request: Request, tag: str, live: bool = False):
|
||||||
|
tag_value = TagUtil.parse_tag(tag)
|
||||||
|
schedule_api: ScheduleApi = request.app.state.schedule_api
|
||||||
|
channels = await schedule_api.get_channels()
|
||||||
|
responses = [
|
||||||
|
await schedule_api.get_channel_schedule(channel, tag_value.date)
|
||||||
|
for channel in channels
|
||||||
|
]
|
||||||
|
return templates.TemplateResponse(
|
||||||
|
request=request,
|
||||||
|
name="schedule.html",
|
||||||
|
context={
|
||||||
|
"version": __version__,
|
||||||
|
"tag_util": TagUtil,
|
||||||
|
"datetime": datetime,
|
||||||
|
"channels": channels,
|
||||||
|
"response": responses[0],
|
||||||
|
"responses": responses,
|
||||||
|
"live": live,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
@app.get("/schedule/{channel}", response_class=RedirectResponse)
|
@app.get("/schedule/{channel}", response_class=RedirectResponse)
|
||||||
async def get_schedule_default(channel: str):
|
async def get_channel_default(channel: str):
|
||||||
return RedirectResponse(f"{channel}/tag/today")
|
return RedirectResponse(f"{channel}/tag/today")
|
||||||
|
|
||||||
@app.get("/schedule/{channel}/tag/{tag}", response_class=HTMLResponse)
|
@app.get("/schedule/{channel}/tag/{tag}", response_class=HTMLResponse)
|
||||||
async def get_schedule_tag(request: Request, channel: str, tag: str):
|
async def get_channel_tag(request: Request, channel: str, tag: str):
|
||||||
tag_value = TagUtil.parse_tag(tag)
|
tag_value = TagUtil.parse_tag(tag)
|
||||||
schedule_api: ScheduleApi = request.app.state.schedule_api
|
schedule_api: ScheduleApi = request.app.state.schedule_api
|
||||||
if tag_value.type == TagType.DAY:
|
if tag_value.type == TagType.DAY:
|
||||||
@@ -46,7 +69,7 @@ def mount(app: FastAPI):
|
|||||||
raise ValueError(tag)
|
raise ValueError(tag)
|
||||||
return templates.TemplateResponse(
|
return templates.TemplateResponse(
|
||||||
request=request,
|
request=request,
|
||||||
name="schedule.html",
|
name="channel.html",
|
||||||
context={
|
context={
|
||||||
"version": __version__,
|
"version": __version__,
|
||||||
"tag_util": TagUtil,
|
"tag_util": TagUtil,
|
||||||
|
|||||||
@@ -5,3 +5,10 @@ td {
|
|||||||
tr.live {
|
tr.live {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.title {
|
||||||
|
margin-top: 0.5rem;
|
||||||
|
font-style: italic;
|
||||||
|
font-weight: bold;
|
||||||
|
font-size: 120%;
|
||||||
|
}
|
||||||
|
|||||||
51
gallery/easel/route/view/schedule/templates/channel.html
Normal file
51
gallery/easel/route/view/schedule/templates/channel.html
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport"
|
||||||
|
content="width=device-width, initial-scale=1.0">
|
||||||
|
<meta http-equiv="X-UA-Compatible"
|
||||||
|
content="ie=edge">
|
||||||
|
<title>Программа | {{response.channel.name}} | {{response.date.strftime('%a, %d %B %Y')}}</title>
|
||||||
|
<link rel="stylesheet"
|
||||||
|
href="/static/common/style.css?v={{version}}">
|
||||||
|
<link rel="stylesheet"
|
||||||
|
href="/static/schedule/style.css?v={{version}}">
|
||||||
|
<link rel="icon"
|
||||||
|
href="/static/common/favicon.ico"
|
||||||
|
type="image/x-icon">
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body class="app-container">
|
||||||
|
<h3>
|
||||||
|
<a class="button {{'disabled' if response.date == datetime.date.today() else ''}}"
|
||||||
|
href="../tag/{{tag_util.create_tag('day', response.date, -1)}}">⬅️</a>
|
||||||
|
<a class="button"
|
||||||
|
href="../..">⬆️</a>
|
||||||
|
<span>{{response.channel.name}} | {{response.date.strftime('%a, %d %B %Y')}}</span>
|
||||||
|
<a class="button"
|
||||||
|
href="../tag/{{tag_util.create_tag('day', response.date, 1)}}">➡️</a>
|
||||||
|
</h3>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for value in response.values %}
|
||||||
|
<tr class="{{'live' if value.live else ''}}">
|
||||||
|
<td>{{value.start.strftime('%H:%M')}}</td>
|
||||||
|
<td>{{(value.end - value.start) | timedelta_format}}</td>
|
||||||
|
<td>{{value.label}}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
content="width=device-width, initial-scale=1.0">
|
content="width=device-width, initial-scale=1.0">
|
||||||
<meta http-equiv="X-UA-Compatible"
|
<meta http-equiv="X-UA-Compatible"
|
||||||
content="ie=edge">
|
content="ie=edge">
|
||||||
<title>Программа | {{response.channel.name}} | {{response.date.strftime('%a, %d %B %Y')}}</title>
|
<title>ТВ</title>
|
||||||
<link rel="stylesheet"
|
<link rel="stylesheet"
|
||||||
href="/static/common/style.css?v={{version}}">
|
href="/static/common/style.css?v={{version}}">
|
||||||
<link rel="stylesheet"
|
<link rel="stylesheet"
|
||||||
@@ -23,12 +23,12 @@
|
|||||||
href="../tag/{{tag_util.create_tag('day', response.date, -1)}}">⬅️</a>
|
href="../tag/{{tag_util.create_tag('day', response.date, -1)}}">⬅️</a>
|
||||||
<a class="button"
|
<a class="button"
|
||||||
href="../..">⬆️</a>
|
href="../..">⬆️</a>
|
||||||
<span>{{response.channel.name}} | {{response.date.strftime('%a, %d %B %Y')}}</span>
|
<span>Прямые трансляции | {{response.date.strftime('%a, %d %B %Y')}}</span>
|
||||||
<a class="button"
|
<a class="button"
|
||||||
href="../tag/{{tag_util.create_tag('day', response.date, 1)}}">➡️</a>
|
href="../tag/{{tag_util.create_tag('day', response.date, 1)}}">➡️</a>
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
<table>
|
<table class="{{'live' if live else ''}}">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<td></td>
|
<td></td>
|
||||||
@@ -37,13 +37,25 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{% for value in response.values %}
|
{% for response in responses %}
|
||||||
<tr class="{{'live' if value.live else ''}}">
|
{% set values = (response.values|selectattr('live') if live else response.values)|list %}
|
||||||
|
{% if values|length > 0 %}
|
||||||
|
<tr>
|
||||||
|
<td colspan="3">
|
||||||
|
<div class="title">{{response.channel.name}}</div>
|
||||||
|
</td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
{% for value in values %}
|
||||||
|
<tr class="{{'live' if not live and value.live else ''}}">
|
||||||
<td>{{value.start.strftime('%H:%M')}}</td>
|
<td>{{value.start.strftime('%H:%M')}}</td>
|
||||||
<td>{{(value.end - value.start) | timedelta_format}}</td>
|
<td>{{(value.end - value.start) | timedelta_format}}</td>
|
||||||
<td>{{value.label}}</td>
|
<td>{{value.label}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -17,9 +17,9 @@ CHANNEL_LIST = [
|
|||||||
"arena",
|
"arena",
|
||||||
"futbol-1",
|
"futbol-1",
|
||||||
"futbol-2",
|
"futbol-2",
|
||||||
"futbol-2",
|
"futbol-3",
|
||||||
"strana",
|
"strana",
|
||||||
"planeta",
|
# "planeta",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user