ActivityPub-federated video streaming platform using P2P directly in your web browser
Add ability to retry video imports
Chocobozzze30e5c9f7b83
diff --git a/client/src/app/+admin/overview/videos/video-list.component.ts b/client/src/app/+admin/overview/videos/video-list.component.tsindex 9be46ae0e9..05309eac35 100644--- a/client/src/app/+admin/overview/videos/video-list.component.ts+++ b/client/src/app/+admin/overview/videos/video-list.component.ts@@ -194,7 +194,9 @@ export class VideoListComponent implements OnInit {}isImport (video: Video) {- return video.state.id === VideoState.TO_IMPORT+ const state = video.state.id++ return state === VideoState.TO_IMPORT || state === VideoState.TO_IMPORT_FAILED}hasOriginalFile (video: Video) {diff --git a/client/src/app/+my-library/my-video-imports/my-video-imports.component.html b/client/src/app/+my-library/my-video-imports/my-video-imports.component.htmlindex d7cd122ac4..a031760264 100644--- a/client/src/app/+my-library/my-video-imports/my-video-imports.component.html+++ b/client/src/app/+my-library/my-video-imports/my-video-imports.component.html@@ -52,17 +52,7 @@</ng-template><ng-template #actionCell let-videoImport>- @if (isVideoImportPending(videoImport)) {- <my-button i18n-label label="Cancel" icon="no" (click)="cancelImport(videoImport)"></my-button>- }-- @if (isVideoImportFailed(videoImport) || isVideoImportCancelled(videoImport) || !videoImport.video) {- <my-delete-button (click)="deleteImport(videoImport)"></my-delete-button>- }-- @if (isVideoImportSuccess(videoImport) && videoImport.video) {- <my-edit-button [ptRouterLink]="getEditVideoUrl(videoImport.video)" i18n-title title="Update the video"></my-edit-button>- }+ <my-action-dropdown i18n-label label="Actions" [actions]="videoImportActions" [entry]="videoImport" container="body"></my-action-dropdown></ng-template><ng-template #expandedRow let-videoImport>diff --git a/client/src/app/+my-library/my-video-imports/my-video-imports.component.ts b/client/src/app/+my-library/my-video-imports/my-video-imports.component.tsindex 139b24fa45..f3fb7ee72a 100644--- a/client/src/app/+my-library/my-video-imports/my-video-imports.component.ts+++ b/client/src/app/+my-library/my-video-imports/my-video-imports.component.ts@@ -1,15 +1,13 @@-import { CommonModule, NgClass } from '@angular/common'-import { Component, inject, viewChild } from '@angular/core'+import { CommonModule } from '@angular/common'+import { Component, inject, OnInit, viewChild } from '@angular/core'import { Notifier } from '@app/core'+import { ActionDropdownComponent, DropdownAction } from '@app/shared/shared-main/buttons/action-dropdown.component'import { PTDatePipe } from '@app/shared/shared-main/common/date.pipe'import { VideoImportService } from '@app/shared/shared-main/video/video-import.service'import { Video } from '@app/shared/shared-main/video/video.model'import { ActorCellComponent } from '@app/shared/shared-tables/actor-cell.component'import { VideoImport, VideoImportState, VideoImportStateType } from '@peertube/peertube-models'import { AdvancedInputFilterComponent } from '../../shared/shared-forms/advanced-input-filter.component'-import { ButtonComponent } from '../../shared/shared-main/buttons/button.component'-import { DeleteButtonComponent } from '../../shared/shared-main/buttons/delete-button.component'-import { EditButtonComponent } from '../../shared/shared-main/buttons/edit-button.component'import { NumberFormatterPipe } from '../../shared/shared-main/common/number-formatter.pipe'import { DataLoaderOptions, TableColumnInfo, TableComponent } from '../../shared/shared-tables/table.component'@@ -19,22 +17,22 @@ import { DataLoaderOptions, TableColumnInfo, TableComponent } from '../../sharedimports: [AdvancedInputFilterComponent,CommonModule,- ButtonComponent,- DeleteButtonComponent,- EditButtonComponent,- NgClass,+ CommonModule,PTDatePipe,TableComponent,NumberFormatterPipe,- ActorCellComponent+ ActorCellComponent,+ ActionDropdownComponent]})-export class MyVideoImportsComponent {+export class MyVideoImportsComponent implements OnInit {private notifier = inject(Notifier)private videoImportService = inject(VideoImportService)readonly table = viewChild<TableComponent<VideoImport>>('table')+ videoImportActions: DropdownAction<VideoImport>[] = []+columns: TableColumnInfo<string>[] = [{ id: 'target', label: $localize`Target`, sortable: false },{ id: 'channel', label: $localize`Channel`, sortable: false },@@ -49,6 +47,38 @@ export class MyVideoImportsComponent {this.dataLoader = this._dataLoader.bind(this)}+ ngOnInit () {+ this.videoImportActions = [+ {+ label: $localize`Cancel import`,+ iconName: 'no',+ handler: videoImport => this.cancelImport(videoImport),+ isDisplayed: videoImport => this.isVideoImportPending(videoImport)+ },+ {+ label: $localize`Retry import`,+ iconName: 'refresh',+ handler: videoImport => this.retryImport(videoImport),+ isDisplayed: videoImport => this.isVideoImportFailed(videoImport)+ },+ {+ label: $localize`Delete import task`,+ description: $localize`The associated video is not deleted`,+ iconName: 'delete',+ handler: videoImport => this.deleteImport(videoImport),+ isDisplayed: videoImport => {+ return this.isVideoImportFailed(videoImport) || this.isVideoImportCancelled(videoImport) || !videoImport.video+ }+ },+ {+ label: $localize`Edit video`,+ iconName: 'edit',+ linkBuilder: videoImport => [ this.getEditVideoUrl(videoImport.video) ],+ isDisplayed: videoImport => this.isVideoImportSuccess(videoImport) && !!videoImport.video+ }+ ]+ }+getVideoImportStateClass (state: VideoImportStateType) {switch (state) {case VideoImportState.FAILED:@@ -110,6 +140,15 @@ export class MyVideoImportsComponent {})}+ retryImport (videoImport: VideoImport) {+ this.videoImportService.retryVideoImport(videoImport)+ .subscribe({+ next: () => this.table().loadData(),++ error: err => this.notifier.error(err.message)+ })+ }+private _dataLoader (options: DataLoaderOptions) {return this.videoImportService.listMyVideoImports({ ...options, includeCollaborations: true })}diff --git a/client/src/app/+video-watch/shared/information/video-alert.component.ts b/client/src/app/+video-watch/shared/information/video-alert.component.tsindex 100d07ca75..de97f6104e 100644--- a/client/src/app/+video-watch/shared/information/video-alert.component.ts+++ b/client/src/app/+video-watch/shared/information/video-alert.component.ts@@ -28,7 +28,7 @@ export class VideoAlertComponent {const video = this.video()if (!video) return undefined- return this.videoStateMessage.buildWarn(video.state.id)+ return this.videoStateMessage.buildWarn(video.id, video.state.id)}hasVideoScheduledPublication () {diff --git a/client/src/app/+videos-publish-manage/+video-publish/import/video-import-torrent.component.ts b/client/src/app/+videos-publish-manage/+video-publish/import/video-import-torrent.component.tsindex f932607f0b..e8ec431251 100644--- a/client/src/app/+videos-publish-manage/+video-publish/import/video-import-torrent.component.ts+++ b/client/src/app/+videos-publish-manage/+video-publish/import/video-import-torrent.component.ts@@ -11,13 +11,14 @@ import { NgbTooltip } from '@ng-bootstrap/ng-bootstrap'import { LoadingBarService } from '@ngx-loading-bar/core'import { PeerTubeProblemDocument, ServerErrorCode, UserVideoQuota, VideoPrivacyType } from '@peertube/peertube-models'import debug from 'debug'-import { switchMap } from 'rxjs'+import { forkJoin, switchMap } from 'rxjs'import { SelectChannelItem } from 'src/types'import { SelectChannelComponent } from '../../../shared/shared-forms/select/select-channel.component'import { GlobalIconComponent } from '../../../shared/shared-icons/global-icon.component'import { HelpComponent } from '../../../shared/shared-main/buttons/help.component'import { VideoManageContainerComponent } from '../../shared-manage/video-manage-container.component'import { DragDropDirective } from '../shared/drag-drop.directive'+import { PlayerSettingsService } from '@app/shared/shared-video/player-settings.service'const debugLogger = debug('peertube:video-publish')@@ -45,6 +46,7 @@ export class VideoImportTorrentComponent implements OnInit, AfterViewInit, CanCoprivate loadingBar = inject(LoadingBarService)private notifier = inject(Notifier)private videoService = inject(VideoService)+ private playerSettingsService = inject(PlayerSettingsService)private videoImportService = inject(VideoImportService)private hooks = inject(HooksService)private serverService = inject(ServerService)@@ -131,10 +133,15 @@ export class VideoImportTorrentComponent implements OnInit, AfterViewInit, CanCothis.loadingBar.useRef().start()this.videoImportService.importVideo(videoEdit.toVideoImportCreate(this.highestPrivacy()))- .pipe(switchMap(({ video }) => this.videoService.getVideo({ videoId: video.uuid })))+ .pipe(switchMap(({ video }) => {+ return forkJoin([+ this.videoService.getVideo({ videoId: video.uuid }),+ this.playerSettingsService.getVideoSettings({ videoId: video.uuid, raw: true })+ ])+ })).subscribe({- next: async video => {- await videoEdit.loadFromAPI({ video, loadPrivacy: false })+ next: async ([ video, playerSettings ]) => {+ await videoEdit.loadFromAPI({ video, playerSettings, loadPrivacy: false })this.loadingBar.useRef().complete()diff --git a/client/src/app/+videos-publish-manage/+video-publish/import/video-import-url.component.ts b/client/src/app/+videos-publish-manage/+video-publish/import/video-import-url.component.tsindex 6a184eb906..003aac5b2f 100644--- a/client/src/app/+videos-publish-manage/+video-publish/import/video-import-url.component.ts+++ b/client/src/app/+videos-publish-manage/+video-publish/import/video-import-url.component.ts@@ -20,6 +20,7 @@ import { SelectChannelComponent } from '../../../shared/shared-forms/select/seleimport { GlobalIconComponent } from '../../../shared/shared-icons/global-icon.component'import { HelpComponent } from '../../../shared/shared-main/buttons/help.component'import { VideoManageContainerComponent } from '../../shared-manage/video-manage-container.component'+import { PlayerSettingsService } from '@app/shared/shared-video/player-settings.service'const debugLogger = debug('peertube:video-publish')@@ -51,6 +52,7 @@ export class VideoImportUrlComponent implements OnInit, AfterViewInit, CanComponprivate route = inject(ActivatedRoute)private chapterService = inject(VideoChapterService)private captionService = inject(VideoCaptionService)+ private playerSettingsService = inject(PlayerSettingsService)readonly userChannels = input.required<SelectChannelItem[]>()readonly userQuota = input.required<UserVideoQuota>()@@ -122,17 +124,18 @@ export class VideoImportUrlComponent implements OnInit, AfterViewInit, CanComponthis.videoImportService.importVideo(videoEdit.toVideoImportCreate(this.highestPrivacy())).pipe(- switchMap(previous => {+ switchMap(({ video }) => {return forkJoin([- this.captionService.listCaptions(previous.video.uuid),- this.chapterService.getChapters({ videoId: previous.video.uuid }),- this.videoService.getVideo({ videoId: previous.video.uuid })- ]).pipe(map(([ { data: captions }, { chapters }, video ]) => ({ captions, chapters, video })))+ this.captionService.listCaptions(video.uuid),+ this.chapterService.getChapters({ videoId: video.uuid }),+ this.playerSettingsService.getVideoSettings({ videoId: video.uuid, raw: true }),+ this.videoService.getVideo({ videoId: video.uuid })+ ]).pipe(map(([ { data: captions }, { chapters }, playerSettings, video ]) => ({ captions, chapters, playerSettings, video })))})).subscribe({- next: async ({ video, captions, chapters }) => {- await videoEdit.loadFromAPI({ video, captions, chapters, loadPrivacy: false })+ next: async ({ video, playerSettings, captions, chapters }) => {+ await videoEdit.loadFromAPI({ video, captions, playerSettings, chapters, loadPrivacy: false })this.loadingBar.useRef().complete()diff --git a/client/src/app/+videos-publish-manage/+video-publish/live/video-go-live.component.ts b/client/src/app/+videos-publish-manage/+video-publish/live/video-go-live.component.tsindex 0f72e23a90..9c198be07f 100644--- a/client/src/app/+videos-publish-manage/+video-publish/live/video-go-live.component.ts+++ b/client/src/app/+videos-publish-manage/+video-publish/live/video-go-live.component.ts@@ -5,9 +5,10 @@ import { VideoEdit } from '@app/+videos-publish-manage/shared-manage/common/videimport { VideoManageController } from '@app/+videos-publish-manage/shared-manage/video-manage-controller.service'import { AuthService, CanComponentDeactivate, HooksService, Notifier, ServerService } from '@app/core'import { LiveVideoService } from '@app/shared/shared-video-live/live-video.service'+import { PlayerSettingsService } from '@app/shared/shared-video/player-settings.service'import { LiveVideoLatencyMode, PeerTubeProblemDocument, ServerErrorCode, UserVideoQuota, VideoPrivacyType } from '@peertube/peertube-models'import debug from 'debug'-import { map, switchMap } from 'rxjs'+import { forkJoin, map, switchMap } from 'rxjs'import { SelectChannelItem } from 'src/types'import { SelectChannelComponent } from '../../../shared/shared-forms/select/select-channel.component'import { GlobalIconComponent } from '../../../shared/shared-icons/global-icon.component'@@ -38,6 +39,7 @@ export class VideoGoLiveComponent implements OnInit, AfterViewInit, CanComponentprivate hooks = inject(HooksService)private manageController = inject(VideoManageController)private route = inject(ActivatedRoute)+ private playerSettingsService = inject(PlayerSettingsService)readonly userChannels = input.required<SelectChannelItem[]>()readonly userQuota = input.required<UserVideoQuota>()@@ -100,14 +102,16 @@ export class VideoGoLiveComponent implements OnInit, AfterViewInit, CanComponentthis.liveVideoService.goLive(videoEdit.toLiveCreate(this.highestPrivacy())).pipe(switchMap(({ video }) => {- return this.liveVideoService.getVideoLive(video.uuid)- .pipe(map(live => ({ live, video })))+ return forkJoin([+ this.liveVideoService.getVideoLive(video.uuid),+ this.playerSettingsService.getVideoSettings({ videoId: video.uuid, raw: true })+ ]).pipe(map(([ live, playerSettings ]) => ({ live, playerSettings, video })))})).subscribe({- next: async ({ video: { id, uuid, shortUUID }, live }) => {+ next: async ({ video: { id, uuid, shortUUID }, live, playerSettings }) => {videoEdit.loadAfterPublish({ video: { id, uuid, shortUUID } })- await videoEdit.loadFromAPI({ live, loadPrivacy: false })+ await videoEdit.loadFromAPI({ live, playerSettings, loadPrivacy: false })debugLogger(`Live published`)diff --git a/client/src/app/+videos-publish-manage/shared-manage/common/unavailable-features.ts b/client/src/app/+videos-publish-manage/shared-manage/common/unavailable-features.tsindex c074a49227..c5ebf3fb0e 100644--- a/client/src/app/+videos-publish-manage/shared-manage/common/unavailable-features.ts+++ b/client/src/app/+videos-publish-manage/shared-manage/common/unavailable-features.ts@@ -15,7 +15,10 @@ export function getReplaceFileUnavailability (options: {if (isLive) return $localize`File replacement is not available on a live.`if (state === VideoState.TO_TRANSCODE) return $localize`File replacement is not available while the video is being transcoded.`if (state === VideoState.TO_EDIT) return $localize`File replacement is not available while the video is being edited.`- if (state === VideoState.TO_IMPORT) return $localize`File replacement is not available while the video is being imported.`++ if (state === VideoState.TO_IMPORT || state === VideoState.TO_IMPORT_FAILED) {+ return $localize`File replacement is not available while the video is being imported.`+ }return $localize`File replacement is not available.`}@@ -37,7 +40,10 @@ export function getStudioUnavailability (options: {if (isLive) return $localize`Studio is not available on a live.`if (state === VideoState.TO_TRANSCODE) return $localize`Studio is not available while the video is being transcoded.`if (state === VideoState.TO_EDIT) return $localize`Studio is not available while the video is being edited.`- if (state === VideoState.TO_IMPORT) return $localize`Studio is not available while the video is being imported.`++ if (state === VideoState.TO_IMPORT || state === VideoState.TO_IMPORT_FAILED) {+ return $localize`Studio is not available while the video is being imported.`+ }return $localize`Studio is not available.`}diff --git a/client/src/app/+videos-publish-manage/shared-manage/common/video-edit.model.ts b/client/src/app/+videos-publish-manage/shared-manage/common/video-edit.model.tsindex c90e32c83e..fc1216c7dd 100644--- a/client/src/app/+videos-publish-manage/shared-manage/common/video-edit.model.ts+++ b/client/src/app/+videos-publish-manage/shared-manage/common/video-edit.model.ts@@ -122,7 +122,7 @@ type UpdateFromAPIOptions = {captions?: VideoCaption[]videoPasswords?: string[]videoSource?: VideoSource- playerSettings?: PlayerVideoSettings+ playerSettings: PlayerVideoSettings}// ---------------------------------------------------------------------------diff --git a/client/src/app/+videos-publish-manage/shared-manage/video-manage-container.component.html b/client/src/app/+videos-publish-manage/shared-manage/video-manage-container.component.htmlindex 3601755d26..0ebc502ca0 100644--- a/client/src/app/+videos-publish-manage/shared-manage/video-manage-container.component.html+++ b/client/src/app/+videos-publish-manage/shared-manage/video-manage-container.component.html@@ -39,6 +39,12 @@<strong class="me-1">{{ getStateWarning().manageMain }}</strong><span>{{ getStateWarning().manageSecondary }}</span>++ @if (getStateWarning().routerLink) {+ <span class="ms-1">+ <a [routerLink]="getStateWarning().routerLink.link" [queryParams]="getStateWarning().routerLink.queryParams">{{ getStateWarning().routerLink.text }}</a>+ </span>+ }</div><my-manage-errors *ngIf="displayFormErrorsMsg && hasFormErrors()" class="d-block mt-2"></my-manage-errors>diff --git a/client/src/app/+videos-publish-manage/shared-manage/video-manage-container.component.ts b/client/src/app/+videos-publish-manage/shared-manage/video-manage-container.component.tsindex 548338d3bc..c7519d79d3 100644--- a/client/src/app/+videos-publish-manage/shared-manage/video-manage-container.component.ts+++ b/client/src/app/+videos-publish-manage/shared-manage/video-manage-container.component.ts@@ -75,7 +75,9 @@ export class VideoManageContainerComponent implements OnInit, OnDestroy {// ---------------------------------------------------------------------------getStateWarning () {- return this.videoStateMessage.buildWarn(this.videoEdit.getVideoAttributes().state)+ const video = this.videoEdit.getVideoAttributes()++ return this.videoStateMessage.buildWarn(video.id, video.state)}// ---------------------------------------------------------------------------diff --git a/client/src/app/shared/shared-main/video/video-import.service.ts b/client/src/app/shared/shared-main/video/video-import.service.tsindex 92e5a02b4f..abd613b57d 100644--- a/client/src/app/shared/shared-main/video/video-import.service.ts+++ b/client/src/app/shared/shared-main/video/video-import.service.ts@@ -41,6 +41,12 @@ export class VideoImportService {if (search) {const filters = this.restService.parseQueryStringFilter(search, {+ id: {+ prefix: 'id:'+ },+ videoId: {+ prefix: 'videoId:'+ },videoChannelSyncId: {prefix: 'videoChannelSyncId:'},@@ -70,6 +76,11 @@ export class VideoImportService {.pipe(catchError(err => this.restExtractor.handleError(err)))}+ retryVideoImport (videoImport: VideoImport) {+ return this.authHttp.post(VideoImportService.BASE_VIDEO_IMPORT_URL + videoImport.id + '/retry', {})+ .pipe(catchError(err => this.restExtractor.handleError(err)))+ }+private extractVideoImports (result: ResultList<VideoImport>): Observable<ResultList<VideoImport>> {return this.serverService.getServerLocale().pipe(diff --git a/client/src/app/shared/shared-main/video/video.model.ts b/client/src/app/shared/shared-main/video/video.model.tsindex f50a66c995..346dd2cd77 100644--- a/client/src/app/shared/shared-main/video/video.model.ts+++ b/client/src/app/shared/shared-main/video/video.model.ts@@ -320,6 +320,7 @@ export class Video implements VideoServerModel {private transcodingAndTranscriptionIncompatibleStates () {return new Set<VideoStateType>([VideoState.TO_IMPORT,+ VideoState.TO_IMPORT_FAILED,VideoState.TO_EDIT,VideoState.TO_MOVE_TO_EXTERNAL_STORAGE,VideoState.TO_MOVE_TO_FILE_SYSTEMdiff --git a/client/src/app/shared/shared-video/video-state-badge.component.ts b/client/src/app/shared/shared-video/video-state-badge.component.tsindex de569dbed8..8c9b24fe4c 100644--- a/client/src/app/shared/shared-video/video-state-badge.component.ts+++ b/client/src/app/shared/shared-video/video-state-badge.component.ts@@ -14,6 +14,7 @@ export class VideoStateBadgeComponent implements OnChanges {[VideoState.PUBLISHED]: 'badge-green',[VideoState.TO_TRANSCODE]: 'badge-brown',[VideoState.TO_IMPORT]: 'badge-brown',+ [VideoState.TO_IMPORT_FAILED]: 'badge-red',[VideoState.WAITING_FOR_LIVE]: 'badge-blue',[VideoState.LIVE_ENDED]: 'badge-green',[VideoState.TO_MOVE_TO_EXTERNAL_STORAGE]: 'badge-brown',@@ -97,6 +98,10 @@ export class VideoStateBadgeComponent implements OnChanges {this.label = $localize`To import`return+ case VideoState.TO_IMPORT_FAILED:+ this.label = $localize`Import failed`+ return+case VideoState.TO_EDIT:this.label = $localize`To edit`returndiff --git a/client/src/app/shared/shared-video/video-state-message.service.ts b/client/src/app/shared/shared-video/video-state-message.service.tsindex d724b12faf..9315885f15 100644--- a/client/src/app/shared/shared-video/video-state-message.service.ts+++ b/client/src/app/shared/shared-video/video-state-message.service.ts@@ -1,11 +1,36 @@import { Injectable } from '@angular/core'import { VideoState, VideoStateType } from '@peertube/peertube-models'+type WarnResult = {+ title: string+ manageMain: string+ manageSecondary: string+ watchMain: string+ watchSecondary: string++ routerLink?: {+ text: string+ link: string[]+ queryParams?: { [key: string]: any }+ }+}+@Injectable()export class VideoStateMessageService {- buildWarn (- state: VideoStateType- ): { title: string, manageMain: string, manageSecondary: string, watchMain: string, watchSecondary: string } {+ private cacheKey: string+ private cacheResult: WarnResult++ buildWarn (videoId: number, state: VideoStateType): WarnResult {+ const key = `${videoId}-${state}`+ if (this.cacheKey === key && this.cacheResult) return this.cacheResult++ this.cacheResult = this._buildWarn(videoId, state)+ this.cacheKey = key++ return this.cacheResult+ }++ private _buildWarn (videoId: number, state: VideoStateType): WarnResult {const manageProcessed = $localize`Your video file is being processed.`const manageFeaturesDisabled = $localize`This can take a while and some features may not be available until it is complete.`const manageContactAdmin = $localize`Contact your administrator to fix it.`@@ -32,9 +57,31 @@ export class VideoStateMessageService {manageMain: $localize`Your remote video is being imported.`,manageSecondary: manageFeaturesDisabled,watchMain: $localize`The remote video is being imported, it will be available when the import is complete.`,- watchSecondary: ''+ watchSecondary: '',+ routerLink: {+ text: $localize`Review your import`,+ link: [ '/my-library/video-imports' ],+ queryParams: { search: `videoId:${videoId}` }+ }}+ case VideoState.TO_IMPORT_FAILED: {+ const details = $localize`The remote video failed to import, it will not be available.`++ return {+ title: $localize`Import failed`,+ manageMain: $localize`Your remote video failed to import.`,+ manageSecondary: '',+ watchMain: details,+ watchSecondary: '',+ routerLink: {+ text: $localize`Review your import`,+ link: [ '/my-library/video-imports' ],+ queryParams: { search: `videoId:${videoId}` }+ }+ }+ }+case VideoState.TO_MOVE_TO_FILE_SYSTEM:return {title: $localize`Moving video files`,diff --git a/config/default.yaml b/config/default.yamlindex f43646264b..cfb45cc0bd 100644--- a/config/default.yaml+++ b/config/default.yaml@@ -806,6 +806,9 @@ import:# Set a custom video import timeout to not block import queuetimeout: '2 hours'+ # Number of attempts a user or the channel sync process can do to import a video if an error occurs during the import process+ max_attempts: 3+# Classic HTTP or all sites supported by youtube-dl https://rg3.github.io/youtube-dl/supportedsites.htmlhttp:# We recommend to use a HTTP proxy if you enable HTTP import to prevent private URL access from this serverdiff --git a/packages/models/src/server/job.model.ts b/packages/models/src/server/job.model.tsindex 7ff8660ff0..95f8775f90 100644--- a/packages/models/src/server/job.model.ts+++ b/packages/models/src/server/job.model.ts@@ -99,26 +99,23 @@ export type VideoFileImportPayload = {export type VideoImportTorrentPayloadType = 'magnet-uri' | 'torrent-file'export type VideoImportYoutubeDLPayloadType = 'youtube-dl'-export interface VideoImportYoutubeDLPayload {- type: VideoImportYoutubeDLPayloadType+interface VideoImportAbstractPayload {+ preventException: booleanvideoImportId: number-generateTranscription: boolean+}++export interface VideoImportYoutubeDLPayload extends VideoImportAbstractPayload {+ type: VideoImportYoutubeDLPayloadTypefileExt?: string}-export interface VideoImportTorrentPayload {+export interface VideoImportTorrentPayload extends VideoImportAbstractPayload {type: VideoImportTorrentPayloadType-- generateTranscription: boolean-- videoImportId: number}-export type VideoImportPayload = (VideoImportYoutubeDLPayload | VideoImportTorrentPayload) & {- preventException: boolean-}+export type VideoImportPayload = VideoImportYoutubeDLPayload | VideoImportTorrentPayloadexport interface VideoImportPreventExceptionResult {resultType: 'success' | 'error'diff --git a/packages/models/src/videos/import/video-import.model.ts b/packages/models/src/videos/import/video-import.model.tsindex eef23f401d..97a6cbf6ae 100644--- a/packages/models/src/videos/import/video-import.model.ts+++ b/packages/models/src/videos/import/video-import.model.ts@@ -9,6 +9,8 @@ export interface VideoImport {magnetUri: stringtorrentName: string+ attempts: number+createdAt: stringupdatedAt: stringoriginallyPublishedAt?: stringdiff --git a/packages/models/src/videos/video-state.enum.ts b/packages/models/src/videos/video-state.enum.tsindex 6eb60d7a19..d1d5292c2a 100644--- a/packages/models/src/videos/video-state.enum.ts+++ b/packages/models/src/videos/video-state.enum.ts@@ -9,7 +9,8 @@ export const VideoState = {TO_MOVE_TO_EXTERNAL_STORAGE_FAILED: 8,TO_EDIT: 9,TO_MOVE_TO_FILE_SYSTEM: 10,- TO_MOVE_TO_FILE_SYSTEM_FAILED: 11+ TO_MOVE_TO_FILE_SYSTEM_FAILED: 11,+ TO_IMPORT_FAILED: 12} as constexport type VideoStateType = typeof VideoState[keyof typeof VideoState]diff --git a/packages/server-commands/src/videos/video-imports-command.ts b/packages/server-commands/src/videos/video-imports-command.tsindex 0a7ba1f3c8..aa4e5626df 100644--- a/packages/server-commands/src/videos/video-imports-command.ts+++ b/packages/server-commands/src/videos/video-imports-command.ts@@ -94,21 +94,39 @@ export class VideoImportsCommand extends AbstractCommand {})}+ retry (+ options: OverrideCommandOptions & {+ importId: number+ }+ ) {+ const path = '/api/v1/videos/imports/' + options.importId + '/retry'++ return this.postBodyRequest({+ ...options,++ path,+ implicitToken: true,+ defaultExpectedStatus: HttpStatusCode.NO_CONTENT_204+ })+ }+listMyVideoImports (options: OverrideCommandOptions & {+ id?: number+ videoId?: numbersort?: stringtargetUrl?: stringvideoChannelSyncId?: numbersearch?: stringincludeCollaborations?: boolean} = {}) {- const { sort, targetUrl, videoChannelSyncId, search, includeCollaborations } = options+ const { id, videoId, sort, targetUrl, videoChannelSyncId, search, includeCollaborations } = optionsconst path = '/api/v1/users/me/videos/imports'return this.getRequestBody<ResultList<VideoImport>>({...options,path,- query: { sort, targetUrl, videoChannelSyncId, search, includeCollaborations },+ query: { id, videoId, sort, targetUrl, videoChannelSyncId, search, includeCollaborations },implicitToken: true,defaultExpectedStatus: HttpStatusCode.OK_200})diff --git a/packages/tests/src/api/check-params/video-imports.ts b/packages/tests/src/api/check-params/video-imports.tsindex 4981907ac7..8eb47f6c35 100644--- a/packages/tests/src/api/check-params/video-imports.ts+++ b/packages/tests/src/api/check-params/video-imports.ts@@ -16,6 +16,7 @@ import {} from '@peertube/peertube-server-commands'import { checkBadCountPagination, checkBadSortPagination, checkBadStartPagination } from '@tests/shared/checks.js'import { FIXTURE_URLS } from '@tests/shared/fixture-urls.js'+import { SQLCommand } from '@tests/shared/sql-command.js'describe('Test video imports API validator', function () {const path = '/api/v1/videos/imports'@@ -62,6 +63,14 @@ describe('Test video imports API validator', function () {await checkBadSortPagination(server.url, myPath, server.accessToken)})+ it('Should fail with a bad id param', async function () {+ await makeGetRequest({ url: server.url, path: myPath, query: { id: 'toto' }, token: server.accessToken })+ })++ it('Should fail with a bad video id param', async function () {+ await makeGetRequest({ url: server.url, path: myPath, query: { videoId: 'toto' }, token: server.accessToken })+ })+it('Should fail with a bad videoChannelSyncId param', async function () {await makeGetRequest({url: server.url,@@ -491,6 +500,73 @@ describe('Test video imports API validator', function () {})})+ describe('Retrying a video import', function () {+ let sqlCommand: SQLCommand+ let importId: number+ let successId: number++ before(async function () {+ this.timeout(60000)++ sqlCommand = new SQLCommand(server)++ await server.jobs.pauseJobQueue()++ {+ const res = await server.videoImports.quickImport({ name: 'To retry', targetUrl: FIXTURE_URLS.goodVideo })+ importId = res.id+ }++ await sqlCommand.setImportUrl(importId, FIXTURE_URLS.badVideo)+ await server.jobs.resumeJobQueue()++ {+ const res = await server.videoImports.quickImport({ name: 'Success', targetUrl: FIXTURE_URLS.goodVideo })+ successId = res.id+ }++ await waitJobs([ server ])+ })++ it('Should fail with an invalid import id', async function () {+ await server.videoImports.retry({ importId: 'artyom' as any, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })+ })++ it('Should fail with an unknown import id', async function () {+ await server.videoImports.retry({ importId: 42, expectedStatus: HttpStatusCode.NOT_FOUND_404 })+ })++ it('Should fail without token', async function () {+ await server.videoImports.retry({ importId, token: null, expectedStatus: HttpStatusCode.UNAUTHORIZED_401 })+ })++ it('Should fail with another user token', async function () {+ await server.videoImports.retry({ importId, token: userAccessToken, expectedStatus: HttpStatusCode.FORBIDDEN_403 })+ })++ it('Should fail with non failed import', async function () {+ this.timeout(60000)++ await server.videoImports.retry({ importId: successId, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })+ })++ it('Should succeed to retry', async function () {+ await server.videoImports.retry({ importId, token: editorToken })+ })++ it('Should fail to retry too many times an import', async function () {+ await waitJobs([ server ])++ await server.videoImports.retry({ importId, token: editorToken })++ await server.videoImports.retry({ importId, token: editorToken, expectedStatus: HttpStatusCode.BAD_REQUEST_400 })+ })++ after(async function () {+ await sqlCommand?.cleanup()+ })+ })+after(async function () {await cleanupTests([ server ])})diff --git a/packages/tests/src/api/videos/video-channel-syncs.ts b/packages/tests/src/api/videos/video-channel-syncs.tsindex e7ba73a91d..cff1f33f35 100644--- a/packages/tests/src/api/videos/video-channel-syncs.ts+++ b/packages/tests/src/api/videos/video-channel-syncs.ts@@ -1,6 +1,6 @@/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */-import { VideoChannelSyncState, VideoInclude, VideoPrivacy } from '@peertube/peertube-models'+import { VideoChannelSyncState, VideoImportState, VideoInclude, VideoPrivacy } from '@peertube/peertube-models'import { areHttpImportTestsDisabled, areYoutubeImportTestsDisabled } from '@peertube/peertube-node-utils'import {cleanupTests,@@ -226,6 +226,33 @@ describe('Test channel synchronizations', function () {expect(total).to.equal(0)})+ it('Should retry failed import jobs', async function () {+ this.timeout(120_000)++ const { data } = await servers[0].videoImports.listMyVideoImports({ videoChannelSyncId: rootChannelSyncId })+ const importId = data[0].id++ await sqlCommands[0].setImportUrl(importId, 'http://fail.example.com')+ await sqlCommands[0].setImportState(importId, VideoImportState.FAILED)++ for (let i = 2; i < 7; i++) {+ await servers[0].debug.sendCommand({+ body: {+ command: 'process-video-channel-sync-latest'+ }+ })++ await waitJobs(servers)++ {+ const { data } = await servers[0].videoImports.listMyVideoImports({ videoChannelSyncId: rootChannelSyncId })+ expect(data[0].state.id).to.equal(VideoImportState.FAILED)+ expect(data[0].error).to.include('fail.example.com')+ expect(data[0].attempts).to.equal(Math.min(3, i))+ }+ }+ })+// 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)diff --git a/packages/tests/src/api/videos/video-imports.ts b/packages/tests/src/api/videos/video-imports.tsindex 6579edbe0c..9af9de5b4d 100644--- a/packages/tests/src/api/videos/video-imports.ts+++ b/packages/tests/src/api/videos/video-imports.ts@@ -17,6 +17,7 @@ import { DeepPartial } from '@peertube/peertube-typescript-utils'import { testCaptionFile } from '@tests/shared/captions.js'import { testImageGeneratedByFFmpeg } from '@tests/shared/checks.js'import { FIXTURE_URLS } from '@tests/shared/fixture-urls.js'+import { SQLCommand } from '@tests/shared/sql-command.js'import { expect } from 'chai'import { pathExists, remove } from 'fs-extra/esm'import { readdir } from 'fs/promises'@@ -86,6 +87,8 @@ describe('Test video imports', function () {function runSuite (mode: 'youtube-dl' | 'yt-dlp') {describe('Import ' + mode, function () {let servers: PeerTubeServer[] = []+ let importId: number+ let importVideoId: numberbefore(async function () {this.timeout(60_000)@@ -114,7 +117,10 @@ describe('Test video imports', function () {this.timeout(60_000)const attributes = { privacy: VideoPrivacy.PUBLIC, targetUrl: FIXTURE_URLS.youtube }- const { video } = await servers[0].videoImports.importVideo({ attributes })+ const { video, id } = await servers[0].videoImports.importVideo({ attributes })+ importId = id+ importVideoId = video.id+expect(video.name).to.equal('small video - youtube'){@@ -242,6 +248,26 @@ describe('Test video imports', function () {}})+ it('Should filter my imports on id', async function () {+ if (areYoutubeImportTestsDisabled()) return++ const { total, data: videoImports } = await servers[0].videoImports.listMyVideoImports({ id: importId })+ expect(total).to.equal(1)+ expect(videoImports).to.have.lengthOf(1)++ expect(videoImports[0].id).to.equal(importId)+ })++ it('Should filter my imports on videoId', async function () {+ if (areYoutubeImportTestsDisabled()) return++ const { total, data: videoImports } = await servers[0].videoImports.listMyVideoImports({ videoId: importVideoId })+ expect(total).to.equal(1)+ expect(videoImports).to.have.lengthOf(1)++ expect(videoImports[0].id).to.equal(importId)+ })+it('Should filter my imports on target URL', async function () {if (areYoutubeImportTestsDisabled()) return@@ -531,8 +557,9 @@ describe('Test video imports', function () {runSuite('yt-dlp')- describe('Delete/cancel an import', function () {+ describe('Managing an import', function () {let server: PeerTubeServer+ let sqlCommand: SQLCommandlet finishedImportId: numberlet finishedVideo: Video@@ -549,6 +576,7 @@ describe('Test video imports', function () {this.timeout(120_000)server = await createSingleServer(1)+ sqlCommand = new SQLCommand(server)await setAccessTokensToServers([ server ])await setDefaultVideoChannel([ server ])@@ -609,7 +637,39 @@ describe('Test video imports', function () {expect(data).to.have.lengthOf(0)})+ it('Should fail an import', async function () {+ await server.jobs.pauseJobQueue()++ pendingImportId = await importVideo('to retry')++ await sqlCommand.setImportUrl(pendingImportId, FIXTURE_URLS.badVideo)+ await server.jobs.resumeJobQueue()++ await waitJobs([ server ])++ const { data } = await server.videoImports.listMyVideoImports()+ expect(data[0].state.id).to.equal(VideoImportState.FAILED)++ const video = await server.videos.getWithToken({ id: data[0].video.id })+ expect(video.state.id).to.equal(VideoState.TO_IMPORT_FAILED)+ })++ it('Should retry an import job', async function () {+ await sqlCommand.setImportUrl(pendingImportId, FIXTURE_URLS.goodVideo)++ await server.videoImports.retry({ importId: pendingImportId })+ await waitJobs([ server ])++ const { data } = await server.videoImports.listMyVideoImports()+ expect(data[0].state.id).to.equal(VideoImportState.SUCCESS)++ const video = await server.videos.getWithToken({ id: data[0].video.id })+ expect(video.state.id).to.equal(VideoState.PUBLISHED)+ })+after(async function () {+ await sqlCommand?.cleanup()+await cleanupTests([ server ])})})diff --git a/packages/tests/src/shared/sql-command.ts b/packages/tests/src/shared/sql-command.tsindex 0e61e750a0..49ba8e0de1 100644--- a/packages/tests/src/shared/sql-command.ts+++ b/packages/tests/src/shared/sql-command.ts@@ -1,5 +1,5 @@import { forceNumber } from '@peertube/peertube-core-utils'-import { FileStorageType, RunnerJobPayload } from '@peertube/peertube-models'+import { FileStorageType, RunnerJobPayload, VideoImportStateType } from '@peertube/peertube-models'import { PeerTubeServer } from '@peertube/peertube-server-commands'import { QueryTypes, Sequelize } from 'sequelize'@@ -7,7 +7,6 @@ export class SQLCommand {private sequelize: Sequelizeconstructor (private readonly server: PeerTubeServer) {-}deleteAll (table: string) {@@ -62,17 +61,17 @@ export class SQLCommand {async setVideoFileStorageOf (uuid: string, storage: FileStorageType) {await this.updateQuery(`UPDATE "videoFile" SET storage = :storage ` +- `WHERE "videoId" IN (SELECT id FROM "video" WHERE uuid = :uuid) OR ` +- `"videoStreamingPlaylistId" IN (` ++ `WHERE "videoId" IN (SELECT id FROM "video" WHERE uuid = :uuid) OR ` ++ `"videoStreamingPlaylistId" IN (` +`SELECT "videoStreamingPlaylist".id FROM "videoStreamingPlaylist" ` +`INNER JOIN video ON video.id = "videoStreamingPlaylist"."videoId" AND "video".uuid = :uuid` +- `)`,+ `)`,{ storage, uuid })await this.updateQuery(`UPDATE "videoStreamingPlaylist" SET storage = :storage ` +- `WHERE "videoId" IN (SELECT id FROM "video" WHERE uuid = :uuid)`,+ `WHERE "videoId" IN (SELECT id FROM "video" WHERE uuid = :uuid)`,{ storage, uuid })@@ -101,6 +100,22 @@ export class SQLCommand {// ---------------------------------------------------------------------------+ async setImportUrl (videoImportId: number, importUrl: string) {+ await this.updateQuery(+ `UPDATE "videoImport" SET "targetUrl" = :importUrl WHERE id = :videoImportId`,+ { importUrl, videoImportId }+ )+ }++ async setImportState (videoImportId: number, state: VideoImportStateType) {+ await this.updateQuery(+ `UPDATE "videoImport" SET "state" = :state WHERE id = :videoImportId`,+ { state, videoImportId }+ )+ }++ // ---------------------------------------------------------------------------+setPluginVersion (pluginName: string, newVersion: string) {return this.setPluginField(pluginName, 'version', newVersion)}@@ -118,7 +133,7 @@ export class SQLCommand {// ---------------------------------------------------------------------------- selectQuery <T extends object> (query: string, replacements: { [id: string]: string | number } = {}) {+ selectQuery<T extends object> (query: string, replacements: { [id: string]: string | number } = {}) {const seq = this.getSequelize()const options = {type: QueryTypes.SELECT as QueryTypes.SELECT,diff --git a/server/core/controllers/api/users/me.ts b/server/core/controllers/api/users/me.tsindex cf6e592c91..349259b3c2 100644--- a/server/core/controllers/api/users/me.ts+++ b/server/core/controllers/api/users/me.ts@@ -212,7 +212,7 @@ async function listMyVideoImports (req: express.Request, res: express.Response)? user.Account.id: undefined,- ...pick(req.query, [ 'targetUrl', 'start', 'count', 'sort', 'search', 'videoChannelSyncId', 'includeCollaborations' ])+ ...pick(req.query, [ 'id', 'videoId', 'targetUrl', 'start', 'count', 'sort', 'search', 'videoChannelSyncId', 'includeCollaborations' ])})return res.json(getFormattedObjects(resultList.data, resultList.total))diff --git a/server/core/controllers/api/videos/import.ts b/server/core/controllers/api/videos/import.tsindex 9d3e02197a..30506efa2b 100644--- a/server/core/controllers/api/videos/import.ts+++ b/server/core/controllers/api/videos/import.ts@@ -7,6 +7,7 @@ import {VideoImportPayload,VideoImportState} from '@peertube/peertube-models'+import { retryImport } from '@server/lib/video-post-import.js'import { buildVideoFromImport, buildYoutubeDLImport, insertFromImportIntoDB, YoutubeDlImportError } from '@server/lib/video-pre-import.js'import { MThumbnail, MVideoThumbnail } from '@server/types/models/index.js'import express from 'express'@@ -30,7 +31,8 @@ import {authenticate,videoImportAddValidator,videoImportCancelValidator,- videoImportDeleteValidator+ videoImportDeleteValidator,+ videoImportRetryValidator} from '../../../middlewares/index.js'const auditLogger = auditLoggerFactory('video-imports')@@ -56,6 +58,13 @@ videoImportsRouter.post(asyncRetryTransactionMiddleware(cancelVideoImport))+videoImportsRouter.post(+ '/imports/:id/retry',+ authenticate,+ asyncMiddleware(videoImportRetryValidator),+ asyncRetryTransactionMiddleware(retryVideoImport)+)+videoImportsRouter.delete('/imports/:id',authenticate,@@ -88,6 +97,14 @@ async function cancelVideoImport (req: express.Request, res: express.Response) {return res.sendStatus(HttpStatusCode.NO_CONTENT_204)}+async function retryVideoImport (req: express.Request, res: express.Response) {+ const videoImport = res.locals.videoImport++ await retryImport(videoImport)++ return res.sendStatus(HttpStatusCode.NO_CONTENT_204)+}+function handleVideoImport (req: express.Request, res: express.Response) {if (req.body.targetUrl) return handleYoutubeDlImport(req, res)@@ -149,6 +166,10 @@ async function handleTorrentImport (req: express.Request, res: express.Response,preventException: false,generateTranscription: body.generateTranscription}++ videoImport.payload = payload+ await videoImport.save()+await JobQueue.Instance.createJob({ type: 'video-import', payload })auditLogger.create(getAuditIdFromRes(res), new VideoImportAuditView(videoImport.toFormattedJSON()))diff --git a/server/core/helpers/youtube-dl/youtube-dl-cli.ts b/server/core/helpers/youtube-dl/youtube-dl-cli.tsindex f8a6488554..d86fea4dc7 100644--- a/server/core/helpers/youtube-dl/youtube-dl-cli.ts+++ b/server/core/helpers/youtube-dl/youtube-dl-cli.ts@@ -213,7 +213,8 @@ export class YoutubeDLCLI {}) {const { url, args, timeout, processOptions } = options- let completeArgs = this.wrapWithProxyOptions(args)+ let completeArgs = this.wrapWithJSRuntimeOptions(args)+ completeArgs = this.wrapWithProxyOptions(completeArgs)completeArgs = this.wrapWithIPOptions(completeArgs)completeArgs = this.wrapWithFFmpegOptions(completeArgs)@@ -236,6 +237,14 @@ export class YoutubeDLCLI {: undefined}+ private wrapWithJSRuntimeOptions (args: string[]) {+ if (CONFIG.IMPORT.VIDEOS.HTTP.YOUTUBE_DL_RELEASE.NAME === 'yt-dlp') {+ return [ '--js-runtimes', 'node' ].concat(args)+ }++ return args+ }+private wrapWithProxyOptions (args: string[]) {const config = CONFIG.IMPORT.VIDEOS.HTTP.PROXIESconst configProxyEnabled = Array.isArray(config) && config.length !== 0diff --git a/server/core/helpers/youtube-dl/youtube-dl-wrapper.ts b/server/core/helpers/youtube-dl/youtube-dl-wrapper.tsindex d5acb371a7..38eaeb7d12 100644--- a/server/core/helpers/youtube-dl/youtube-dl-wrapper.ts+++ b/server/core/helpers/youtube-dl/youtube-dl-wrapper.ts@@ -23,13 +23,11 @@ const processOptions = {}class YoutubeDLWrapper {-constructor (private readonly url: string,private readonly enabledResolutions: VideoResolutionType[],private readonly useBestFormat: boolean) {-}async getInfoForDownload (youtubeDLArgs: string[] = []): Promise<YoutubeDLInfo> {diff --git a/server/core/initializers/config.ts b/server/core/initializers/config.tsindex 41d5e89e2a..66a53bd66a 100644--- a/server/core/initializers/config.ts+++ b/server/core/initializers/config.ts@@ -806,6 +806,9 @@ const CONFIG = {get TIMEOUT () {return parseDurationToMs(config.get<string>('import.videos.timeout'))},+ get MAX_ATTEMPTS () {+ return config.get<number>('import.videos.max_attempts')+ },HTTP: {get ENABLED () {diff --git a/server/core/initializers/constants.ts b/server/core/initializers/constants.tsindex 8919eb04bf..40f807025b 100644--- a/server/core/initializers/constants.ts+++ b/server/core/initializers/constants.ts@@ -58,7 +58,7 @@ import { CONFIG, registerConfigChangedHandler } from './config.js'// ----------------------------------------------------------------------------export const LAST_MIGRATION_VERSION = 945+export const LAST_MIGRATION_VERSION = 950// ---------------------------------------------------------------------------@@ -624,7 +624,8 @@ export const VIDEO_STATES: { [id in VideoStateType]: string } = {[VideoState.TO_MOVE_TO_EXTERNAL_STORAGE_FAILED]: 'External storage move failed',[VideoState.TO_EDIT]: 'To edit',[VideoState.TO_MOVE_TO_FILE_SYSTEM]: 'To move to file system',- [VideoState.TO_MOVE_TO_FILE_SYSTEM_FAILED]: 'Move to file system failed'+ [VideoState.TO_MOVE_TO_FILE_SYSTEM_FAILED]: 'Move to file system failed',+ [VideoState.TO_IMPORT_FAILED]: 'Import failed'}export const VIDEO_IMPORT_STATES: { [id in VideoImportStateType]: string } = {diff --git a/server/core/initializers/migrations/0950-retry-import.ts b/server/core/initializers/migrations/0950-retry-import.tsnew file mode 100644index 0000000000..73aa8ed64a--- /dev/null+++ b/server/core/initializers/migrations/0950-retry-import.ts@@ -0,0 +1,31 @@+import * as Sequelize from 'sequelize'++async function up (utils: {+ transaction: Sequelize.Transaction+ queryInterface: Sequelize.QueryInterface+ sequelize: Sequelize.Sequelize+}): Promise<void> {+ {+ await utils.queryInterface.addColumn('videoImport', 'attempts', {+ type: Sequelize.DataTypes.INTEGER,+ allowNull: false,+ defaultValue: 0+ }, { transaction: utils.transaction })+ }++ {+ await utils.queryInterface.addColumn('videoImport', 'payload', {+ type: Sequelize.DataTypes.JSONB,+ allowNull: true+ }, { transaction: utils.transaction })+ }+}++function down (options) {+ throw new Error('Not implemented.')+}++export {+ down,+ up+}diff --git a/server/core/lib/job-queue/handlers/video-import.ts b/server/core/lib/job-queue/handlers/video-import.tsindex a5c8fe05b4..a5115cfe97 100644--- a/server/core/lib/job-queue/handlers/video-import.ts+++ b/server/core/lib/job-queue/handlers/video-import.ts@@ -57,6 +57,13 @@ async function processVideoImport (job: Job): Promise<VideoImportPreventExceptioreturn { resultType: 'success' }}+ if (videoImport.attempts >= CONFIG.IMPORT.VIDEOS.MAX_ATTEMPTS) {+ logger.info('Do not process import since it has reached the maximum number of attempts', { payload, attempts: videoImport.attempts })++ return { resultType: 'error' }+ }++ videoImport.attempts += 1videoImport.state = VideoImportState.PROCESSINGawait videoImport.save()@@ -66,6 +73,8 @@ async function processVideoImport (job: Job): Promise<VideoImportPreventExceptioreturn { resultType: 'success' }} catch (err) {+ // Processors already handle video import state change on error+if (!payload.preventException) throw errlogger.warn('Catch error in video import to send value to parent job.', { payload, err })@@ -87,7 +96,9 @@ async function processTorrentImport (job: Job, videoImport: MVideoImportDefault,const options = { type: payload.type, generateTranscription: payload.generateTranscription, videoImportId: payload.videoImportId }const target = {- torrentName: videoImport.torrentName ? getSecureTorrentName(videoImport.torrentName) : undefined,+ torrentName: videoImport.torrentName+ ? getSecureTorrentName(videoImport.torrentName)+ : undefined,uri: videoImport.magnetUri}return processFile(() => downloadWebTorrentVideo(target, JOB_TTL['video-import']), videoImport, options)@@ -113,8 +124,16 @@ async function processYoutubeDLImport (job: Job, videoImport: MVideoImportDefaulasync function getVideoImportOrDie (payload: VideoImportPayload) {const videoImport = await VideoImportModel.loadAndPopulateVideo(payload.videoImportId)- if (!videoImport?.Video) {- throw new Error(`Cannot import video ${payload.videoImportId}: the video import or video linked to this import does not exist anymore.`)+ if (!videoImport) throw new Error('Video import not found')++ if (!videoImport.Video) {+ const err = new Error(+ `Cannot process video import ${payload.videoImportId}: the video import or video linked to this import does not exist anymore.`+ )++ await onImportError(err, null, videoImport)++ throw err}return videoImport@@ -328,11 +347,22 @@ async function onImportError (err: Error, tempVideoPath: string, videoImport: MVlogger.warn('Cannot cleanup files after a video import error.', { err: errUnlink })}- videoImport.error = err.message- if (videoImport.state !== VideoImportState.REJECTED) {- videoImport.state = VideoImportState.FAILED- }- await videoImport.save()+ await sequelizeTypescript.transaction(async t => {+ videoImport.error = err.message++ if (videoImport.state !== VideoImportState.REJECTED) {+ videoImport.state = VideoImportState.FAILED+ }++ await videoImport.save({ transaction: t })++ const video = await VideoModel.load(videoImport.videoId, t)++ if (video) {+ video.state = VideoState.TO_IMPORT_FAILED+ await video.save({ transaction: t })+ }+ })Notifier.Instance.notifyOnFinishedVideoImport({ videoImport, success: false })}diff --git a/server/core/lib/schedulers/video-channel-sync-latest-scheduler.ts b/server/core/lib/schedulers/video-channel-sync-latest-scheduler.tsindex 2273265ac5..9cac65914c 100644--- a/server/core/lib/schedulers/video-channel-sync-latest-scheduler.ts+++ b/server/core/lib/schedulers/video-channel-sync-latest-scheduler.ts@@ -1,10 +1,14 @@-import { logger } from '@server/helpers/logger.js'+import { logger, loggerTagsFactory } from '@server/helpers/logger.js'import { CONFIG } from '@server/initializers/config.js'import { VideoChannelModel } from '@server/models/video/video-channel.js'import { VideoChannelSyncModel } from '@server/models/video/video-channel-sync.js'import { SCHEDULER_INTERVALS_MS } from '../../initializers/constants.js'import { synchronizeChannel } from '../sync-channel.js'import { AbstractScheduler } from './abstract-scheduler.js'+import { VideoImportModel } from '@server/models/video/video-import.js'+import { retryImport } from '../video-post-import.js'++const lTags = loggerTagsFactory('channel-synchronization')export class VideoChannelSyncLatestScheduler extends AbstractScheduler {private static instance: AbstractScheduler@@ -16,11 +20,11 @@ export class VideoChannelSyncLatestScheduler extends AbstractScheduler {protected async internalExecute () {if (!CONFIG.IMPORT.VIDEO_CHANNEL_SYNCHRONIZATION.ENABLED) {- logger.debug('Discard channels synchronization as the feature is disabled')+ logger.debug('Discard channels synchronization as the feature is disabled', lTags())return}- logger.info('Checking channels to synchronize')+ logger.info('Checking channels to synchronize', lTags())const channelSyncs = await VideoChannelSyncModel.listSyncs()@@ -28,9 +32,8 @@ export class VideoChannelSyncLatestScheduler extends AbstractScheduler {const channel = await VideoChannelModel.loadAndPopulateAccount(sync.videoChannelId)logger.info(- 'Creating video import jobs for "%s" sync with external channel "%s"',- channel.Actor.preferredUsername,- sync.externalChannelUrl+ `Creating video import jobs for "${channel.Actor.preferredUsername}" sync with external channel "${sync.externalChannelUrl}"`,+ lTags())// We can't rely on publication date for playlist elements@@ -46,6 +49,15 @@ export class VideoChannelSyncLatestScheduler extends AbstractScheduler {channelSync: sync,skipPublishedBefore})++ const failed = await VideoImportModel.listFailedBySyncId({ channelSyncId: sync.id })+ for (const videoImport of failed) {+ logger.info(+ `Retrying failed video import (id: ${videoImport.id}) for channel "${channel.Actor.preferredUsername}"`,+ lTags()+ )+ await retryImport(videoImport)+ }}}diff --git a/server/core/lib/video-post-import.ts b/server/core/lib/video-post-import.tsnew file mode 100644index 0000000000..511a0ef536--- /dev/null+++ b/server/core/lib/video-post-import.ts@@ -0,0 +1,28 @@+import { VideoImportPayload, VideoImportState, VideoImportYoutubeDLPayload } from '@peertube/peertube-models'+import { CONFIG } from '@server/initializers/config.js'+import { MVideoImport } from '@server/types/models/video/video-import.js'+import { JobQueue } from './job-queue/job-queue.js'++export async function retryImport (videoImport: MVideoImport) {+ let type: VideoImportPayload['type']++ if (videoImport.magnetUri) type = 'magnet-uri'+ else if (videoImport.torrentName) type = 'torrent-file'+ else type = 'youtube-dl'++ const payload: VideoImportPayload = {+ type: videoImport.payload?.type ?? type,+ videoImportId: videoImport.id,++ // If part of a sync process, there is a parent job that will aggregate children results+ preventException: videoImport.payload?.preventException ?? !!videoImport.videoChannelSyncId,++ generateTranscription: videoImport.payload?.generateTranscription ?? CONFIG.VIDEO_TRANSCRIPTION.ENABLED,+ fileExt: (videoImport.payload as VideoImportYoutubeDLPayload)?.fileExt+ }++ await JobQueue.Instance.createJob({ type: 'video-import', payload })++ videoImport.state = VideoImportState.PENDING+ await videoImport.save()+}diff --git a/server/core/lib/video-pre-import.ts b/server/core/lib/video-pre-import.tsindex 87aec9127d..b92f353304 100644--- a/server/core/lib/video-pre-import.ts+++ b/server/core/lib/video-pre-import.ts@@ -83,7 +83,6 @@ async function insertFromImportIntoDB (parameters: {const videoImport = await sequelizeTypescript.transaction(async t => {const sequelizeOptions = { transaction: t }- // eslint-disable-next-line max-lenconst videoCreated = await video.save(sequelizeOptions) as (MVideoAccountDefault & MVideoWithBlacklistLight & MVideoTag & MVideoThumbnail)@@ -283,6 +282,9 @@ async function buildYoutubeDLImport (options: {preventException: !!channelSync}+ videoImport.payload = payload+ await videoImport.save()+return {videoImport,job: { type: 'video-import' as 'video-import', payload }diff --git a/server/core/middlewares/validators/videos/shared/video-validators.ts b/server/core/middlewares/validators/videos/shared/video-validators.tsindex cd9f06cbc1..85566b225e 100644--- a/server/core/middlewares/validators/videos/shared/video-validators.ts+++ b/server/core/middlewares/validators/videos/shared/video-validators.ts@@ -123,7 +123,8 @@ export function checkVideoCanBeTranscribed (video: MVideo, req: express.Request,VideoState.TO_IMPORT,VideoState.TO_EDIT,VideoState.TO_MOVE_TO_EXTERNAL_STORAGE,- VideoState.TO_MOVE_TO_FILE_SYSTEM+ VideoState.TO_MOVE_TO_FILE_SYSTEM,+ VideoState.TO_IMPORT_FAILED])if (incompatibleStates.has(video.state)) {res.fail({diff --git a/server/core/middlewares/validators/videos/video-imports.ts b/server/core/middlewares/validators/videos/video-imports.tsindex 1dc6724873..a93fa8ccda 100644--- a/server/core/middlewares/validators/videos/video-imports.ts+++ b/server/core/middlewares/validators/videos/video-imports.ts@@ -99,6 +99,14 @@ export const videoImportAddValidator = getCommonVideoEditAttributes().concat([])export const listMyVideoImportsValidator = [+ query('id')+ .optional()+ .custom(isIdValid),++ query('videoId')+ .optional()+ .custom(isIdValid),+query('videoChannelSyncId').optional().custom(isIdValid),@@ -156,6 +164,41 @@ export const videoImportCancelValidator = [}]+export const videoImportRetryValidator = [+ param('id')+ .custom(isIdValid),++ async (req: express.Request, res: express.Response, next: express.NextFunction) => {+ if (areValidationErrors(req, res)) return++ if (!await doesVideoImportExist(forceNumber(req.params.id), res)) return+ if (!await checkCanManageImport({ user: res.locals.oauth.token.User, videoImport: res.locals.videoImport, req, res })) return++ if (res.locals.videoImport.state !== VideoImportState.FAILED) {+ return res.fail({+ status: HttpStatusCode.BAD_REQUEST_400,+ message: req.t('Cannot retry a non failed video import')+ })+ }++ if (!res.locals.videoImport.Video) {+ return res.fail({+ status: HttpStatusCode.BAD_REQUEST_400,+ message: req.t('Cannot retry video import because the associated video metadata has been deleted')+ })+ }++ if (res.locals.videoImport.attempts >= CONFIG.IMPORT.VIDEOS.MAX_ATTEMPTS) {+ return res.fail({+ status: HttpStatusCode.BAD_REQUEST_400,+ message: req.t('Cannot retry video import since it has reached the maximum number of attempts')+ })+ }++ return next()+ }+]+// ---------------------------------------------------------------------------// Private// ---------------------------------------------------------------------------diff --git a/server/core/models/shared/model-builder.ts b/server/core/models/shared/model-builder.tsindex 3ec81ac2f5..89b6348981 100644--- a/server/core/models/shared/model-builder.ts+++ b/server/core/models/shared/model-builder.ts@@ -75,9 +75,13 @@ export class ModelBuilder<T extends SequelizeModel> {const association = Model.associations[tableName]if (!association) {- logger.error(`Cannot find association ${tableName} from key ${key} of model ${rootTableName}`, {- associations: Object.keys(Model.associations)- })+ if (!Model.getAttributes()[tableName]) {+ logger.error(`Cannot find association ${tableName} from key ${key} of model ${rootTableName}`, {+ associations: Object.keys(Model.associations),+ model: Model.getAttributes()+ })+ }+continue}diff --git a/server/core/models/shared/sql/actor-helpers.ts b/server/core/models/shared/sql/actor-helpers.tsindex a26642cafb..7ebf6a9a12 100644--- a/server/core/models/shared/sql/actor-helpers.ts+++ b/server/core/models/shared/sql/actor-helpers.ts@@ -20,29 +20,44 @@ export function getActorJoin (options: {export function getChannelJoin (options: {base?: stringon: string- includeAccount?: boolean // default false- includeAvatars?: boolean // default false+ includeAccount: boolean+ includeAvatars: boolean+ includeActors: boolean}) {- const { base = '', on, includeAccount = false, includeAvatars = false } = options+ const { base = '', on, includeAccount, includeAvatars, includeActors } = optionsconst accountJoin = includeAccount- ? getAccountJoin({ base: `${base}VideoChannel->`, on: `"${base}VideoChannel"."accountId"`, includeAvatars })+ ? getAccountJoin({+ base: `${base}VideoChannel->`,+ on: `"${base}VideoChannel"."accountId"`,+ includeAvatars,+ includeActor: includeActors+ })+ : ''++ const actorJoin = includeActors+ ? getActorJoin({ base: `${base}VideoChannel->`, on: `"${base}VideoChannel"."actorId"`, includeAvatars }): ''return ` LEFT JOIN "videoChannel" "${base}VideoChannel" ON "${base}VideoChannel"."id" = ${on} ` +- getActorJoin({ base: `${base}VideoChannel->`, on: `"${base}VideoChannel"."actorId"`, includeAvatars }) ++ actorJoin +accountJoin}export function getAccountJoin (options: {base?: stringon: string- includeAvatars?: boolean // default false+ includeAvatars: boolean+ includeActor: boolean}) {- const { base = '', on, includeAvatars = false } = options+ const { base = '', on, includeAvatars, includeActor } = options++ const actorJoin = includeActor+ ? getActorJoin({ base: `${base}Account->`, on: `"${base}Account"."actorId"`, includeAvatars })+ : ''return `LEFT JOIN "account" "${base}Account" ON "${base}Account"."id" = ${on} ` +- getActorJoin({ base: `${base}Account->`, on: `"${base}Account"."actorId"`, includeAvatars })+ actorJoin}export function getAvatarsJoin (options: {diff --git a/server/core/models/video/sql/comment/video-comment-list-query-builder.ts b/server/core/models/video/sql/comment/video-comment-list-query-builder.tsindex cf5f5ee4d7..4ca2e8ca32 100644--- a/server/core/models/video/sql/comment/video-comment-list-query-builder.ts+++ b/server/core/models/video/sql/comment/video-comment-list-query-builder.ts@@ -1,6 +1,6 @@import { VideoChannelCollaboratorState, VideoPrivacy } from '@peertube/peertube-models'import { AbstractListQuery, AbstractListQueryOptions } from '@server/models/shared/abstract-list-query.js'-import { getAvatarsJoin, getChannelJoin } from '@server/models/shared/sql/actor-helpers.js'+import { getAccountJoin, getActorJoin, getAvatarsJoin, getChannelJoin } from '@server/models/shared/sql/actor-helpers.js'import { Sequelize } from 'sequelize'import { createSafeIn } from '../../../shared/index.js'import { VideoCommentTableAttributes } from './video-comment-table-attributes.js'@@ -43,8 +43,10 @@ export class VideoCommentListQueryBuilder extends AbstractListQuery {private readonly tableAttributes = new VideoCommentTableAttributes()private builtAccountJoin = false+ private builtAccountActorJoin = falseprivate builtVideoJoin = falseprivate builtVideoChannelJoin = false+ private builtVideoChannelActorJoin = falseprivate builtVideoChannelCollaboratorsJoin = falseprivate builtAccountAvatarJoin = falseprivate builtChannelAvatarJoin = false@@ -120,10 +122,12 @@ export class VideoCommentListQueryBuilder extends AbstractListQuery {if (this.options.isLocal === true) {this.buildAccountJoin()+ this.buildAccountActorJoin()where.push('"Account->Actor"."serverId" IS NULL')} else if (this.options.isLocal === false) {this.buildAccountJoin()+ this.buildAccountActorJoin()where.push('"Account->Actor"."serverId" IS NOT NULL')}@@ -174,6 +178,7 @@ export class VideoCommentListQueryBuilder extends AbstractListQuery {if (this.options.search) {this.buildVideoJoin()this.buildAccountJoin()+ this.buildAccountActorJoin()const escapedLikeSearch = this.sequelize.escape('%' + this.options.search + '%')@@ -189,6 +194,7 @@ export class VideoCommentListQueryBuilder extends AbstractListQuery {if (this.options.searchAccount) {this.buildAccountJoin()+ this.buildAccountActorJoin()const escapedLikeSearch = this.sequelize.escape('%' + this.options.searchAccount + '%')@@ -218,13 +224,27 @@ export class VideoCommentListQueryBuilder extends AbstractListQuery {private buildAccountJoin () {if (this.builtAccountJoin) return- this.subQueryJoin += ' LEFT JOIN "account" "Account" ON "Account"."id" = "VideoCommentModel"."accountId" ' +- 'LEFT JOIN "actor" "Account->Actor" ON "Account->Actor"."id" = "Account"."actorId" ' +- 'LEFT JOIN "server" "Account->Actor->Server" ON "Account->Actor"."serverId" = "Account->Actor->Server"."id" '+ this.subQueryJoin += getAccountJoin({+ on: `"VideoCommentModel"."accountId"`,+ includeAvatars: false,+ includeActor: false+ })this.builtAccountJoin = true}+ private buildAccountActorJoin () {+ if (this.builtAccountActorJoin) return++ this.subQueryJoin += getActorJoin({+ base: 'Account->',+ on: `"Account"."actorId"`,+ includeAvatars: false+ })++ this.builtAccountActorJoin = true+ }+private buildVideoJoin () {if (this.builtVideoJoin) return@@ -240,11 +260,27 @@ export class VideoCommentListQueryBuilder extends AbstractListQuery {this.subQueryJoin += getChannelJoin({base: 'Video->',- on: '"Video"."channelId"'+ on: '"Video"."channelId"',+ includeAccount: false,+ includeAvatars: false,+ includeActors: false})this.builtVideoChannelJoin = true}++ private buildVideoChannelActorJoin () {+ if (this.builtVideoChannelActorJoin) return++ this.subQueryJoin += getActorJoin({+ base: 'Video->VideoChannel->',+ on: '"Video->VideoChannel"."actorId"',+ includeAvatars: false+ })++ this.builtVideoChannelActorJoin = true+ }+private buildVideoChannelCollaboratorsJoin () {if (this.builtVideoChannelCollaboratorsJoin) return@@ -329,11 +365,13 @@ export class VideoCommentListQueryBuilder extends AbstractListQuery {if (selectType === 'api-list' || selectType === 'api-video' || selectType === 'feed') {this.buildAccountJoin()+ this.buildAccountActorJoin()}if (selectType === 'api-list') {this.buildVideoJoin()this.buildVideoChannelJoin()+ this.buildVideoChannelActorJoin()}if (this.options.autoTagOfAccountId && selectType === 'api-list') {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 424bd939cc..c622fdac0f 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@@ -7,6 +7,8 @@ import { VideoImportTableAttributes } from './video-import-table-attributes.js'export interface ListVideoImportsOptions extends AbstractListQueryOptions {userId: number+ id?: number+ videoId?: numbersearch?: stringtargetUrl?: stringvideoChannelSyncId?: number@@ -62,6 +64,18 @@ export class VideoImportListQueryBuilder extends AbstractListQuery {this.replacements.userId = this.options.userId}+ if (this.options.id) {+ where.push('"VideoImportModel"."id" = :id')++ this.replacements.id = this.options.id+ }++ if (this.options.videoId) {+ where.push('"VideoImportModel"."videoId" = :videoId')++ this.replacements.videoId = this.options.videoId+ }+if (this.options.targetUrl) {where.push('"VideoImportModel"."targetUrl" = :targetUrl')@@ -96,7 +110,7 @@ export class VideoImportListQueryBuilder extends AbstractListQuery {if (this.builtVideoJoin) returnthis.subQueryJoin += ` LEFT JOIN "video" "Video" ON "Video"."id" = "VideoImportModel"."videoId" ` +- getChannelJoin({ base: 'Video->', on: '"Video"."channelId"', includeAccount: true })+ getChannelJoin({ base: 'Video->', on: '"Video"."channelId"', includeAccount: true, includeActors: true, includeAvatars: false })this.builtVideoJoin = true}diff --git a/server/core/models/video/sql/video-channel-sync/video-channel-sync-list-query-builder.ts b/server/core/models/video/sql/video-channel-sync/video-channel-sync-list-query-builder.tsindex 51f8c879d3..d83172f9e4 100644--- a/server/core/models/video/sql/video-channel-sync/video-channel-sync-list-query-builder.ts+++ b/server/core/models/video/sql/video-channel-sync/video-channel-sync-list-query-builder.ts@@ -56,7 +56,12 @@ export class VideoChannelSyncListQueryBuilder extends AbstractListQuery {private buildChannelJoin () {if (this.builtChannelJoin) return- this.subQueryJoin += getChannelJoin({ on: `"VideoChannelSyncModel"."videoChannelId"` })+ this.subQueryJoin += getChannelJoin({+ on: `"VideoChannelSyncModel"."videoChannelId"`,+ includeAccount: false,+ includeAvatars: false,+ includeActors: true+ })this.builtChannelJoin = true}diff --git a/server/core/models/video/video-import.ts b/server/core/models/video/video-import.tsindex 1b50961ded..97083fe5e3 100644--- a/server/core/models/video/video-import.ts+++ b/server/core/models/video/video-import.ts@@ -1,9 +1,7 @@-import { VideoImport, VideoImportState, type VideoImportStateType } from '@peertube/peertube-models'-import { afterCommitIfTransaction } from '@server/helpers/database-utils.js'-import { MVideoImportDefault, MVideoImportFormattable } from '@server/types/models/video/video-import.js'+import { VideoImport, type VideoImportPayload, VideoImportState, type VideoImportStateType } from '@peertube/peertube-models'+import { MVideoImport, MVideoImportDefault, MVideoImportFormattable } from '@server/types/models/video/video-import.js'import { Op } from 'sequelize'import {- AfterUpdate,AllowNull,BelongsTo,Column,@@ -24,6 +22,7 @@ import { UserModel } from '../user/user.js'import { ListVideoImportsOptions, VideoImportListQueryBuilder } from './sql/import/video-import-list-query-builder.js'import { VideoChannelSyncModel } from './video-channel-sync.js'import { VideoModel, ScopeNames as VideoModelScopeNames } from './video.js'+import { CONFIG } from '@server/initializers/config.js'const defaultVideoScope = () => {return VideoModel.scope([@@ -96,6 +95,15 @@ export class VideoImportModel extends SequelizeModel<VideoImportModel> {@Column(DataType.TEXT)declare error: string+ @AllowNull(false)+ @Default(0)+ @Column+ declare attempts: number++ @AllowNull(true)+ @Column(DataType.JSONB)+ declare payload: VideoImportPayload+@ForeignKey(() => UserModel)@Columndeclare userId: number@@ -132,15 +140,6 @@ export class VideoImportModel extends SequelizeModel<VideoImportModel> {})declare VideoChannelSync: Awaited<VideoChannelSyncModel>- @AfterUpdate- static deleteVideoIfFailed (instance: VideoImportModel, options) {- if (instance.state === VideoImportState.FAILED) {- return afterCommitIfTransaction(options.transaction, () => instance.Video.destroy())- }-- return undefined- }-// ---------------------------------------------------------------------------static getSQLAttributes (tableName: string, aliasPrefix = '') {@@ -173,12 +172,7 @@ export class VideoImportModel extends SequelizeModel<VideoImportModel> {}): Promise<boolean> {const { channelSyncId, channelId, targetUrl } = options- const baseWhere = {- targetUrl,- state: {- [Op.in]: [ VideoImportState.PENDING, VideoImportState.PROCESSING, VideoImportState.SUCCESS ]- }- }+ const baseWhere = { targetUrl }const bySyncId = channelSyncId? VideoImportModel.unscoped().findOne({@@ -206,6 +200,31 @@ export class VideoImportModel extends SequelizeModel<VideoImportModel> {return (await Promise.all([ bySyncId, byChannelId ])).some(e => !!e)}+ static listFailedBySyncId (options: {+ channelSyncId?: number+ }): Promise<MVideoImport[]> {+ return VideoImportModel.unscoped().findAll({+ include: [+ {+ model: VideoModel.unscoped(),+ required: true+ }+ ],+ where: {+ videoChannelSyncId: options.channelSyncId,+ state: {+ [Op.in]: [ VideoImportState.FAILED ]+ },+ attempts: {+ [Op.lt]: CONFIG.IMPORT.VIDEOS.MAX_ATTEMPTS+ }+ },+ limit: 100+ })+ }++ // ---------------------------------------------------------------------------+getTargetIdentifier () {return this.targetUrl || this.magnetUri || this.torrentName}@@ -230,6 +249,8 @@ export class VideoImportModel extends SequelizeModel<VideoImportModel> {magnetUri: this.magnetUri,torrentName: this.torrentName,+ attempts: this.attempts,+state: {id: this.state,label: VideoImportModel.getStateLabel(this.state)diff --git a/support/doc/api/openapi.yaml b/support/doc/api/openapi.yamlindex 46bfd081d9..585fa3b4db 100644--- a/support/doc/api/openapi.yaml+++ b/support/doc/api/openapi.yaml@@ -2228,10 +2228,18 @@ paths:- Videos- My Userparameters:+ - $ref: '#/components/parameters/id'- $ref: '#/components/parameters/start'- $ref: '#/components/parameters/count'- $ref: '#/components/parameters/sort'- $ref: '#/components/parameters/includeCollaborations'+ -+ name: videoId+ in: query+ required: false+ description: Filter on import video ID+ schema:+ type: integer-name: targetUrlin: query@@ -3625,6 +3633,20 @@ paths:'204':description: successful operation+ /api/v1/videos/imports/{id}/retry:+ post:+ summary: Retry video import+ description: "**PeerTube >= 8.0** Retry a pending video import"+ security:+ - OAuth2: []+ tags:+ - Video Imports+ parameters:+ - $ref: '#/components/parameters/id'+ responses:+ '204':+ description: successful operation+/api/v1/videos/imports/{id}:delete:summary: Delete video import@@ -4749,6 +4771,7 @@ paths:'/api/v1/video-channels/{channelHandle}/activities':get:summary: List activities of a video channel+ description: "**PeerTube >= 8.0**"operationId: listVideoChannelActivitiestags:- Video Channels@@ -7489,7 +7512,7 @@ paths:get:tags:- Video Channels- summary: List channel collaborators+ summary: "**PeerTube >= 8.0** List channel collaborators"operationId: listVideoChannelCollaboratorssecurity:- OAuth2: []@@ -7517,8 +7540,7 @@ paths:- Video Channelssummary: Invite a collaboratoroperationId: inviteVideoChannelCollaborator- description: >- Invite a local user to collaborate on the specified video channel.+ description: "**PeerTube >= 8.0** Invite a local user to collaborate on the specified video channel."security:- OAuth2: []parameters:@@ -7549,6 +7571,7 @@ paths:tags:- Video Channelssummary: Accept a collaboration invitation+ description: "**PeerTube >= 8.0**"operationId: acceptVideoChannelCollaboratorsecurity:- OAuth2: []@@ -7564,6 +7587,7 @@ paths:tags:- Video Channelssummary: Reject a collaboration invitation+ description: "**PeerTube >= 8.0**"operationId: rejectVideoChannelCollaboratorsecurity:- OAuth2: []@@ -7579,7 +7603,7 @@ paths:tags:- Video Channelssummary: Remove a channel collaborator- description: Only the channel owner or the collaborator themselves can remove a collaborator from a channel+ description: "**PeerTube >= 8.0** Only the channel owner or the collaborator themselves can remove a collaborator from a channel"operationId: removeVideoChannelCollaboratorsecurity:- OAuth2: []