MCPcopy Create free account
hub / github.com/DialmasterOrg/Youtarr / channelAutoDownload

Method channelAutoDownload

server/modules/channelModule.js:622–648  ·  view source on GitHub ↗

* Trigger automatic channel video downloads. * Called by cron scheduler based on configured frequency. * Skips execution if a Channel Downloads job is already running to prevent queue backup. * @returns {Promise }

()

Source from the content-addressed store, hash-verified

620 * @returns {Promise<void>}
621 */
622 async channelAutoDownload() {
623 logger.info({
624 currentTime: new Date(),
625 interval: configModule.getConfig().channelDownloadFrequency
626 }, 'Running scheduled channel downloads');
627
628 // Check if a Channel Downloads job is already running
629 const jobModule = require('./jobModule');
630 const jobs = jobModule.getAllJobs();
631 // Check for both In Progress and Pending channel downloads to prevent accumulation
632 // Note: Pending jobs are terminated on app restart, so they won't get stuck
633 const hasRunningChannelDownload = Object.values(jobs).some(
634 job => job.jobType.includes('Channel Downloads') &&
635 (job.status === 'In Progress' || job.status === 'Pending')
636 );
637
638 if (hasRunningChannelDownload) {
639 logger.warn('Skipping scheduled channel download - previous download still in progress');
640 return;
641 }
642
643 try {
644 await downloadModule.doChannelAndPlaylistDownloads();
645 } catch (err) {
646 logger.error({ err }, 'Scheduled channel + playlist downloads failed');
647 }
648 }
649
650 /**
651 * Fetch channel metadata from YouTube along with sanitized folder name.

Callers 1

Calls 3

getConfigMethod · 0.80
getAllJobsMethod · 0.80

Tested by

no test coverage detected