feat: support categorized archives and selectable quality variants
This commit is contained in:
45 files changed
+932
-92
No files matched your search
@@ -3,6 +3,7 @@ import type {
|
||||
AdminJob,
|
||||
CatalogItem,
|
||||
CatalogPage,
|
||||
CatalogSection,
|
||||
ClientCapabilities,
|
||||
EpisodeItem,
|
||||
LocalizedText,
|
||||
@@ -10,6 +11,7 @@ import type {
|
||||
PlaybackSession,
|
||||
PlaybackState,
|
||||
PlaybackSubtitleTrack,
|
||||
QualityVariant,
|
||||
SeasonItem,
|
||||
TitleDetail,
|
||||
} from '@/types'
|
||||
@@ -67,6 +69,20 @@ function array(value: unknown): unknown[] {
|
||||
return Array.isArray(value) ? value : []
|
||||
}
|
||||
|
||||
function normalizeVariant(input: unknown): QualityVariant {
|
||||
const item = record(input)
|
||||
return {
|
||||
id: text(item.id) ?? '',
|
||||
label: text(item.label) ?? `${number(item.height) ?? 0}p`,
|
||||
...(number(item.width) ? { width: number(item.width) } : {}),
|
||||
...(number(item.height) ? { height: number(item.height) } : {}),
|
||||
...(text(item.videoCodec) ? { videoCodec: text(item.videoCodec) } : {}),
|
||||
compatibility: text(item.compatibility) ?? 'INVALID',
|
||||
available: boolean(item.available),
|
||||
isDefault: boolean(item.isDefault),
|
||||
}
|
||||
}
|
||||
|
||||
function normalizeCatalogItem(input: unknown): CatalogItem {
|
||||
const item = record(input)
|
||||
const metadata = record(item.metadata)
|
||||
@@ -95,6 +111,10 @@ function normalizeCatalogItem(input: unknown): CatalogItem {
|
||||
...(posterUrl ? { posterUrl } : {}),
|
||||
...(backdropUrl ? { backdropUrl } : {}),
|
||||
...(number(item.year ?? metadata.year) !== undefined ? { year: number(item.year ?? metadata.year) } : {}),
|
||||
...(text(item.category) ? { category: text(item.category) } : {}),
|
||||
...(text(item.categorySlug) ? { categorySlug: text(item.categorySlug) } : {}),
|
||||
...(text(item.releaseWindow) ? { releaseWindow: text(item.releaseWindow) } : {}),
|
||||
variants: array(item.variants).map(normalizeVariant).filter((variant) => variant.id),
|
||||
...(number(item.runtimeSeconds ?? item.durationSeconds) !== undefined
|
||||
? { runtimeSeconds: number(item.runtimeSeconds ?? item.durationSeconds) }
|
||||
: {}),
|
||||
@@ -121,6 +141,7 @@ function normalizeEpisode(input: unknown, seasonNumber: number): EpisodeItem {
|
||||
? { durationSeconds: number(item.durationSeconds ?? item.runtimeSeconds) }
|
||||
: {}),
|
||||
published: item.published === undefined ? true : boolean(item.published),
|
||||
variants: array(item.variants).map(normalizeVariant).filter((variant) => variant.id),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,6 +228,8 @@ export function normalizePlaybackSession(input: unknown): PlaybackSession {
|
||||
id,
|
||||
state: normalizeState(payload.state ?? payload.status),
|
||||
mediaItemId: text(payload.mediaItemId) ?? '',
|
||||
...(text(payload.variantId) ? { variantId: text(payload.variantId) } : {}),
|
||||
...(text(payload.qualityLabel) ? { qualityLabel: text(payload.qualityLabel) } : {}),
|
||||
...(manifestUrl ? { manifestUrl } : {}),
|
||||
...(number(payload.durationSeconds ?? payload.duration) !== undefined
|
||||
? { durationSeconds: number(payload.durationSeconds ?? payload.duration) }
|
||||
@@ -270,7 +293,7 @@ function withSignal(signal: AbortSignal | undefined, init: RequestInit = {}): Re
|
||||
}
|
||||
|
||||
export const api = {
|
||||
async catalog(options: { cursor?: string; limit?: number; kind?: string } = {}, signal?: AbortSignal): Promise<CatalogPage> {
|
||||
async catalog(options: { cursor?: string; limit?: number; kind?: string; category?: string; year?: number; releaseWindow?: string } = {}, signal?: AbortSignal): Promise<CatalogPage> {
|
||||
const body = await request(`/catalog${queryString({ ...options })}`, withSignal(signal))
|
||||
const source = record(body)
|
||||
const payload = Object.keys(record(source.data)).length ? record(source.data) : source
|
||||
@@ -284,6 +307,19 @@ export const api = {
|
||||
}
|
||||
},
|
||||
|
||||
async catalogSections(limitPerSection = 12, signal?: AbortSignal): Promise<CatalogSection[]> {
|
||||
const body = record(await request(`/catalog/sections${queryString({ limitPerSection })}`, withSignal(signal)))
|
||||
return array(body.sections).map((input) => {
|
||||
const section = record(input)
|
||||
return {
|
||||
slug: text(section.slug) ?? '',
|
||||
name: text(section.name) ?? text(section.slug) ?? '',
|
||||
items: array(section.items).map(normalizeCatalogItem).filter((item) => item.id),
|
||||
hasMore: boolean(section.hasMore),
|
||||
}
|
||||
}).filter((section) => section.slug && section.items.length)
|
||||
},
|
||||
|
||||
async search(term: string, signal?: AbortSignal): Promise<CatalogPage> {
|
||||
const body = await request(`/search${queryString({ q: term, limit: 40 })}`, withSignal(signal))
|
||||
const source = record(body)
|
||||
@@ -334,11 +370,12 @@ export const api = {
|
||||
async createPlaybackSession(
|
||||
mediaItemId: string,
|
||||
clientCapabilities: ClientCapabilities,
|
||||
variantId?: string,
|
||||
signal?: AbortSignal,
|
||||
): Promise<PlaybackSession> {
|
||||
const body = await request('/playback-sessions', withSignal(signal, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ mediaItemId, clientCapabilities }),
|
||||
body: JSON.stringify({ mediaItemId, ...(variantId ? { variantId } : {}), clientCapabilities }),
|
||||
}))
|
||||
const session = normalizePlaybackSession(body)
|
||||
return { ...session, mediaItemId: session.mediaItemId || mediaItemId }
|
||||
@@ -436,7 +473,7 @@ export const api = {
|
||||
const body = record(await request('/admin/scans', {
|
||||
method: 'POST',
|
||||
headers: { 'x-csrf-token': csrfToken },
|
||||
body: JSON.stringify({ full: false }),
|
||||
body: JSON.stringify({ full: true }),
|
||||
}))
|
||||
const jobId = text(body.id ?? body.jobId ?? record(body.data).jobId)
|
||||
return { ...(jobId ? { jobId } : {}) }
|
||||
|
||||
@@ -14,6 +14,7 @@ const item: CatalogItem = {
|
||||
title: { fa: 'فیلم نمونه', en: 'Sample movie' },
|
||||
overview: {},
|
||||
playable: true,
|
||||
variants: [],
|
||||
year: 2026,
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ function play() {
|
||||
if (!props.item.playable || !props.item.mediaItemId) return
|
||||
player.play({
|
||||
mediaItemId: props.item.mediaItemId,
|
||||
...(props.item.variants.length ? { variants: props.item.variants } : {}),
|
||||
title: title.value,
|
||||
...(props.item.posterUrl ? { posterUrl: props.item.posterUrl } : {}),
|
||||
})
|
||||
|
||||
@@ -36,7 +36,7 @@ const currentTime = ref(0)
|
||||
const duration = ref(0)
|
||||
const buffered = ref(0)
|
||||
const controlsVisible = ref(true)
|
||||
const menu = ref<'subtitles' | 'audio' | null>(null)
|
||||
const menu = ref<'subtitles' | 'audio' | 'quality' | null>(null)
|
||||
const session = ref<PlaybackSession | null>(null)
|
||||
const selectedSubtitle = ref('off')
|
||||
const selectedAudio = ref('')
|
||||
@@ -442,7 +442,17 @@ async function start(request: PlayRequest) {
|
||||
}
|
||||
|
||||
try {
|
||||
const initial = await api.createPlaybackSession(request.mediaItemId, capabilities, requestController.signal)
|
||||
const variants = (request.variants ?? []).filter((variant) => variant.available)
|
||||
const selectedVariant = request.variantId
|
||||
? variants.find((variant) => variant.id === request.variantId)
|
||||
: variants.find((variant) => variant.height === ui.preferences.preferredQualityHeight)
|
||||
?? variants.find((variant) => variant.isDefault)
|
||||
const initial = await api.createPlaybackSession(
|
||||
request.mediaItemId,
|
||||
capabilities,
|
||||
selectedVariant?.id,
|
||||
requestController.signal,
|
||||
)
|
||||
await resolveSession(initial, sequence, requestController.signal)
|
||||
} catch (error) {
|
||||
if ((error as { name?: string }).name === 'AbortError' || sequence !== requestSequence) return
|
||||
@@ -503,11 +513,23 @@ function toggleMute() {
|
||||
void ui.setVolume(element.volume, element.muted)
|
||||
}
|
||||
|
||||
function toggleMenu(target: 'subtitles' | 'audio') {
|
||||
function toggleMenu(target: 'subtitles' | 'audio' | 'quality') {
|
||||
menu.value = menu.value === target ? null : target
|
||||
showControls()
|
||||
}
|
||||
|
||||
async function chooseQuality(variant: NonNullable<PlayRequest['variants']>[number]) {
|
||||
const request = currentRequest.value
|
||||
if (!request || session.value?.variantId === variant.id) {
|
||||
menu.value = null
|
||||
return
|
||||
}
|
||||
await saveProgress(true)
|
||||
if (variant.height) await ui.setPreferredQuality(variant.height)
|
||||
menu.value = null
|
||||
await start({ ...request, variantId: variant.id })
|
||||
}
|
||||
|
||||
function formatTime(seconds: number): string {
|
||||
if (!Number.isFinite(seconds) || seconds < 0) return '00:00'
|
||||
const hours = Math.floor(seconds / 3600)
|
||||
@@ -671,6 +693,20 @@ onBeforeUnmount(() => {
|
||||
|
||||
<span class="control-spacer" />
|
||||
|
||||
<div v-if="currentRequest?.variants?.some((variant) => variant.available)" class="control-menu-wrap">
|
||||
<button class="player-text-button focus-ring" type="button" data-tv-focus @click="toggleMenu('quality')">{{ t('quality') }}</button>
|
||||
<div v-if="menu === 'quality'" class="track-menu">
|
||||
<button
|
||||
v-for="variant in currentRequest.variants.filter((candidate) => candidate.available)"
|
||||
:key="variant.id"
|
||||
type="button"
|
||||
data-tv-focus
|
||||
:class="{ selected: variant.id === session?.variantId }"
|
||||
@click="chooseQuality(variant)"
|
||||
>{{ variant.label }}</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="session?.audioTracks.length" class="control-menu-wrap">
|
||||
<button class="player-text-button focus-ring" type="button" data-tv-focus @click="toggleMenu('audio')">{{ t('audio') }}</button>
|
||||
<div v-if="menu === 'audio'" class="track-menu">
|
||||
|
||||
@@ -61,6 +61,12 @@ const fa = {
|
||||
unavailable: 'ناموجود',
|
||||
unsupported: 'پشتیبانینشده',
|
||||
year: 'سال',
|
||||
quality: 'کیفیت',
|
||||
browse: 'مرور',
|
||||
browseAll: 'مشاهده همه',
|
||||
allYears: 'همه سالها',
|
||||
releaseWindow: 'بازه انتشار',
|
||||
allSeasons: 'همه فصلها',
|
||||
} as const
|
||||
|
||||
const en: Record<keyof typeof fa, string> = {
|
||||
@@ -122,6 +128,12 @@ const en: Record<keyof typeof fa, string> = {
|
||||
unavailable: 'Unavailable',
|
||||
unsupported: 'Unsupported',
|
||||
year: 'Year',
|
||||
quality: 'Quality',
|
||||
browse: 'Browse',
|
||||
browseAll: 'Browse all',
|
||||
allYears: 'All years',
|
||||
releaseWindow: 'Release season',
|
||||
allSeasons: 'All seasons',
|
||||
}
|
||||
|
||||
export type TranslationKey = keyof typeof fa
|
||||
|
||||
@@ -2,6 +2,7 @@ import { createRouter, createWebHistory } from 'vue-router'
|
||||
|
||||
import AdminView from '@/views/AdminView.vue'
|
||||
import CatalogView from '@/views/CatalogView.vue'
|
||||
import BrowseView from '@/views/BrowseView.vue'
|
||||
import SearchView from '@/views/SearchView.vue'
|
||||
import TitleView from '@/views/TitleView.vue'
|
||||
|
||||
@@ -11,6 +12,7 @@ export const router = createRouter({
|
||||
routes: [
|
||||
{ path: '/', name: 'catalog', component: CatalogView },
|
||||
{ path: '/search', name: 'search', component: SearchView },
|
||||
{ path: '/browse/:category', name: 'browse', component: BrowseView },
|
||||
{ path: '/title/:slug', name: 'title', component: TitleView },
|
||||
{ path: '/admin', name: 'admin', component: AdminView },
|
||||
{ path: '/:pathMatch(.*)*', redirect: '/' },
|
||||
|
||||
@@ -18,6 +18,7 @@ describe('viewer storage', () => {
|
||||
audioLanguage: 'ja',
|
||||
volume: 0.7,
|
||||
muted: false,
|
||||
preferredQualityHeight: 1080,
|
||||
})
|
||||
|
||||
await expect(readPreferences()).resolves.toMatchObject({ uiLanguage: 'en', subtitleLanguage: 'en', volume: 0.7 })
|
||||
|
||||
@@ -11,6 +11,7 @@ export const defaultPreferences: ViewerPreferences = {
|
||||
audioLanguage: 'ja',
|
||||
volume: 1,
|
||||
muted: false,
|
||||
preferredQualityHeight: 720,
|
||||
}
|
||||
|
||||
let databasePromise: Promise<IDBDatabase | null> | undefined
|
||||
|
||||
@@ -3,6 +3,8 @@ import { markRaw } from 'vue'
|
||||
|
||||
export interface PlayRequest {
|
||||
mediaItemId: string
|
||||
variantId?: string
|
||||
variants?: import('@/types').QualityVariant[]
|
||||
title: string
|
||||
posterUrl?: string
|
||||
}
|
||||
|
||||
@@ -43,5 +43,10 @@ export const useUiStore = defineStore('ui', {
|
||||
this.preferences.muted = muted
|
||||
await writePreferences({ ...this.preferences })
|
||||
},
|
||||
|
||||
async setPreferredQuality(height: number) {
|
||||
this.preferences.preferredQualityHeight = Math.max(1, Math.round(height))
|
||||
await writePreferences({ ...this.preferences })
|
||||
},
|
||||
},
|
||||
})
|
||||
+46
-1
@@ -39,7 +39,8 @@ body {
|
||||
}
|
||||
|
||||
button,
|
||||
input {
|
||||
input,
|
||||
select {
|
||||
font: inherit;
|
||||
}
|
||||
|
||||
@@ -1356,3 +1357,47 @@ button:disabled,
|
||||
animation-iteration-count: 1 !important;
|
||||
}
|
||||
}
|
||||
|
||||
.section-heading,
|
||||
.browse-header,
|
||||
.browse-filters {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
.category-rail {
|
||||
display: flex;
|
||||
overflow-x: auto;
|
||||
overflow-y: hidden;
|
||||
scroll-snap-type: x proximity;
|
||||
padding-block: .5rem 1rem;
|
||||
}
|
||||
|
||||
.category-rail > * {
|
||||
flex: 0 0 clamp(10rem, 17vw, 15rem);
|
||||
scroll-snap-align: start;
|
||||
}
|
||||
|
||||
.browse-view {
|
||||
padding: 7rem clamp(1rem, 4vw, 4rem) 4rem;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.browse-header { margin-bottom: 2rem; align-items: end; }
|
||||
.browse-header h1 { margin: .25rem 0 0; font-size: clamp(2rem, 5vw, 4rem); }
|
||||
.browse-filters select {
|
||||
min-width: 10rem;
|
||||
padding: .75rem 1rem;
|
||||
color: var(--text);
|
||||
background: var(--panel-raised);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: .8rem;
|
||||
}
|
||||
|
||||
@media (max-width: 700px) {
|
||||
.browse-header { align-items: stretch; flex-direction: column; }
|
||||
.browse-filters { align-items: stretch; }
|
||||
.browse-filters select { min-width: 0; flex: 1; }
|
||||
}
|
||||
@@ -6,6 +6,17 @@ export interface LocalizedText {
|
||||
en?: string | undefined
|
||||
}
|
||||
|
||||
export interface QualityVariant {
|
||||
id: string
|
||||
label: string
|
||||
width?: number | undefined
|
||||
height?: number | undefined
|
||||
videoCodec?: string | undefined
|
||||
compatibility: string
|
||||
available: boolean
|
||||
isDefault: boolean
|
||||
}
|
||||
|
||||
export interface CatalogItem {
|
||||
id: string
|
||||
mediaItemId: string
|
||||
@@ -16,6 +27,10 @@ export interface CatalogItem {
|
||||
posterUrl?: string | undefined
|
||||
backdropUrl?: string | undefined
|
||||
year?: number | undefined
|
||||
category?: string | undefined
|
||||
categorySlug?: string | undefined
|
||||
releaseWindow?: string | undefined
|
||||
variants: QualityVariant[]
|
||||
runtimeSeconds?: number | undefined
|
||||
seasonCount?: number | undefined
|
||||
episodeCount?: number | undefined
|
||||
@@ -34,6 +49,7 @@ export interface EpisodeItem {
|
||||
posterUrl?: string | undefined
|
||||
durationSeconds?: number | undefined
|
||||
published: boolean
|
||||
variants: QualityVariant[]
|
||||
}
|
||||
|
||||
export interface SeasonItem {
|
||||
@@ -54,6 +70,13 @@ export interface CatalogPage {
|
||||
total?: number | undefined
|
||||
}
|
||||
|
||||
export interface CatalogSection {
|
||||
slug: string
|
||||
name: string
|
||||
items: CatalogItem[]
|
||||
hasMore: boolean
|
||||
}
|
||||
|
||||
export type PlaybackState = 'PREPARING' | 'READY' | 'UNSUPPORTED_CLIENT' | 'FAILED'
|
||||
export type SubtitleDelivery = 'ASS_JASSUB' | 'WEBVTT' | 'OFF'
|
||||
|
||||
@@ -79,6 +102,8 @@ export interface PlaybackSession {
|
||||
id: string
|
||||
state: PlaybackState
|
||||
mediaItemId: string
|
||||
variantId?: string | undefined
|
||||
qualityLabel?: string | undefined
|
||||
manifestUrl?: string | undefined
|
||||
durationSeconds?: number | undefined
|
||||
pollAfterMs: number
|
||||
@@ -115,6 +140,7 @@ export interface ViewerPreferences {
|
||||
audioLanguage: string
|
||||
volume: number
|
||||
muted: boolean
|
||||
preferredQualityHeight: number
|
||||
}
|
||||
|
||||
export interface AdminJob {
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
<script setup lang="ts">
|
||||
import { computed, onBeforeUnmount, ref, watch } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import { api } from '@/api/client'
|
||||
import LoadingState from '@/components/LoadingState.vue'
|
||||
import MediaCard from '@/components/MediaCard.vue'
|
||||
import { useSpatialNavigation } from '@/composables/spatial-navigation'
|
||||
import { useI18n } from '@/i18n'
|
||||
import type { CatalogItem } from '@/types'
|
||||
|
||||
const route = useRoute()
|
||||
const root = ref<HTMLElement | null>(null)
|
||||
const items = ref<CatalogItem[]>([])
|
||||
const sourceItems = ref<CatalogItem[]>([])
|
||||
const year = ref('')
|
||||
const releaseWindow = ref('')
|
||||
const loading = ref(true)
|
||||
const error = ref('')
|
||||
let controller: AbortController | undefined
|
||||
const { t } = useI18n()
|
||||
useSpatialNavigation(root, { restoreKey: 'browse-focus' })
|
||||
const category = computed(() => String(route.params.category ?? ''))
|
||||
const categoryName = computed(() => sourceItems.value[0]?.category ?? category.value)
|
||||
const years = computed(() => [...new Set(sourceItems.value.map((item) => item.year).filter((value): value is number => value !== undefined))].sort((a, b) => b - a))
|
||||
const windows = computed(() => [...new Set(sourceItems.value.map((item) => item.releaseWindow).filter((value): value is string => Boolean(value)))])
|
||||
|
||||
async function load() {
|
||||
controller?.abort()
|
||||
controller = new AbortController()
|
||||
loading.value = true
|
||||
error.value = ''
|
||||
try {
|
||||
const page = await api.catalog({
|
||||
category: category.value,
|
||||
limit: 100,
|
||||
...(year.value ? { year: Number(year.value) } : {}),
|
||||
...(releaseWindow.value ? { releaseWindow: releaseWindow.value } : {}),
|
||||
}, controller.signal)
|
||||
items.value = page.items
|
||||
if (!year.value && !releaseWindow.value) sourceItems.value = page.items
|
||||
} catch (reason) {
|
||||
if ((reason as { name?: string }).name !== 'AbortError') error.value = reason instanceof Error ? reason.message : t('networkError')
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
watch([category, year, releaseWindow], () => void load(), { immediate: true })
|
||||
onBeforeUnmount(() => controller?.abort())
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<main ref="root" class="browse-view">
|
||||
<header class="browse-header">
|
||||
<div><p class="eyebrow">{{ t('browse') }}</p><h1>{{ categoryName }}</h1></div>
|
||||
<div class="browse-filters">
|
||||
<select v-model="year" data-tv-focus class="focus-ring" :aria-label="t('year')">
|
||||
<option value="">{{ t('allYears') }}</option>
|
||||
<option v-for="value in years" :key="value" :value="String(value)">{{ value }}</option>
|
||||
</select>
|
||||
<select v-model="releaseWindow" data-tv-focus class="focus-ring" :aria-label="t('releaseWindow')">
|
||||
<option value="">{{ t('allSeasons') }}</option>
|
||||
<option v-for="value in windows" :key="value" :value="value">{{ value }}</option>
|
||||
</select>
|
||||
</div>
|
||||
</header>
|
||||
<LoadingState v-if="loading" :label="t('loadingCatalog')" />
|
||||
<section v-else-if="error" class="center-state error-state"><p>{{ error }}</p></section>
|
||||
<section v-else-if="items.length" class="media-grid">
|
||||
<MediaCard v-for="item in items" :key="item.id" :item="item" />
|
||||
</section>
|
||||
<section v-else class="center-state"><h2>{{ t('emptyCatalog') }}</h2></section>
|
||||
</main>
|
||||
</template>
|
||||
@@ -8,15 +8,16 @@ import { useSpatialNavigation } from '@/composables/spatial-navigation'
|
||||
import { useI18n } from '@/i18n'
|
||||
import { listProgress } from '@/storage/viewer-db'
|
||||
import { usePlayerStore } from '@/stores/player'
|
||||
import type { CatalogItem } from '@/types'
|
||||
import type { CatalogItem, CatalogSection } from '@/types'
|
||||
|
||||
const root = ref<HTMLElement | null>(null)
|
||||
const items = ref<CatalogItem[]>([])
|
||||
const sections = ref<CatalogSection[]>([])
|
||||
const progress = ref<Record<string, number>>({})
|
||||
const loading = ref(true)
|
||||
const error = ref('')
|
||||
const { localize, t } = useI18n()
|
||||
const player = usePlayerStore()
|
||||
const items = computed(() => sections.value.flatMap((section) => section.items))
|
||||
const featured = computed(() => items.value.find((item) => item.playable) ?? items.value[0])
|
||||
const { restoreFocus } = useSpatialNavigation(root, { restoreKey: 'catalog-focus' })
|
||||
|
||||
@@ -25,6 +26,7 @@ function playFeatured() {
|
||||
if (!item?.playable || !item.mediaItemId) return
|
||||
player.play({
|
||||
mediaItemId: item.mediaItemId,
|
||||
...(item.variants.length ? { variants: item.variants } : {}),
|
||||
title: localize(item.title, item.slug),
|
||||
...(item.posterUrl ? { posterUrl: item.posterUrl } : {}),
|
||||
})
|
||||
@@ -34,8 +36,8 @@ async function load() {
|
||||
loading.value = true
|
||||
error.value = ''
|
||||
try {
|
||||
const [catalog, storedProgress] = await Promise.all([api.catalog({ limit: 60 }), listProgress()])
|
||||
items.value = catalog.items
|
||||
const [catalogSections, storedProgress] = await Promise.all([api.catalogSections(12), listProgress()])
|
||||
sections.value = catalogSections
|
||||
progress.value = Object.fromEntries(storedProgress.map((entry) => [
|
||||
entry.mediaItemId,
|
||||
entry.durationSeconds > 0 ? (entry.positionSeconds / entry.durationSeconds) * 100 : 0,
|
||||
@@ -96,11 +98,16 @@ onMounted(() => void load())
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="catalog-section" aria-labelledby="catalog-heading">
|
||||
<h2 id="catalog-heading">{{ t('allTitles') }}</h2>
|
||||
<div class="media-grid">
|
||||
<section v-for="section in sections" :key="section.slug" class="catalog-section">
|
||||
<div class="section-heading">
|
||||
<h2>{{ section.name }}</h2>
|
||||
<RouterLink class="secondary-button focus-ring" data-tv-focus :to="{ name: 'browse', params: { category: section.slug } }">
|
||||
{{ t('browseAll') }}
|
||||
</RouterLink>
|
||||
</div>
|
||||
<div class="media-grid category-rail">
|
||||
<MediaCard
|
||||
v-for="item in items"
|
||||
v-for="item in section.items"
|
||||
:key="item.id"
|
||||
:item="item"
|
||||
:progress="progress[item.mediaItemId]"
|
||||
|
||||
@@ -31,6 +31,7 @@ function playTitle() {
|
||||
if (!detail.value || !mediaItemId) return
|
||||
player.play({
|
||||
mediaItemId,
|
||||
...(detail.value.variants.length ? { variants: detail.value.variants } : {}),
|
||||
title: title.value,
|
||||
...(detail.value.posterUrl ? { posterUrl: detail.value.posterUrl } : {}),
|
||||
})
|
||||
@@ -39,6 +40,7 @@ function playTitle() {
|
||||
function playEpisode(episode: EpisodeItem) {
|
||||
player.play({
|
||||
mediaItemId: episode.mediaItemId,
|
||||
...(episode.variants.length ? { variants: episode.variants } : {}),
|
||||
title: `${title.value} · ${t('episode')} ${episode.number}`,
|
||||
...(episode.posterUrl ? { posterUrl: episode.posterUrl } : {}),
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user