diff options
author | Chocobozzz <me@florianbigard.com> | 2022-09-07 17:30:21 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-09-08 08:41:48 +0200 |
commit | e9fc9e03c120fb048ed00b38157d15144770ec23 (patch) | |
tree | 5bea5b738e518527663f17217c92c24fde6620f4 /server/helpers | |
parent | d4d9bbc6f24522f5d63b0ab105a02f80ca98d702 (diff) | |
download | PeerTube-e9fc9e03c120fb048ed00b38157d15144770ec23.tar.gz PeerTube-e9fc9e03c120fb048ed00b38157d15144770ec23.tar.zst PeerTube-e9fc9e03c120fb048ed00b38157d15144770ec23.zip |
Optimize fetching playlist urls
Diffstat (limited to 'server/helpers')
-rw-r--r-- | server/helpers/youtube-dl/youtube-dl-cli.ts | 5 | ||||
-rw-r--r-- | server/helpers/youtube-dl/youtube-dl-wrapper.ts | 9 |
2 files changed, 8 insertions, 6 deletions
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 { | |||
142 | }): Promise<{ upload_date: string, webpage_url: string }[]> { | 142 | }): Promise<{ upload_date: string, webpage_url: string }[]> { |
143 | const additionalYoutubeDLArgs = [ '--skip-download', '--playlist-reverse' ] | 143 | const additionalYoutubeDLArgs = [ '--skip-download', '--playlist-reverse' ] |
144 | 144 | ||
145 | if (CONFIG.IMPORT.VIDEOS.HTTP.YOUTUBE_DL_RELEASE.NAME === 'yt-dlp') { | ||
146 | // Optimize listing videos only when using yt-dlp because it is bugged with youtube-dl when fetching a channel | ||
147 | additionalYoutubeDLArgs.push('--flat-playlist') | ||
148 | } | ||
149 | |||
145 | if (options.latestVideosCount !== undefined) { | 150 | if (options.latestVideosCount !== undefined) { |
146 | additionalYoutubeDLArgs.push('--playlist-end', options.latestVideosCount.toString()) | 151 | additionalYoutubeDLArgs.push('--playlist-end', options.latestVideosCount.toString()) |
147 | } | 152 | } |
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 @@ | |||
1 | import { move, pathExists, readdir, remove } from 'fs-extra' | 1 | import { move, pathExists, readdir, remove } from 'fs-extra' |
2 | import { dirname, join } from 'path' | 2 | import { dirname, join } from 'path' |
3 | import { inspect } from 'util' | ||
3 | import { CONFIG } from '@server/initializers/config' | 4 | import { CONFIG } from '@server/initializers/config' |
4 | import { isVideoFileExtnameValid } from '../custom-validators/videos' | 5 | import { isVideoFileExtnameValid } from '../custom-validators/videos' |
5 | import { logger, loggerTagsFactory } from '../logger' | 6 | import { logger, loggerTagsFactory } from '../logger' |
@@ -59,13 +60,9 @@ class YoutubeDLWrapper { | |||
59 | processOptions | 60 | processOptions |
60 | }) | 61 | }) |
61 | 62 | ||
62 | if (!Array.isArray(list)) throw new Error(`YoutubeDL could not get list info from ${this.url}`) | 63 | if (!Array.isArray(list)) throw new Error(`YoutubeDL could not get list info from ${this.url}: ${inspect(list)}`) |
63 | 64 | ||
64 | return list.map(info => { | 65 | return list.map(info => info.webpage_url) |
65 | const infoBuilder = new YoutubeDLInfoBuilder(info) | ||
66 | |||
67 | return infoBuilder.getInfo() | ||
68 | }) | ||
69 | } | 66 | } |
70 | 67 | ||
71 | async getSubtitles (): Promise<YoutubeDLSubs> { | 68 | async getSubtitles (): Promise<YoutubeDLSubs> { |