ActivityPub-federated video streaming platform using P2P directly in your web browser
Fix channel import
Chocobozzz20872615a4fe
diff --git a/server/core/lib/sync-channel.ts b/server/core/lib/sync-channel.tsindex 07a304da23..11fc929145 100644--- a/server/core/lib/sync-channel.ts+++ b/server/core/lib/sync-channel.ts@@ -37,7 +37,7 @@ export async function synchronizeChannel (options: {CONFIG.TRANSCODING.ALWAYS_TRANSCODE_ORIGINAL_RESOLUTION)- const lTags = loggerTagsFactory(...rootLTags().tags, channelSync.externalChannelUrl, channelUsername)+ const lTags = loggerTagsFactory(...rootLTags().tags, externalChannelUrl, channelUsername)const targetUrls = await youtubeDL.getInfoForListImport({userLanguage: user.getLanguage(),@@ -45,7 +45,7 @@ export async function synchronizeChannel (options: {})logger.info(- `Fetched ${targetUrls.length} candidate URLs for sync channel ${channelSync.externalChannelUrl}.`,+ `Fetched ${targetUrls.length} candidate URLs.`,{ targetUrls, ...lTags() })@@ -94,14 +94,17 @@ export async function synchronizeChannel (options: {}}- const failed = await VideoImportModel.listFailedBySyncId({ channelSyncId: channelSync.id })- for (const videoImport of failed) {- logger.info(- `Retrying failed video import (id: ${videoImport.id}) for channel "${channel.Actor.preferredUsername}"`,- rootLTags()- )+ // Retry failed imports from this sync (if any)+ if (channelSync) {+ const failed = await VideoImportModel.listFailedBySyncId({ channelSyncId: channelSync.id })+ for (const videoImport of failed) {+ logger.info(+ `Retrying failed video import (id: ${videoImport.id}) for channel "${channel.Actor.preferredUsername}"`,+ rootLTags()+ )- children.push(await buildRetryImportJob(videoImport))+ children.push(await buildRetryImportJob(videoImport))+ }}// Will update the channel sync status@@ -116,8 +119,11 @@ export async function synchronizeChannel (options: {await JobQueue.Instance.createJobWithChildren(parent, children)} catch (err) {logger.error(`Failed to import ${externalChannelUrl} in channel ${channelUsername}`, { err, ...rootLTags() })- channelSync.state = VideoChannelSyncState.FAILED- await channelSync.save()++ if (channelSync) {+ channelSync.state = VideoChannelSyncState.FAILED+ await channelSync.save()+ }}}@@ -125,7 +131,7 @@ export async function synchronizeChannel (options: {async function skipImport (options: {channel: MChannelAccountDefault- channelSync: MChannelSync+ channelSync?: MChannelSynctargetUrl: stringlTags: LoggerTagsFn}) {diff --git a/server/core/models/video/sql/import/video-import-list-query-builder.ts b/server/core/models/video/sql/import/video-import-list-query-builder.tsindex ab035a89be..c0fdf97ac6 100644--- a/server/core/models/video/sql/import/video-import-list-query-builder.ts+++ b/server/core/models/video/sql/import/video-import-list-query-builder.ts@@ -25,6 +25,7 @@ export class VideoImportListQueryBuilder extends AbstractListQuery {private builtThumbnailJoin = falseprivate builtAccountAvatarJoin = falseprivate builtChannelAvatarJoin = false+ private builtChannelSyncJoin = falseconstructor (protected readonly sequelize: Sequelize,@@ -174,6 +175,14 @@ export class VideoImportListQueryBuilder extends AbstractListQuery {this.builtChannelAvatarJoin = true}+ private buildChannelSyncJoin () {+ if (this.builtChannelSyncJoin) return++ this.join += ' LEFT JOIN "videoChannelSync" "VideoChannelSync" ON "VideoChannelSync"."id" = "VideoImportModel"."videoChannelSyncId" '++ this.builtChannelSyncJoin = true+ }+// ---------------------------------------------------------------------------protected buildQueryJoin () {@@ -181,6 +190,7 @@ export class VideoImportListQueryBuilder extends AbstractListQuery {this.buildAccountAvatarsJoin()this.buildTagJoin()this.buildThumbnailJoin()+ this.buildChannelSyncJoin()}protected buildQueryAttributes () {@@ -190,7 +200,8 @@ export class VideoImportListQueryBuilder extends AbstractListQuery {this.tableAttributes.getVideoTagAttributes(),this.tableAttributes.getAccountAvatarAttributes(),this.tableAttributes.getChannelAvatarAttributes(),- this.tableAttributes.getThumbnailAttributes()+ this.tableAttributes.getThumbnailAttributes(),+ this.tableAttributes.getChannelSyncAttributes()]}diff --git a/server/core/models/video/sql/import/video-import-table-attributes.ts b/server/core/models/video/sql/import/video-import-table-attributes.tsindex 910316195a..a7bdb8bdff 100644--- a/server/core/models/video/sql/import/video-import-table-attributes.ts+++ b/server/core/models/video/sql/import/video-import-table-attributes.ts@@ -8,6 +8,7 @@ import { ThumbnailModel } from '../../thumbnail.js'import { VideoChannelModel } from '../../video-channel.js'import { VideoImportModel } from '../../video-import.js'import { VideoModel } from '../../video.js'+import { VideoChannelSyncModel } from '../../video-channel-sync.js'export class VideoImportTableAttributes {@Memoize()@@ -22,6 +23,7 @@ export class VideoImportTableAttributes {return VideoModel.getSQLAttributes('Video', 'Video.').join(', ')}+ @Memoize()getVideoTagAttributes () {return TagModel.getSQLAttributes('Video->Tags', 'Video.Tags.').join(', ')}@@ -78,4 +80,9 @@ export class VideoImportTableAttributes {getThumbnailAttributes () {return ThumbnailModel.getSQLAttributes('Video->Thumbnails', 'Video.Thumbnails.').join(', ')}++ @Memoize()+ getChannelSyncAttributes () {+ return VideoChannelSyncModel.getSQLAttributes('VideoChannelSync', 'VideoChannelSync.').join(', ')+ }}