ActivityPub-federated video streaming platform using P2P directly in your web browser
Add ability to retry import in videos list
Chocobozzz0f0e5ba7b7cc
diff --git a/client/src/app/+admin/moderation/automatic-tag-policies/automatic-tag-policies-admin.component.ts b/client/src/app/+admin/moderation/automatic-tag-policies/automatic-tag-policies-admin.component.tsindex 3a23cec4f6..6a827dfc64 100644--- a/client/src/app/+admin/moderation/automatic-tag-policies/automatic-tag-policies-admin.component.ts+++ b/client/src/app/+admin/moderation/automatic-tag-policies/automatic-tag-policies-admin.component.ts@@ -1,4 +1,4 @@-import { Component, OnInit, inject, ChangeDetectionStrategy } from '@angular/core'+import { ChangeDetectionStrategy, Component, OnInit, inject } from '@angular/core'import { FormsModule } from '@angular/forms'import { ActivatedRoute } from '@angular/router'import { HtmlRendererService, Notifier } from '@app/core'@@ -8,6 +8,7 @@ import { AutomaticTagAvailableType } from '@peertube/peertube-models'import { AutomaticTagPoliciesAdminTag } from './automatic-tag-policies-admin.resolver'@Component({+ selector: 'my-automatic-tag-policies-admin',templateUrl: './automatic-tag-policies-admin.component.html',changeDetection: ChangeDetectionStrategy.Eager,imports: [diff --git a/client/src/app/+admin/moderation/watched-words-list/watched-words-list-admin.component.ts b/client/src/app/+admin/moderation/watched-words-list/watched-words-list-admin.component.tsindex 303542df3d..1b1eb40123 100644--- a/client/src/app/+admin/moderation/watched-words-list/watched-words-list-admin.component.ts+++ b/client/src/app/+admin/moderation/watched-words-list/watched-words-list-admin.component.ts@@ -1,9 +1,10 @@-import { Component, ChangeDetectionStrategy } from '@angular/core'+import { ChangeDetectionStrategy, Component } from '@angular/core'import { RouterLink } from '@angular/router'import { WatchedWordsListAdminOwnerComponent } from '@app/shared/shared-watched-words/watched-words-list-admin-owner.component'@Component({+ selector: 'my-watched-words-list-admin',templateUrl: './watched-words-list-admin.component.html',changeDetection: ChangeDetectionStrategy.Eager,imports: [diff --git a/client/src/app/+admin/overview/videos/video-list.component.html b/client/src/app/+admin/overview/videos/video-list.component.htmlindex 906ec7a880..9df34e4a6b 100644--- a/client/src/app/+admin/overview/videos/video-list.component.html+++ b/client/src/app/+admin/overview/videos/video-list.component.html@@ -93,7 +93,7 @@placement="bottom auto" buttonIcon="more-horizontal" buttonStyled="true" [video]="video"[displayOptions]="videoActionsOptions" [muteStatus]="accountBlocklist.get(video.account.id)"(videoRemoved)="table.loadData()" (videoFilesRemoved)="table.loadData()" (transcodingCreated)="table.loadData()"- (muted)="loadBlockStatus()" (unmuted)="loadBlockStatus()"+ (muted)="loadBlockStatus()" (unmuted)="loadBlockStatus()" (videoImportRetried)="table.loadData()"></my-video-actions-dropdown></ng-template>diff --git a/client/src/app/+admin/overview/videos/video-list.component.ts b/client/src/app/+admin/overview/videos/video-list.component.tsindex c47276f11c..6ebc0cc13e 100644--- a/client/src/app/+admin/overview/videos/video-list.component.ts+++ b/client/src/app/+admin/overview/videos/video-list.component.ts@@ -6,6 +6,7 @@ import { PTDatePipe } from '@app/shared/shared-main/common/date.pipe'import { VideoCaptionService } from '@app/shared/shared-main/video-caption/video-caption.service'import { VideoDetails } from '@app/shared/shared-main/video/video-details.model'import { VideoFileTokenService } from '@app/shared/shared-main/video/video-file-token.service'+import { VideoImportService } from '@app/shared/shared-main/video/video-import.service'import { Video } from '@app/shared/shared-main/video/video.model'import { VideoService } from '@app/shared/shared-main/video/video.service'import { AccountBlockBadgeInput } from '@app/shared/shared-moderation/account-block-badges.component'@@ -82,6 +83,7 @@ export class VideoListComponent implements OnInit {private server = inject(ServerService)private videoFileTokenService = inject(VideoFileTokenService)private blocklistService = inject(BlocklistService)+ private videoImportService = inject(VideoImportService)readonly videoBlockModal = viewChild<VideoBlockComponent>('videoBlockModal')readonly bulkUpdateVideosModal = viewChild<BulkUpdateVideosModalComponent>('bulkUpdateVideosModal')@@ -105,7 +107,8 @@ export class VideoListComponent implements OnInit {liveInfo: false,removeFiles: true,transcoding: true,- generateTranscription: true+ generateTranscription: true,+ retryFailedImport: true}columns: TableColumnInfo<ColumnName>[] = [@@ -290,6 +293,14 @@ export class VideoListComponent implements OnInit {isDisplayed: videos => videos.every(v => v.canGenerateTranscription(this.authUser, this.serverConfig.videoTranscription.enabled)),iconName: 'video-lang'}+ ],+ [+ {+ label: $localize`Retry import`,+ handler: videos => this.retryImport(videos),+ isDisplayed: videos => videos.every(v => this.authUser.hasRight(UserRight.MANAGE_VIDEO_IMPORTS) && this.isImportFailed(v)),+ iconName: 'refresh'+ }]]}@@ -308,6 +319,10 @@ export class VideoListComponent implements OnInit {return state === VideoState.TO_IMPORT || state === VideoState.TO_IMPORT_FAILED}+ isImportFailed (video: Video) {+ return video.state?.id === VideoState.TO_IMPORT_FAILED+ }+hasOriginalFile (video: Video) {return !!video.videoSource?.fileDownloadUrl}@@ -586,4 +601,22 @@ export class VideoListComponent implements OnInit {error: err => this.notifier.handleError(err)})}++ private retryImport (videos: Video[]) {+ this.videoImportService.retryVideoImportByVideos(videos)+ .subscribe({+ next: () => {+ this.notifier.success(+ formatICU(+ $localize`Retry import requested for {count, plural, =1 {1 video} other {{count} videos}}.`,+ { count: videos.length }+ )+ )++ this.table().loadData()+ },++ error: err => this.notifier.handleError(err)+ })+ }}diff --git a/client/src/app/+my-library/my-videos/my-videos.component.html b/client/src/app/+my-library/my-videos/my-videos.component.htmlindex 1248e5d384..c81b39d2e3 100644--- a/client/src/app/+my-library/my-videos/my-videos.component.html+++ b/client/src/app/+my-library/my-videos/my-videos.component.html@@ -22,13 +22,11 @@[inputFilters]="inputFilters"canUseMatchSort="true">-<ng-template #totalTitle let-totalRecords><ng-container i18n>{ totalRecords, plural, =0 {No videos} =1 {1 video} other {{{ totalRecords | myNumberFormatter }} videos}}</ng-container></ng-template><ng-template #tableCells let-video>-@if (table.isColumnDisplayed('duration')) {<td><my-video-cell [video]="video" thumbnail="true" title="false"></my-video-cell>@@ -94,7 +92,7 @@@if (table.isColumnDisplayed('published')) {<td>- {{ video.publishedAt | ptDate: 'short' }}+ {{ video.publishedAt | ptDate: 'short' }}</td>}@@ -131,8 +129,12 @@@if (table.isColumnDisplayed('playlists')) {<td><div class="badges playlists">- @for (playlist of (videosContainedInPlaylists[video.id] || []); track playlist) {- <a class="pt-badge pt-badge-keep-case" [class]="getPlaylistBadge(playlist.playlistDisplayName)" [routerLink]="['/w/p/', playlist.playlistShortUUID]">+ @for (playlist of videosContainedInPlaylists[video.id] || []; track playlist) {+ <a+ class="pt-badge pt-badge-keep-case"+ [class]="getPlaylistBadge(playlist.playlistDisplayName)"+ [routerLink]="[ '/w/p/', playlist.playlistShortUUID ]"+ >{{ playlist.playlistDisplayName }}</a>}@@ -142,20 +144,38 @@</ng-template><ng-template #actionCell let-video>- <my-button class="me-3" i18n-label label="Manage" [ptRouterLink]="[ '/videos', 'manage', video.shortUUID ]" theme="secondary" icon="film" responsiveLabel="true"></my-button>+ <my-button+ class="me-3"+ i18n-label+ label="Manage"+ [ptRouterLink]="[ '/videos', 'manage', video.shortUUID ]"+ theme="secondary"+ icon="film"+ responsiveLabel="true"+ ></my-button><my-video-actions-dropdown- placement="bottom auto" buttonIcon="more-horizontal" buttonStyled="true" [video]="video" [displayOptions]="videoActionsOptions"- (videoRemoved)="table.loadData()" (videoFilesRemoved)="table.loadData()" (transcodingCreated)="table.loadData()" (videoExistsInPlaylistChange)="fetchVideosContainedInPlaylists([ video ])"+ placement="bottom auto"+ buttonIcon="more-horizontal"+ buttonStyled="true"+ [video]="video"+ [displayOptions]="videoActionsOptions"+ (videoRemoved)="table.loadData()"+ (videoFilesRemoved)="table.loadData()"+ (transcodingCreated)="table.loadData()"+ (videoExistsInPlaylistChange)="fetchVideosContainedInPlaylists([ video ])"+ (videoImportRetried)="table.loadData()"></my-video-actions-dropdown></ng-template><ng-template #noResults let-search="search" let-hasFilters="hasFilters">{{ getNoResults(!!search || hasFilters) }}</ng-template>-</my-table>-<my-bulk-update-videos-in-playlist-modal #bulkUpdateVideosInPlaylistModal (saved)="fetchVideosContainedInPlaylists($event)"></my-bulk-update-videos-in-playlist-modal>+<my-bulk-update-videos-in-playlist-modal+ #bulkUpdateVideosInPlaylistModal+ (saved)="fetchVideosContainedInPlaylists($event)"+></my-bulk-update-videos-in-playlist-modal><my-bulk-update-videos-modal #bulkUpdateVideosModal (saved)="table.loadData()"></my-bulk-update-videos-modal>diff --git a/client/src/app/+my-library/my-videos/my-videos.component.ts b/client/src/app/+my-library/my-videos/my-videos.component.tsindex d9c9fd1da2..688b5659f7 100644--- a/client/src/app/+my-library/my-videos/my-videos.component.ts+++ b/client/src/app/+my-library/my-videos/my-videos.component.ts@@ -1,4 +1,4 @@-import { Component, inject, OnDestroy, OnInit, viewChild, ChangeDetectionStrategy } from '@angular/core'+import { ChangeDetectionStrategy, Component, inject, OnDestroy, OnInit, viewChild } from '@angular/core'import { FormsModule } from '@angular/forms'import { ActivatedRoute, RouterLink } from '@angular/router'import { AuthService, AuthUser, ConfirmService, Notifier, RestPagination, ServerService } from '@app/core'@@ -107,7 +107,8 @@ export class MyVideosComponent implements OnInit, OnDestroy {muteByServer: false,liveInfo: true,removeFiles: false,- transcoding: false+ transcoding: false,+ retryFailedImport: true}user: AuthUserdiff --git a/client/src/app/+video-watch/shared/action-buttons/action-buttons.component.ts b/client/src/app/+video-watch/shared/action-buttons/action-buttons.component.tsindex 21988d6e18..0535f9eb9d 100644--- a/client/src/app/+video-watch/shared/action-buttons/action-buttons.component.ts+++ b/client/src/app/+video-watch/shared/action-buttons/action-buttons.component.ts@@ -1,5 +1,5 @@import { NgClass, NgStyle } from '@angular/common'-import { Component, OnChanges, inject, input, output, viewChild, ChangeDetectionStrategy } from '@angular/core'+import { ChangeDetectionStrategy, Component, OnChanges, inject, input, output, viewChild } from '@angular/core'import { RedirectService, ScreenService } from '@app/core'import { GlobalIconComponent } from '@app/shared/shared-icons/global-icon.component'import { VideoDetails } from '@app/shared/shared-main/video/video-details.model'@@ -76,7 +76,8 @@ export class ActionButtonsComponent implements OnChanges {liveInfo: true,generateTranscription: true,transcriptionWidget: true,- transcoding: true+ transcoding: true,+ retryFailedImport: true}userRating: UserVideoRateTypediff --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 c4e8949b12..cc66352090 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@@ -350,8 +350,10 @@ export class VideoEdit {this.metadata.channelName = options.channelNamethis.metadata.channelDisplayName = options.channelDisplayName- this.initialMetadata.accountName = this.metadata.accountName- this.initialMetadata.channelId = this.common.channelId+ this.initialMetadata = {+ accountName: this.metadata.accountName,+ channelId: this.common.channelId+ }this.updateAfterChange()}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 4195f9864a..6c764243c9 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@@ -1,12 +1,12 @@import { HttpClient, HttpParams } from '@angular/common/http'-import { Injectable, inject } from '@angular/core'+import { inject, Injectable } from '@angular/core'import { RestExtractor, RestPagination, RestService, ServerService, UserService } from '@app/core'import { objectToFormData } from '@app/helpers'import { peertubeTranslate } from '@peertube/peertube-core-utils'-import { ResultList, VideoImport, VideoImportCreate } from '@peertube/peertube-models'+import { ResultList, Video, VideoImport, VideoImportCreate } from '@peertube/peertube-models'import { SortMeta } from 'primeng/api'-import { Observable } from 'rxjs'-import { catchError, map, switchMap } from 'rxjs/operators'+import { from, Observable } from 'rxjs'+import { catchError, concatMap, map, switchMap, toArray } from 'rxjs/operators'import { environment } from '../../../../environments/environment'@Injectable()@@ -65,6 +65,27 @@ export class VideoImportService {.pipe(catchError(err => this.restExtractor.handleError(err)))}+ retryVideoImportByVideos (videos: Pick<Video, 'id'>[]) {+ const pagination = { start: 0, count: 1 }+ const sort = { field: 'createdAt', order: -1 }++ return from(videos)+ .pipe(+ concatMap(video => {+ return this.listMyVideoImports({ pagination, sort, includeCollaborations: true, videoId: video.id })+ .pipe(switchMap(({ data }) => {+ if (data.length === 0) {+ throw new Error('No video import found for this video')+ }++ return this.authHttp.post(VideoImportService.BASE_VIDEO_IMPORT_URL + data[0].id + '/retry', {})+ }))+ }),+ toArray(),+ 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-video-miniature/video-actions-dropdown.component.ts b/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.tsindex 7c9ea949ee..6b6eab2533 100644--- a/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.ts+++ b/client/src/app/shared/shared-video-miniature/video-actions-dropdown.component.ts@@ -1,7 +1,7 @@-import { Component, OnChanges, booleanAttribute, inject, input, output, viewChild, ChangeDetectionStrategy } from '@angular/core'+import { ChangeDetectionStrategy, Component, OnChanges, booleanAttribute, inject, input, output, viewChild } from '@angular/core'import { AuthService, ConfirmService, Notifier, ScreenService, ServerService } from '@app/core'import { NgbDropdown, NgbDropdownAnchor, NgbDropdownMenu } from '@ng-bootstrap/ng-bootstrap'-import { VideoCaption } from '@peertube/peertube-models'+import { UserRight, VideoCaption, VideoState } from '@peertube/peertube-models'import { of } from 'rxjs'import {ActionDropdownComponent,@@ -12,6 +12,7 @@ import {import { VideoCaptionService } from '../shared-main/video-caption/video-caption.service'import { RedundancyService } from '../shared-main/video/redundancy.service'import { VideoDetails } from '../shared-main/video/video-details.model'+import { VideoImportService } from '../shared-main/video/video-import.service'import { Video } from '../shared-main/video/video.model'import { VideoService } from '../shared-main/video/video.service'import { AccountBlockBadgeInput } from '../shared-moderation/account-block-badges.component'@@ -37,6 +38,7 @@ export type VideoActionsDisplayType = {transcoding?: booleangenerateTranscription?: booleantranscriptionWidget?: boolean+ retryFailedImport?: boolean}@Component({@@ -66,6 +68,7 @@ export class VideoActionsDropdownComponent implements OnChanges {private videoCaptionService = inject(VideoCaptionService)private redundancyService = inject(RedundancyService)private serverService = inject(ServerService)+ private videoImportService = inject(VideoImportService)readonly playlistDropdown = viewChild<NgbDropdown>('playlistDropdown')readonly playlistAdd = viewChild<VideoAddToPlaylistComponent>('playlistAdd')@@ -92,7 +95,8 @@ export class VideoActionsDropdownComponent implements OnChanges {removeFiles: false,transcoding: false,generateTranscription: false,- transcriptionWidget: false+ transcriptionWidget: false,+ retryFailedImport: true})readonly placement = input('auto')readonly moreActions = input<DropdownAction<{@@ -115,6 +119,7 @@ export class VideoActionsDropdownComponent implements OnChanges {readonly muted = output()readonly unmuted = output()readonly transcodingCreated = output()+ readonly videoImportRetried = output()readonly modalOpened = output()readonly videoExistsInPlaylistChange = output()@@ -225,6 +230,17 @@ export class VideoActionsDropdownComponent implements OnChanges {return this.video().canGenerateTranscription(this.user, this.serverService.getHTMLConfig().videoTranscription.enabled)}+ canRetryImport () {+ if (this.video().state?.id !== VideoState.TO_IMPORT_FAILED) return false+ if (!this.user) return false+ if (this.user.hasRight(UserRight.MANAGE_VIDEO_IMPORTS)) return true++ const channel = this.video().channel+ if (this.user.isEditorOfChannel(channel) || this.user.isOwnerOfChannel(channel)) return true++ return false+ }+// ---------------------------------------------------------------------------isVideoDownloadableByAnonymous () {@@ -490,6 +506,20 @@ export class VideoActionsDropdownComponent implements OnChanges {})}+ retryImport () {+ const video = this.video()++ this.videoImportService.retryVideoImportByVideos([ video ])+ .subscribe({+ next: () => {+ this.notifier.success($localize`Retry video import of "${video.name}" requested.`)+ this.videoImportRetried.emit()+ },++ error: err => this.notifier.handleError(err)+ })+ }+onVideoBlocked () {this.videoBlocked.emit()}@@ -565,6 +595,12 @@ export class VideoActionsDropdownComponent implements OnChanges {iconName: 'film',isDisplayed: () => this.authService.isLoggedIn() && this.displayOptions().update && this.isVideoUpdatable()},+ {+ label: $localize`Retry import`,+ handler: () => this.retryImport(),+ isDisplayed: () => this.authService.isLoggedIn() && this.displayOptions().retryFailedImport && this.canRetryImport(),+ iconName: 'refresh'+ },{label: $localize`Block...`,handler: () => this.showBlockModal(),