import Notifications from '../components/Notifications'; import SettingsNavigation from '../components/SettingsNavigation'; import Button from '../components/Button'; import PaginationDummy from '../components/PaginationDummy'; import { Fragment, useEffect, useState } from 'react'; import loadSchedule, { ScheduleResponseType } from '../api/loader/loadSchedule'; import loadAppriseNotification, { AppriseNotificationType, } from '../api/loader/loadAppriseNotification'; import deleteTaskSchedule from '../api/actions/deleteTaskSchedule'; import createTaskSchedule from '../api/actions/createTaskSchedule'; import createAppriseNotificationUrl, { AppriseTaskNameType, } from '../api/actions/createAppriseNotificationUrl'; import deleteAppriseNotificationUrl from '../api/actions/deleteAppriseNotificationUrl'; import { ApiError, ApiResponseType } from '../functions/APIClient'; const SettingsScheduling = () => { const [refresh, setRefresh] = useState(false); const [scheduleResponse, setScheduleResponse] = useState>(); const [appriseNotification, setAppriseNotification] = useState>(); const [updateSubscribed, setUpdateSubscribed] = useState(); const [downloadPending, setDownloadPending] = useState(); const [checkReindex, setCheckReindex] = useState(); const [checkReindexDays, setCheckReindexDays] = useState(); const [thumbnailCheck, setThumbnailCheck] = useState(); const [zipBackup, setZipBackup] = useState(); const [zipBackupDays, setZipBackupDays] = useState(); const [notificationUrl, setNotificationUrl] = useState(); const [notificationTask, setNotificationTask] = useState(''); const [checkReindexError, setCheckReindexError] = useState(null); const [updateSubscribedError, setUpdateSubscribedError] = useState(null); const [downloadPendingError, setDownloadPendingError] = useState(null); const [thumnailCheckError, setThumnailCheckError] = useState(null); const [zipBackupError, setZipBackupError] = useState(null); const { data: scheduleResponseData } = scheduleResponse ?? {}; const { data: appriseNotificationData } = appriseNotification ?? {}; useEffect(() => { (async () => { if (refresh) { const scheduleResponse = await loadSchedule(); const appriseNotificationResponse = await loadAppriseNotification(); setScheduleResponse(scheduleResponse); setAppriseNotification(appriseNotificationResponse); setRefresh(false); } })(); }, [refresh]); useEffect(() => { setRefresh(true); }, []); const groupedSchedules = Object.groupBy(scheduleResponseData || [], ({ name }) => name); console.log(groupedSchedules); const { update_subscribed, download_pending, run_backup, check_reindex, thumbnail_check } = groupedSchedules; const updateSubscribedSchedule = update_subscribed?.pop(); const downloadPendingSchedule = download_pending?.pop(); const runBackup = run_backup?.pop(); const checkReindexSchedule = check_reindex?.pop(); const thumbnailCheckSchedule = thumbnail_check?.pop(); return ( <> TA | Scheduling Settings

Scheduler Setup

Schedule settings expect a cron like format, where the first value is minute, second is hour and third is day of the week.

Examples:

  • 0 15 *: Run task every day at 15:00 in the afternoon.
  • 30 8 */2: Run task every second day of the week (Sun, Tue, Thu, Sat) at 08:30 in the morning.
  • auto: Sensible default.

Note:

  • Avoid an unnecessary frequent schedule to not get blocked by YouTube. For that reason, the scheduler doesn't support schedules that trigger more than once per hour.

Rescan Subscriptions

Become a sponsor and join{' '} members.tubearchivist.com {' '} to get access to real time notifications for new videos uploaded by your favorite channels.

Current rescan schedule:{' '} {!updateSubscribedSchedule && 'False'} {updateSubscribedSchedule && ( <> {updateSubscribedSchedule?.schedule}{' '}

Start Download

Current Download schedule:{' '} {!download_pending && 'False'} {downloadPendingSchedule && ( <> {downloadPendingSchedule?.schedule}{' '}

Refresh Metadata

Current Metadata refresh schedule:{' '} {!checkReindexSchedule && 'False'} {checkReindexSchedule && ( <> {checkReindexSchedule?.schedule}{' '}

Current refresh for metadata older than x days:{' '} {checkReindexSchedule?.config?.days}

Refresh older than x days, recommended 90:

{ setCheckReindexDays(Number(e.currentTarget.value)); }} />

Thumbnail Check

Current thumbnail check schedule:{' '} {!thumbnailCheckSchedule && 'False'} {thumbnailCheckSchedule && ( <> {thumbnailCheckSchedule?.schedule}{' '}

ZIP file index backup

Zip file backups are very slow for large archives and consistency is not guaranteed, use snapshots instead. Make sure no other tasks are running when creating a Zip file backup.

Current index backup schedule:{' '} {!runBackup && 'False'} {runBackup && ( <> {runBackup.schedule}{' '}

Current backup files to keep:{' '} {runBackup?.config?.rotate}

Max auto backups to keep:

{ setZipBackupDays(Number(e.currentTarget.value)); }} />

Add Notification URL

{!appriseNotificationData &&

No notifications stored

} {appriseNotificationData && ( <>
{Object.entries(appriseNotificationData)?.map(([key, { urls, title }]) => { return (

{title}

{urls.map((url: string) => { return (

{url}

)}

Send notification on completed tasks with the help of the{' '} Apprise {' '} library.

{ setNotificationUrl(e.currentTarget.value); }} />
); }; export default SettingsScheduling;