From e9fc9e03c120fb048ed00b38157d15144770ec23 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 7 Sep 2022 17:30:21 +0200 Subject: Optimize fetching playlist urls --- server/helpers/youtube-dl/youtube-dl-cli.ts | 5 +++++ server/helpers/youtube-dl/youtube-dl-wrapper.ts | 9 +++------ 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'server/helpers') diff --git a/server/helpers/youtube-dl/youtube-dl-cli.ts b/server/helpers/youtube-dl/youtube-dl-cli.ts index 508055b85..fc4c40787 100644 --- a/server/helpers/youtube-dl/youtube-dl-cli.ts +++ b/server/helpers/youtube-dl/youtube-dl-cli.ts @@ -142,6 +142,11 @@ export class YoutubeDLCLI { }): Promise<{ upload_date: string, webpage_url: string }[]> { const additionalYoutubeDLArgs = [ '--skip-download', '--playlist-reverse' ] + if (CONFIG.IMPORT.VIDEOS.HTTP.YOUTUBE_DL_RELEASE.NAME === 'yt-dlp') { + // Optimize listing videos only when using yt-dlp because it is bugged with youtube-dl when fetching a channel + additionalYoutubeDLArgs.push('--flat-playlist') + } + if (options.latestVideosCount !== undefined) { additionalYoutubeDLArgs.push('--playlist-end', options.latestVideosCount.toString()) } diff --git a/server/helpers/youtube-dl/youtube-dl-wrapper.ts b/server/helpers/youtube-dl/youtube-dl-wrapper.ts index 2c3ba2feb..966b8df78 100644 --- a/server/helpers/youtube-dl/youtube-dl-wrapper.ts +++ b/server/helpers/youtube-dl/youtube-dl-wrapper.ts @@ -1,5 +1,6 @@ import { move, pathExists, readdir, remove } from 'fs-extra' import { dirname, join } from 'path' +import { inspect } from 'util' import { CONFIG } from '@server/initializers/config' import { isVideoFileExtnameValid } from '../custom-validators/videos' import { logger, loggerTagsFactory } from '../logger' @@ -59,13 +60,9 @@ class YoutubeDLWrapper { processOptions }) - if (!Array.isArray(list)) throw new Error(`YoutubeDL could not get list info from ${this.url}`) + if (!Array.isArray(list)) throw new Error(`YoutubeDL could not get list info from ${this.url}: ${inspect(list)}`) - return list.map(info => { - const infoBuilder = new YoutubeDLInfoBuilder(info) - - return infoBuilder.getInfo() - }) + return list.map(info => info.webpage_url) } async getSubtitles (): Promise { -- cgit v1.2.3