diff --git a/tubearchivist/www/src/lib/getDownloads.ts b/tubearchivist/www/src/lib/getDownloads.ts index 546ac95..28770c9 100755 --- a/tubearchivist/www/src/lib/getDownloads.ts +++ b/tubearchivist/www/src/lib/getDownloads.ts @@ -1,5 +1,4 @@ import { Download } from "../types/download"; -import { DownloadResponse } from "../types/download"; import { getTAUrl } from "./constants"; const TA_BASE_URL = getTAUrl(); @@ -19,7 +18,7 @@ export const getDownloads = async (token: string, filter: boolean): Promise => { +export const sendDownloads = async (token: string, input: string): Promise => { var data = { "data": [{ "youtube_id": input, @@ -42,3 +41,20 @@ export const sendDownloads = async (token: string, input: string): Promise => { + const response = await fetch(`${TA_BASE_URL.server}/api/download/?filter=${filter}`, { + headers: { + Accept: "application/json", + "Content-Type": "application/json", + Authorization: `Token ${token}`, + mode: "no-cors", + }, + method: "DELETE" + }); + if (!response.ok) { + // throw new Error("Error adding content to the download queue."); + // return response.json(); + } + return response.json(); +}; \ No newline at end of file diff --git a/tubearchivist/www/src/pages/download.tsx b/tubearchivist/www/src/pages/download.tsx index 4cbcd64..b0d2475 100755 --- a/tubearchivist/www/src/pages/download.tsx +++ b/tubearchivist/www/src/pages/download.tsx @@ -5,7 +5,7 @@ import { dehydrate, QueryClient, useQuery } from "react-query"; import { CustomHead } from "../components/CustomHead"; import { Layout } from "../components/Layout"; import NextImage from "next/image"; -import { getDownloads } from "../lib/getDownloads"; +import { getDownloads, sendDeleteAllQueuedIgnored } from "../lib/getDownloads"; import { sendDownloads } from "../lib/getDownloads"; import RescanIcon from "../images/icon-rescan.svg"; import DownloadIcon from "../images/icon-download.svg"; @@ -199,13 +199,13 @@ const Download: NextPage = () => { {ignoredStatus &&

Ignored from download

- +
} {!ignoredStatus &&

Download queue

- +
}

Total videos: {downloads?.data?.length} {!downloads?.data?.length &&

No videos queued for download. Press rescan subscriptions to check if there are any new videos.

}

diff --git a/tubearchivist/www/src/types/download.ts b/tubearchivist/www/src/types/download.ts index c7d919d..a3eb771 100755 --- a/tubearchivist/www/src/types/download.ts +++ b/tubearchivist/www/src/types/download.ts @@ -2,13 +2,14 @@ export interface Download { data: Datum[]; config: Config; paginate: boolean; -} - -export interface DownloadResponse { - data: Datum[]; message: string; } +// export interface DownloadResponse { +// data: Datum[]; +// message: string; +// } + export interface Config { archive: Archive; default_view: DefaultView;