Add playlist support to downloader API and frontend

Enhanced the downloader backend and frontend to support playlist URLs for video info and downloads. The API now returns structured playlist information, allows selecting specific videos for download, and returns a ZIP file for playlist downloads. Updated OpenAPI types, removed deprecated parameters (start_time, end_time, playlist_items), and improved Content Security Policy handling in nginx. Refactored frontend to handle playlist selection and updated generated API models accordingly.
This commit is contained in:
2025-12-25 04:54:27 +01:00
parent cf615c5279
commit 264f0116ae
20 changed files with 606 additions and 424 deletions

View File

@@ -5,7 +5,7 @@
*/
export interface DownloadRequest {
/** Video URL to download from supported platforms */
/** Video/Playlist URL to download from supported platforms */
url: string;
/** Container format for the output file. Common formats: mp4 (H.264 + AAC, most compatible), mkv (flexible, lossless container), webm (VP9/AV1 + Opus), flv (legacy), mov (Apple-friendly), avi (older), ogg, m4a (audio only), mp3 (audio only). The extension will be validated by ffmpeg during conversion. */
ext?: string;
@@ -19,6 +19,11 @@ export interface DownloadRequest {
* @nullable
*/
audio_quality?: number | null;
/**
* For playlists: specify which videos to download as array of numbers (e.g., [1,3,5]). If omitted, all videos are downloaded.
* @nullable
*/
selected_videos?: number[] | null;
/**
* Language codes (e.g., 'en', 'cs', 'en,cs') or 'all' for all available subtitles
* @nullable
@@ -30,21 +35,6 @@ export interface DownloadRequest {
embed_thumbnail?: boolean;
/** Extract audio only, ignoring video quality settings */
extract_audio?: boolean;
/**
* Start time for trimming (format: HH:MM:SS or seconds as integer)
* @nullable
*/
start_time?: string | null;
/**
* End time for trimming (format: HH:MM:SS or seconds as integer)
* @nullable
*/
end_time?: string | null;
/**
* Playlist items to download (e.g., '1-5,8,10' or '1,2,3')
* @nullable
*/
playlist_items?: string | null;
/**
* Browser cookies in Netscape format for age-restricted content. Export from browser extensions like 'Get cookies.txt'
* @nullable

View File

@@ -85,6 +85,7 @@ export * from "./stateFdaEnum";
export * from "./statusEnum";
export * from "./trackingURL";
export * from "./userRegistration";
export * from "./videoInfo";
export * from "./videoInfoResponse";
export * from "./zasilkovnaPacket";
export * from "./zasilkovnaPacketRead";

View File

@@ -1,27 +0,0 @@
/**
* Generated by orval v7.17.0 🍺
* Do not edit manually.
* OpenAPI spec version: 0.0.0
*/
/**
* * `WAITING_FOR_ORDERING_SHIPMENT` - cz#Čeká na objednání zásilkovny
* `PENDING` - cz#Podáno
* `SENDED` - cz#Odesláno
* `ARRIVED` - cz#Doručeno
* `CANCELED` - cz#Zrušeno
* `RETURNING` - cz#Posláno zpátky
* `RETURNED` - cz#Vráceno
*/
export type StateE15Enum = (typeof StateE15Enum)[keyof typeof StateE15Enum];
// eslint-disable-next-line @typescript-eslint/no-redeclare
export const StateE15Enum = {
WAITING_FOR_ORDERING_SHIPMENT: "WAITING_FOR_ORDERING_SHIPMENT",
PENDING: "PENDING",
SENDED: "SENDED",
ARRIVED: "ARRIVED",
CANCELED: "CANCELED",
RETURNING: "RETURNING",
RETURNED: "RETURNED",
} as const;

View File

@@ -1,21 +0,0 @@
/**
* Generated by orval v7.17.0 🍺
* Do not edit manually.
* OpenAPI spec version: 0.0.0
*/
/**
* * `ordered` - cz#Objednávka se připravuje
* `shipped` - cz#Odesláno
* `delivered` - cz#Doručeno
* `ready_to_pickup` - cz#Připraveno k vyzvednutí
*/
export type StateFdaEnum = (typeof StateFdaEnum)[keyof typeof StateFdaEnum];
// eslint-disable-next-line @typescript-eslint/no-redeclare
export const StateFdaEnum = {
ordered: "ordered",
shipped: "shipped",
delivered: "delivered",
ready_to_pickup: "ready_to_pickup",
} as const;

View File

@@ -0,0 +1,26 @@
/**
* Generated by orval v7.17.0 🍺
* Do not edit manually.
* OpenAPI spec version: 0.0.0
*/
export interface VideoInfo {
/** Video ID */
id: string;
/** Video title */
title: string;
/**
* Video duration in seconds (null if unavailable)
* @nullable
*/
duration: number | null;
/**
* Base64 encoded thumbnail image as data URL (e.g., data:image/jpeg;base64,...)
* @nullable
*/
thumbnail: string | null;
/** List of available video quality options (e.g., '1080p', '720p', '480p') */
video_resolutions: string[];
/** List of available audio format options */
audio_resolutions: string[];
}

View File

@@ -3,22 +3,21 @@
* Do not edit manually.
* OpenAPI spec version: 0.0.0
*/
import type { VideoInfo } from "./videoInfo";
export interface VideoInfoResponse {
/** Video title */
title: string;
/** Whether the URL is a playlist */
is_playlist: boolean;
/**
* Video duration in seconds (null if unavailable)
* Playlist title (if applicable)
* @nullable
*/
duration: number | null;
playlist_title: string | null;
/**
* URL to video thumbnail image
* Number of videos in playlist (if applicable)
* @nullable
*/
thumbnail: string | null;
/** List of available video quality options (e.g., '1080p', '720p', '480p') */
video_resolutions: string[];
/** List of available audio format options */
audio_resolutions: string[];
playlist_count: number | null;
/** Array of video information (single video for individual URLs, multiple for playlists) */
videos: VideoInfo[];
}

View File

@@ -32,18 +32,24 @@ import { publicMutator } from "../../publicClient";
/**
*
Fetch detailed information about a video from supported platforms.
Fetch detailed information about a video or playlist from supported platforms.
**Supported platforms:** YouTube, TikTok, Vimeo, Twitter, Instagram, Facebook, Reddit, and many more.
**Returns:**
For single videos:
- Video title, duration, and thumbnail
- Available video qualities/resolutions
- Available audio formats
For playlists:
- Array of videos with the same info structure as single videos
- Each video includes title, duration, thumbnail, and available qualities
**Usage:**
```
GET /api/downloader/download/?url=https://youtube.com/watch?v=VIDEO_ID
GET /api/downloader/download/?url=https://youtube.com/playlist?list=PLAYLIST_ID
```
* @summary Get video info from URL
@@ -211,7 +217,12 @@ export function useApiDownloaderDownloadRetrieve<
/**
*
Download video with optional quality constraints and container format conversion.
Download video/playlist with optional quality constraints and container format conversion.
**For Playlists:**
- Returns a ZIP file containing all selected videos
- Use `selected_videos` to specify which videos to download (e.g., [1,3,5] or [1,2,3,4,5])
- If `selected_videos` is not provided, all videos in the playlist will be downloaded
**Quality Parameters (optional):**
- If not specified, yt-dlp will automatically select the best available quality.
@@ -228,12 +239,9 @@ export function useApiDownloaderDownloadRetrieve<
- `embed_subtitles`: Embed subtitles into video file
- `embed_thumbnail`: Embed thumbnail as cover art
- `extract_audio`: Extract audio only (ignores video quality)
- `start_time`: Trim start (format: HH:MM:SS or seconds)
- `end_time`: Trim end (format: HH:MM:SS or seconds)
- `playlist_items`: Download specific playlist items (e.g., '1-5,8,10')
- `cookies`: Browser cookies for age-restricted content (Netscape format)
* @summary Download video from URL
* @summary Download video or playlist from URL
*/
export const apiDownloaderDownloadCreate = (
downloadRequest: DownloadRequest,
@@ -293,7 +301,7 @@ export type ApiDownloaderDownloadCreateMutationBody = DownloadRequest;
export type ApiDownloaderDownloadCreateMutationError = DownloadErrorResponse;
/**
* @summary Download video from URL
* @summary Download video or playlist from URL
*/
export const useApiDownloaderDownloadCreate = <
TError = DownloadErrorResponse,

View File

@@ -6,7 +6,7 @@
export type ApiDownloaderDownloadRetrieveParams = {
/**
* Video URL from YouTube, TikTok, Vimeo, etc. Must be a valid URL from a supported platform.
* Video/Playlist URL from YouTube, TikTok, Vimeo, etc. Must be a valid URL from a supported platform.
* @minLength 1
*/
url: string;

View File

@@ -5,7 +5,7 @@
*/
export interface DownloadRequest {
/** Video URL to download from supported platforms */
/** Video/Playlist URL to download from supported platforms */
url: string;
/** Container format for the output file. Common formats: mp4 (H.264 + AAC, most compatible), mkv (flexible, lossless container), webm (VP9/AV1 + Opus), flv (legacy), mov (Apple-friendly), avi (older), ogg, m4a (audio only), mp3 (audio only). The extension will be validated by ffmpeg during conversion. */
ext?: string;
@@ -19,6 +19,11 @@ export interface DownloadRequest {
* @nullable
*/
audio_quality?: number | null;
/**
* For playlists: specify which videos to download as array of numbers (e.g., [1,3,5]). If omitted, all videos are downloaded.
* @nullable
*/
selected_videos?: number[] | null;
/**
* Language codes (e.g., 'en', 'cs', 'en,cs') or 'all' for all available subtitles
* @nullable
@@ -30,21 +35,6 @@ export interface DownloadRequest {
embed_thumbnail?: boolean;
/** Extract audio only, ignoring video quality settings */
extract_audio?: boolean;
/**
* Start time for trimming (format: HH:MM:SS or seconds as integer)
* @nullable
*/
start_time?: string | null;
/**
* End time for trimming (format: HH:MM:SS or seconds as integer)
* @nullable
*/
end_time?: string | null;
/**
* Playlist items to download (e.g., '1-5,8,10' or '1,2,3')
* @nullable
*/
playlist_items?: string | null;
/**
* Browser cookies in Netscape format for age-restricted content. Export from browser extensions like 'Get cookies.txt'
* @nullable

View File

@@ -80,6 +80,7 @@ export * from "./stateFdaEnum";
export * from "./statusEnum";
export * from "./trackingURL";
export * from "./userRegistration";
export * from "./videoInfo";
export * from "./videoInfoResponse";
export * from "./zasilkovnaPacket";
export * from "./zasilkovnaPacketRead";

View File

@@ -1,27 +0,0 @@
/**
* Generated by orval v7.17.0 🍺
* Do not edit manually.
* OpenAPI spec version: 0.0.0
*/
/**
* * `WAITING_FOR_ORDERING_SHIPMENT` - cz#Čeká na objednání zásilkovny
* `PENDING` - cz#Podáno
* `SENDED` - cz#Odesláno
* `ARRIVED` - cz#Doručeno
* `CANCELED` - cz#Zrušeno
* `RETURNING` - cz#Posláno zpátky
* `RETURNED` - cz#Vráceno
*/
export type StateE15Enum = (typeof StateE15Enum)[keyof typeof StateE15Enum];
// eslint-disable-next-line @typescript-eslint/no-redeclare
export const StateE15Enum = {
WAITING_FOR_ORDERING_SHIPMENT: "WAITING_FOR_ORDERING_SHIPMENT",
PENDING: "PENDING",
SENDED: "SENDED",
ARRIVED: "ARRIVED",
CANCELED: "CANCELED",
RETURNING: "RETURNING",
RETURNED: "RETURNED",
} as const;

View File

@@ -1,21 +0,0 @@
/**
* Generated by orval v7.17.0 🍺
* Do not edit manually.
* OpenAPI spec version: 0.0.0
*/
/**
* * `ordered` - cz#Objednávka se připravuje
* `shipped` - cz#Odesláno
* `delivered` - cz#Doručeno
* `ready_to_pickup` - cz#Připraveno k vyzvednutí
*/
export type StateFdaEnum = (typeof StateFdaEnum)[keyof typeof StateFdaEnum];
// eslint-disable-next-line @typescript-eslint/no-redeclare
export const StateFdaEnum = {
ordered: "ordered",
shipped: "shipped",
delivered: "delivered",
ready_to_pickup: "ready_to_pickup",
} as const;

View File

@@ -0,0 +1,26 @@
/**
* Generated by orval v7.17.0 🍺
* Do not edit manually.
* OpenAPI spec version: 0.0.0
*/
export interface VideoInfo {
/** Video ID */
id: string;
/** Video title */
title: string;
/**
* Video duration in seconds (null if unavailable)
* @nullable
*/
duration: number | null;
/**
* Base64 encoded thumbnail image as data URL (e.g., data:image/jpeg;base64,...)
* @nullable
*/
thumbnail: string | null;
/** List of available video quality options (e.g., '1080p', '720p', '480p') */
video_resolutions: string[];
/** List of available audio format options */
audio_resolutions: string[];
}

View File

@@ -3,22 +3,21 @@
* Do not edit manually.
* OpenAPI spec version: 0.0.0
*/
import type { VideoInfo } from "./videoInfo";
export interface VideoInfoResponse {
/** Video title */
title: string;
/** Whether the URL is a playlist */
is_playlist: boolean;
/**
* Video duration in seconds (null if unavailable)
* Playlist title (if applicable)
* @nullable
*/
duration: number | null;
playlist_title: string | null;
/**
* URL to video thumbnail image
* Number of videos in playlist (if applicable)
* @nullable
*/
thumbnail: string | null;
/** List of available video quality options (e.g., '1080p', '720p', '480p') */
video_resolutions: string[];
/** List of available audio format options */
audio_resolutions: string[];
playlist_count: number | null;
/** Array of video information (single video for individual URLs, multiple for playlists) */
videos: VideoInfo[];
}