mirror of
https://github.com/WonderAliceUwU/OmniArr.git
synced 2026-11-22 03:35:56 +00:00
feature: add per chapter download
This commit is contained in:
1 parent
9c836201ea
commit
79c8072318
6 files changed
+278
-35
No files matched your search
+109
-18
@@ -574,7 +574,6 @@ function AuthScreen({
|
||||
<div className={isSetup ? 'auth-layout' : 'auth-layout auth-layout-login'}>
|
||||
<section className={isSetup ? 'auth-panel' : 'auth-panel auth-panel-login'}>
|
||||
<div className="auth-panel-shell">
|
||||
<p className="eyebrow">{isSetup ? 'First boot' : 'Secure access'}</p>
|
||||
<h1>{isSetup ? 'Create your master password' : 'Sign in to OmniArr'}</h1>
|
||||
<p className="auth-copy">
|
||||
{isSetup
|
||||
@@ -1048,6 +1047,7 @@ function TitleDetailsModal(props: {
|
||||
const [detailsError, setDetailsError] = useState('')
|
||||
const [activeSeasonId, setActiveSeasonId] = useState<string | undefined>(undefined)
|
||||
const [episodeWatchBusyId, setEpisodeWatchBusyId] = useState<string | null>(null)
|
||||
const [episodeDownloadBusyId, setEpisodeDownloadBusyId] = useState<string | null>(null)
|
||||
const [seasonActionBusy, setSeasonActionBusy] = useState<'download' | 'delete' | null>(null)
|
||||
const [playerTarget, setPlayerTarget] = useState<{ id: string; title: string } | null>(null)
|
||||
const [isOverviewExpanded, setIsOverviewExpanded] = useState(false)
|
||||
@@ -1110,6 +1110,7 @@ function TitleDetailsModal(props: {
|
||||
setDetailsError('')
|
||||
setActiveSeasonId(undefined)
|
||||
setEpisodeWatchBusyId(null)
|
||||
setEpisodeDownloadBusyId(null)
|
||||
setSeasonActionBusy(null)
|
||||
setPlayerTarget(null)
|
||||
setIsOverviewExpanded(false)
|
||||
@@ -1340,6 +1341,28 @@ function TitleDetailsModal(props: {
|
||||
}
|
||||
}, [activeSeasonDownloadStatus, details, seasonValue])
|
||||
|
||||
useEffect(() => {
|
||||
if (!details || details.mediaType !== 'series') {
|
||||
return
|
||||
}
|
||||
|
||||
const hasEpisodeTransfers = details.episodes.some((episode) =>
|
||||
episode.downloadStatus === 'processing' || episode.downloadStatus === 'downloading'
|
||||
)
|
||||
|
||||
if (!hasEpisodeTransfers) {
|
||||
return
|
||||
}
|
||||
|
||||
const timeoutId = window.setTimeout(() => {
|
||||
void refreshSeasonState(seasonValue || undefined)
|
||||
}, 2500)
|
||||
|
||||
return () => {
|
||||
window.clearTimeout(timeoutId)
|
||||
}
|
||||
}, [details, seasonValue])
|
||||
|
||||
function handleRequestClose() {
|
||||
if (!props.originRect || transitionState === 'closing') {
|
||||
props.onClose()
|
||||
@@ -1466,6 +1489,42 @@ function TitleDetailsModal(props: {
|
||||
}
|
||||
}
|
||||
|
||||
function handleEpisodeDownload(
|
||||
event: MouseEvent<HTMLButtonElement>,
|
||||
episodeId: string,
|
||||
sonarrEpisodeId: number | undefined,
|
||||
availability: TitleDetailsResponse['episodes'][number]['availability']
|
||||
) {
|
||||
event.preventDefault()
|
||||
event.stopPropagation()
|
||||
|
||||
if (!sonarrEpisodeId || availability === 'downloading' || episodeDownloadBusyId === episodeId) {
|
||||
return
|
||||
}
|
||||
|
||||
setEpisodeDownloadBusyId(episodeId)
|
||||
updateEpisodeInCaches(episodeId, (episode) => ({
|
||||
...episode,
|
||||
downloadStatus: 'processing',
|
||||
downloadProgress: undefined,
|
||||
canDownload: false,
|
||||
}))
|
||||
|
||||
void api.requestEpisode({ episodeId: sonarrEpisodeId })
|
||||
.catch(() => {
|
||||
updateEpisodeInCaches(episodeId, (episode) => ({
|
||||
...episode,
|
||||
availability,
|
||||
downloadStatus: 'idle',
|
||||
downloadProgress: undefined,
|
||||
canDownload: availability === 'missing',
|
||||
}))
|
||||
})
|
||||
.finally(() => {
|
||||
setEpisodeDownloadBusyId((current) => current === episodeId ? null : current)
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={transitionState === 'closing' ? 'modal-backdrop is-closing' : 'modal-backdrop'} onClick={handleRequestClose} role="presentation">
|
||||
<div
|
||||
@@ -1606,16 +1665,17 @@ function TitleDetailsModal(props: {
|
||||
activeSeasonDownloadStatus === 'downloading' ? (
|
||||
<div
|
||||
aria-label="Season downloading"
|
||||
className="title-season-progress"
|
||||
role="img"
|
||||
title={activeSeasonMeta?.downloadLabel || 'Downloading'}
|
||||
>
|
||||
<div
|
||||
className="title-season-progress-bar"
|
||||
style={{ width: `${activeSeasonMeta?.downloadProgress || 0}%` }}
|
||||
/>
|
||||
</div>
|
||||
) : activeSeasonDownloadStatus === 'processing' ? (
|
||||
className="title-season-progress"
|
||||
role="img"
|
||||
title={activeSeasonMeta?.downloadLabel || 'Downloading'}
|
||||
>
|
||||
<span
|
||||
className="title-season-progress-ring"
|
||||
style={{ ['--season-download-progress' as '--season-download-progress']: `${activeSeasonMeta?.downloadProgress || 0}` }}
|
||||
/>
|
||||
<span className="title-season-progress-percent">{`${activeSeasonMeta?.downloadProgress || 0}%`}</span>
|
||||
</div>
|
||||
) : activeSeasonDownloadStatus === 'processing' ? (
|
||||
<div
|
||||
aria-label="Season processing"
|
||||
className="title-season-processing"
|
||||
@@ -1735,15 +1795,45 @@ function TitleDetailsModal(props: {
|
||||
<div className="episode-card-title-row">
|
||||
<strong>{episode.title}</strong>
|
||||
<div className="episode-card-state-icons">
|
||||
{episode.canDownload || episode.availability === 'downloading' ? (
|
||||
{episode.canDownload || episode.downloadStatus === 'processing' || episode.downloadStatus === 'downloading' ? (
|
||||
episode.downloadStatus === 'downloading' ? (
|
||||
<span
|
||||
aria-label={episode.availability === 'downloading' ? 'Episode downloading' : 'Episode available to download'}
|
||||
className={episode.availability === 'downloading' ? 'episode-card-availability is-downloading' : 'episode-card-availability'}
|
||||
title={episode.availability === 'downloading' ? 'Downloading' : 'Available to download'}
|
||||
aria-label="Episode downloading"
|
||||
className="episode-card-availability-progress"
|
||||
title={`${episode.downloadProgress || 0}% downloaded`}
|
||||
>
|
||||
<span
|
||||
className="episode-card-availability-ring"
|
||||
style={{ ['--episode-download-progress' as '--episode-download-progress']: `${episode.downloadProgress || 0}` }}
|
||||
/>
|
||||
<span className="episode-card-availability-percent">{`${episode.downloadProgress || 0}%`}</span>
|
||||
</span>
|
||||
) : episode.downloadStatus === 'processing' ? (
|
||||
<span
|
||||
aria-label="Episode processing"
|
||||
className="episode-card-availability-processing"
|
||||
title="Processing"
|
||||
>
|
||||
<span className="episode-card-processing-spinner" aria-hidden="true" />
|
||||
</span>
|
||||
) : (
|
||||
<button
|
||||
aria-label="Download episode"
|
||||
className="episode-card-availability episode-card-availability-button"
|
||||
disabled={episodeDownloadBusyId === episode.id}
|
||||
onClick={(event) => handleEpisodeDownload(
|
||||
event,
|
||||
episode.id,
|
||||
episode.sonarrEpisodeId,
|
||||
episode.availability
|
||||
)}
|
||||
title="Available to download"
|
||||
type="button"
|
||||
>
|
||||
<DownloadGlyph />
|
||||
</span>
|
||||
) : null}
|
||||
</button>
|
||||
)
|
||||
) : null}
|
||||
{episode.availableInJellyfin ? (
|
||||
<button
|
||||
aria-label={episode.watched ? 'Mark episode as unwatched' : 'Mark episode as watched'}
|
||||
@@ -1971,7 +2061,7 @@ function DownloadRow(props: {
|
||||
</div>
|
||||
<button
|
||||
aria-label={`Delete ${item.title}`}
|
||||
className="download-delete-button"
|
||||
className="download-action-button download-delete-button"
|
||||
disabled={props.busy}
|
||||
onClick={confirmDelete}
|
||||
type="button"
|
||||
@@ -1987,6 +2077,7 @@ function DownloadRow(props: {
|
||||
|
||||
function humanizeDownloadState(state: string) {
|
||||
return state
|
||||
.replace(/([a-z])([A-Z])/g, '$1 $2')
|
||||
.replace(/[_-]+/g, ' ')
|
||||
.replace(/\b\w/g, (match) => match.toUpperCase())
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import type {
|
||||
ServiceOptionsResponse,
|
||||
SessionResponse,
|
||||
EpisodeWatchStateRequest,
|
||||
EpisodeRequestPayload,
|
||||
SeasonDeletePayload,
|
||||
SeasonRequestPayload,
|
||||
TitleDetailsRequest,
|
||||
@@ -112,6 +113,11 @@ export const api = {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(payload),
|
||||
}),
|
||||
requestEpisode: (payload: EpisodeRequestPayload) =>
|
||||
request<{ ok: boolean }>('/api/requests/episode', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(payload),
|
||||
}),
|
||||
deleteSeason: (payload: SeasonDeletePayload) =>
|
||||
request<{ ok: boolean }>('/api/seasons/delete', {
|
||||
method: 'POST',
|
||||
|
||||
+85
-15
@@ -1783,25 +1783,26 @@ img {
|
||||
}
|
||||
|
||||
.title-season-progress {
|
||||
width: 2.5rem;
|
||||
gap: 0.48rem;
|
||||
min-width: 4.1rem;
|
||||
}
|
||||
|
||||
.title-season-progress::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
height: 0.28rem;
|
||||
.title-season-progress-ring {
|
||||
--season-download-progress: 0;
|
||||
width: 1.7rem;
|
||||
height: 1.7rem;
|
||||
border-radius: 999px;
|
||||
background: rgba(255, 255, 255, 0.12);
|
||||
background:
|
||||
radial-gradient(circle at center, #090b10 48%, transparent 50%),
|
||||
conic-gradient(#ffffff calc(var(--season-download-progress) * 1%), rgba(255, 255, 255, 0.14) 0);
|
||||
}
|
||||
|
||||
.title-season-progress-bar {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
height: 0.28rem;
|
||||
border-radius: 999px;
|
||||
background: #e50914;
|
||||
.title-season-progress-percent {
|
||||
color: #eef4ff;
|
||||
font-size: 0.74rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.04em;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.episode-dock {
|
||||
@@ -2092,6 +2093,12 @@ img {
|
||||
opacity: 0.88;
|
||||
}
|
||||
|
||||
.episode-card-availability-button {
|
||||
padding: 0;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.episode-card-availability .title-action-icon {
|
||||
width: 0.98rem;
|
||||
height: 0.98rem;
|
||||
@@ -2101,6 +2108,58 @@ img {
|
||||
animation: episodeCardAvailabilityPulse 900ms ease-in-out infinite alternate;
|
||||
}
|
||||
|
||||
.episode-card-availability-processing {
|
||||
display: inline-grid;
|
||||
place-items: center;
|
||||
width: 1.55rem;
|
||||
height: 1.55rem;
|
||||
}
|
||||
|
||||
.episode-card-processing-spinner {
|
||||
width: 1rem;
|
||||
height: 1rem;
|
||||
border: 2px solid rgba(255, 255, 255, 0.18);
|
||||
border-top-color: rgba(255, 255, 255, 0.88);
|
||||
border-radius: 999px;
|
||||
animation: episodeDockSpinner 720ms linear infinite;
|
||||
}
|
||||
|
||||
.episode-card-availability-progress {
|
||||
position: relative;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
min-width: 0;
|
||||
color: rgba(244, 247, 255, 0.9);
|
||||
}
|
||||
|
||||
.episode-card-availability-ring {
|
||||
--episode-download-progress: 0;
|
||||
width: 1.2rem;
|
||||
height: 1.2rem;
|
||||
border-radius: 999px;
|
||||
background:
|
||||
radial-gradient(circle at center, #090b10 46%, transparent 48%),
|
||||
conic-gradient(#ffffff calc(var(--episode-download-progress) * 1%), rgba(255, 255, 255, 0.14) 0);
|
||||
}
|
||||
|
||||
.episode-card-availability-percent {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: calc(100% + 0.28rem);
|
||||
transform: translateX(-50%);
|
||||
opacity: 0;
|
||||
font-size: 0.66rem;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.04em;
|
||||
white-space: nowrap;
|
||||
transition: opacity 160ms ease;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.episode-card-availability-progress:hover .episode-card-availability-percent {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.episode-card-watch-toggle svg {
|
||||
width: 1rem;
|
||||
height: 1rem;
|
||||
@@ -2419,13 +2478,24 @@ img {
|
||||
gap: 0.8rem;
|
||||
}
|
||||
|
||||
.download-delete-button {
|
||||
.download-action-button {
|
||||
width: 1.9rem;
|
||||
height: 1.9rem;
|
||||
border: 0;
|
||||
border-radius: 999px;
|
||||
background: rgba(255, 255, 255, 0.07);
|
||||
color: #dbe2ee;
|
||||
display: inline-grid;
|
||||
place-items: center;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.download-action-button .title-action-icon {
|
||||
width: 0.92rem;
|
||||
height: 0.92rem;
|
||||
}
|
||||
|
||||
.download-delete-button {
|
||||
font-size: 1.1rem;
|
||||
line-height: 1;
|
||||
text-indent: 0.06rem;
|
||||
|
||||
Reference in new issue
Block a user