]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Fix infinite playlist import
authorChocobozzz <me@florianbigard.com>
Mon, 14 Nov 2022 10:11:39 +0000 (11:11 +0100)
committerChocobozzz <me@florianbigard.com>
Mon, 14 Nov 2022 10:11:39 +0000 (11:11 +0100)
Using an hard videos limit in config

config/default.yaml
config/production.yaml.example
server/initializers/checker-before-init.ts
server/initializers/config.ts
server/lib/job-queue/handlers/video-channel-import.ts
server/lib/sync-channel.ts
server/tests/api/videos/channel-import-videos.ts
server/tests/api/videos/video-channel-syncs.ts

index 2e249cc768328dc77b8890ba21dc0c395a809c97..a916b1dc3e886f61b91f3e6731fb1e909dc4ffdb 100644 (file)
@@ -578,6 +578,9 @@ import:
     # Number of latest published videos to check and to potentially import when syncing a channel
     videos_limit_per_synchronization: 10
 
+    # Max number of videos to import when the user asks for full sync
+    full_sync_videos_limit: 1000
+
 auto_blacklist:
   # New videos automatically blacklisted so moderators can review before publishing
   videos:
index c136a73ad3942dac6d12d498af3ec720ff377b3e..100bc79482de6d8a8b6c554075ef21e6c48de429 100644 (file)
@@ -588,6 +588,9 @@ import:
     # Number of latest published videos to check and to potentially import when syncing a channel
     videos_limit_per_synchronization: 10
 
+    # Max number of videos to import when the user asks for full sync
+    full_sync_videos_limit: 1000
+
 auto_blacklist:
   # New videos automatically blacklisted so moderators can review before publishing
   videos:
index e5ec0d1df5bb32bba38982ec4f1e84828abf3a79..42be7ee6e929303f9bbf6014b38d613113a3a865 100644 (file)
@@ -35,6 +35,7 @@ function checkMissedConfig () {
     'import.videos.http.enabled', 'import.videos.torrent.enabled', 'import.videos.concurrency', 'import.videos.timeout',
     'import.video_channel_synchronization.enabled', 'import.video_channel_synchronization.max_per_user',
     'import.video_channel_synchronization.check_interval', 'import.video_channel_synchronization.videos_limit_per_synchronization',
+    'import.video_channel_synchronization.full_sync_videos_limit',
     'auto_blacklist.videos.of_users.enabled', 'trending.videos.interval_days',
     'client.videos.miniature.display_author_avatar',
     'client.videos.miniature.prefer_author_display_name', 'client.menu.login.redirect_on_single_external_auth',
index 7652da24acda79908ac91a62c18ca6151b121bd4..3dd1f6971e39dc12e09802aa1680af9d96cf17d4 100644 (file)
@@ -418,6 +418,9 @@ const CONFIG = {
       get CHECK_INTERVAL () { return parseDurationToMs(config.get<string>('import.video_channel_synchronization.check_interval')) },
       get VIDEOS_LIMIT_PER_SYNCHRONIZATION () {
         return config.get<number>('import.video_channel_synchronization.videos_limit_per_synchronization')
+      },
+      get FULL_SYNC_VIDEOS_LIMIT () {
+        return config.get<number>('import.video_channel_synchronization.full_sync_videos_limit')
       }
     }
   },
index c3dd8a6888ecd52ac0ff1e8639c1483fa53faaaa..035f88e96c00630f2ab374003e5103a8a84687d5 100644 (file)
@@ -37,6 +37,7 @@ export async function processVideoChannelImport (job: Job) {
   await synchronizeChannel({
     channel: videoChannel,
     externalChannelUrl: payload.externalChannelUrl,
-    channelSync
+    channelSync,
+    videosCountLimit: CONFIG.IMPORT.VIDEO_CHANNEL_SYNCHRONIZATION.FULL_SYNC_VIDEOS_LIMIT
   })
 }
index 4d00d6163c60c1eabad6d2aa6a18312e3a3a617e..10167ee38edf1afe80ef75dbbd1bac7694e71835 100644 (file)
@@ -12,8 +12,8 @@ import { ServerConfigManager } from './server-config-manager'
 export async function synchronizeChannel (options: {
   channel: MChannelAccountDefault
   externalChannelUrl: string
+  videosCountLimit: number
   channelSync?: MChannelSync
-  videosCountLimit?: number
   onlyAfter?: Date
 }) {
   const { channel, externalChannelUrl, videosCountLimit, onlyAfter, channelSync } = options
index 7cfd02fbb4855319ac55c720797cc7f8a11bda34..a66f88a0ec13f3777334f63c64d89322b32a6b51 100644 (file)
@@ -109,6 +109,45 @@ describe('Test videos import in a channel', function () {
         }
       })
 
+      it('Should limit max amount of videos synced on full sync', async function () {
+        this.timeout(240_000)
+
+        await server.kill()
+        await server.run({
+          import: {
+            video_channel_synchronization: {
+              full_sync_videos_limit: 1
+            }
+          }
+        })
+
+        const { id } = await server.channels.create({ attributes: { name: 'channel3' } })
+        const channel3Id = id
+
+        const { videoChannelSync } = await server.channelSyncs.create({
+          attributes: {
+            externalChannelUrl: FIXTURE_URLS.youtubeChannel,
+            videoChannelId: channel3Id
+          }
+        })
+        const syncId = videoChannelSync.id
+
+        await waitJobs(server)
+
+        await server.channels.importVideos({
+          channelName: 'channel3',
+          externalChannelUrl: FIXTURE_URLS.youtubeChannel,
+          videoChannelSyncId: syncId
+        })
+
+        await waitJobs(server)
+
+        const { total, data } = await server.videos.listByChannel({ handle: 'channel3' })
+
+        expect(total).to.equal(1)
+        expect(data).to.have.lengthOf(1)
+      })
+
       after(async function () {
         await server?.kill()
       })
@@ -116,5 +155,7 @@ describe('Test videos import in a channel', function () {
   }
 
   runSuite('yt-dlp')
-  runSuite('youtube-dl')
+
+  // FIXME: With recent changes on youtube, youtube-dl doesn't fetch live replays which means the test suite fails
+  // runSuite('youtube-dl')
 })
index 865b25f043dbcd44bd952d16135e7fdb77a77703..91291524d38544f11898bdbbb5c8f51230b1f677 100644 (file)
@@ -220,7 +220,7 @@ describe('Test channel synchronizations', function () {
         expect(total).to.equal(0)
       })
 
-      // FIXME: youtube-dl doesn't work when speicifying a port after the hostname
+      // FIXME: youtube-dl/yt-dlp doesn't work when speicifying a port after the hostname
       // it('Should import a remote PeerTube channel', async function () {
       //   this.timeout(240_000)