From 010382b6037cff5d0ed16fa8b158691439fac9b7 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 3 Jun 2022 14:04:52 +0200 Subject: [PATCH 1/3] Completely remove best default trending algorithm --- CHANGELOG.md | 1 + .../+videos/video-list/videos-list-common-page.component.ts | 4 ++++ config/default.yaml | 1 - config/production.yaml.example | 1 - server/tests/api/check-params/config.ts | 2 +- server/tests/api/server/config.ts | 2 +- shared/server-commands/server/config-command.ts | 2 +- 7 files changed, 8 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f3724a3bf..8aeeb7b7e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ * Add `client.videos.resumable_upload.max_chunk_size` config option [#4857](https://github.com/Chocobozzz/PeerTube/pull/4857) * Add `object_storage.upload_acl` config option [#4861](https://github.com/Chocobozzz/PeerTube/pull/4861) * Add ability to set RTMP/RTMPS listening hostname using `rtmp.hostname`/`rtmps.hostname` and public RTMP/RTMPS hostname using `rtmp.public_hostname`/`rtmps.public_hostname` + * Removed `best` default trending algorithm. It is automatically used if using `hot` algorithm with a logged in user ### Docker diff --git a/client/src/app/+videos/video-list/videos-list-common-page.component.ts b/client/src/app/+videos/video-list/videos-list-common-page.component.ts index 72c7e1ef6..d2782036b 100644 --- a/client/src/app/+videos/video-list/videos-list-common-page.component.ts +++ b/client/src/app/+videos/video-list/videos-list-common-page.component.ts @@ -173,6 +173,10 @@ export class VideosListCommonPageComponent implements OnInit, OnDestroy, Disable case 'most-liked': return '-likes' + // We'll automatically apply "best" sort if using "hot" sort with a logged user + case 'best': + return '-hot' + default: return '-' + algorithm as VideoSortField } diff --git a/config/default.yaml b/config/default.yaml index 689f81343..54452d5e2 100644 --- a/config/default.yaml +++ b/config/default.yaml @@ -181,7 +181,6 @@ trending: interval_days: 7 # Compute trending videos for the last x days algorithms: enabled: - - 'best' # adaptation of Reddit's 'Best' algorithm (Hot minus History) - 'hot' # adaptation of Reddit's 'Hot' algorithm - 'most-viewed' # default, used initially by PeerTube as the trending page - 'most-liked' diff --git a/config/production.yaml.example b/config/production.yaml.example index 6db43fccf..89b7fe966 100644 --- a/config/production.yaml.example +++ b/config/production.yaml.example @@ -177,7 +177,6 @@ trending: interval_days: 7 # Compute trending videos for the last x days algorithms: enabled: - - 'best' # adaptation of Reddit's 'Best' algorithm (Hot minus History) - 'hot' # adaptation of Reddit's 'Hot' algorithm - 'most-viewed' # default, used initially by PeerTube as the trending page - 'most-liked' diff --git a/server/tests/api/check-params/config.ts b/server/tests/api/check-params/config.ts index c8dbbf797..99fb24a5b 100644 --- a/server/tests/api/check-params/config.ts +++ b/server/tests/api/check-params/config.ts @@ -165,7 +165,7 @@ describe('Test config API validators', function () { trending: { videos: { algorithms: { - enabled: [ 'best', 'hot', 'most-viewed', 'most-liked' ], + enabled: [ 'hot', 'most-viewed', 'most-liked' ], default: 'most-viewed' } } diff --git a/server/tests/api/server/config.ts b/server/tests/api/server/config.ts index f31012a5c..0f2fb5493 100644 --- a/server/tests/api/server/config.ts +++ b/server/tests/api/server/config.ts @@ -367,7 +367,7 @@ const newCustomConfig: CustomConfig = { trending: { videos: { algorithms: { - enabled: [ 'best', 'hot', 'most-viewed', 'most-liked' ], + enabled: [ 'hot', 'most-viewed', 'most-liked' ], default: 'hot' } } diff --git a/shared/server-commands/server/config-command.ts b/shared/server-commands/server/config-command.ts index ed4961bc3..5320dead4 100644 --- a/shared/server-commands/server/config-command.ts +++ b/shared/server-commands/server/config-command.ts @@ -356,7 +356,7 @@ export class ConfigCommand extends AbstractCommand { trending: { videos: { algorithms: { - enabled: [ 'best', 'hot', 'most-viewed', 'most-liked' ], + enabled: [ 'hot', 'most-viewed', 'most-liked' ], default: 'hot' } } From 5a2f775a212bcb708f1756e3780c764cc232a910 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 3 Jun 2022 14:18:28 +0200 Subject: [PATCH 2/3] Handle playlist without videos available --- .../shared/information/video-alert.component.html | 4 ++++ .../shared/information/video-alert.component.ts | 1 + .../shared/playlist/video-watch-playlist.component.html | 2 +- .../shared/playlist/video-watch-playlist.component.ts | 5 ++++- .../app/+videos/+video-watch/video-watch.component.html | 7 +++++-- .../src/app/+videos/+video-watch/video-watch.component.ts | 7 +++++++ 6 files changed, 22 insertions(+), 4 deletions(-) diff --git a/client/src/app/+videos/+video-watch/shared/information/video-alert.component.html b/client/src/app/+videos/+video-watch/shared/information/video-alert.component.html index c6ffb1abd..be726c990 100644 --- a/client/src/app/+videos/+video-watch/shared/information/video-alert.component.html +++ b/client/src/app/+videos/+video-watch/shared/information/video-alert.component.html @@ -34,6 +34,10 @@ This live has ended. +
+ There are no videos available in this playlist. +
+
This video is blocked.
{{ video.blacklistedReason }} diff --git a/client/src/app/+videos/+video-watch/shared/information/video-alert.component.ts b/client/src/app/+videos/+video-watch/shared/information/video-alert.component.ts index 79b56705f..ba79fabc8 100644 --- a/client/src/app/+videos/+video-watch/shared/information/video-alert.component.ts +++ b/client/src/app/+videos/+video-watch/shared/information/video-alert.component.ts @@ -9,6 +9,7 @@ import { VideoState } from '@shared/models' }) export class VideoAlertComponent { @Input() video: VideoDetails + @Input() noPlaylistVideoFound: boolean isVideoToTranscode () { return this.video && this.video.state.id === VideoState.TO_TRANSCODE diff --git a/client/src/app/+videos/+video-watch/shared/playlist/video-watch-playlist.component.html b/client/src/app/+videos/+video-watch/shared/playlist/video-watch-playlist.component.html index da81d76d1..f5dd352a3 100644 --- a/client/src/app/+videos/+video-watch/shared/playlist/video-watch-playlist.component.html +++ b/client/src/app/+videos/+video-watch/shared/playlist/video-watch-playlist.component.html @@ -1,5 +1,5 @@
diff --git a/client/src/app/+videos/+video-watch/shared/playlist/video-watch-playlist.component.ts b/client/src/app/+videos/+video-watch/shared/playlist/video-watch-playlist.component.ts index 879d296a7..ec85db0ff 100644 --- a/client/src/app/+videos/+video-watch/shared/playlist/video-watch-playlist.component.ts +++ b/client/src/app/+videos/+video-watch/shared/playlist/video-watch-playlist.component.ts @@ -18,6 +18,7 @@ export class VideoWatchPlaylistComponent { @Input() playlist: VideoPlaylist @Output() videoFound = new EventEmitter() + @Output() noVideoFound = new EventEmitter() playlistElements: VideoPlaylistElement[] = [] playlistPagination: ComponentPagination = { @@ -28,10 +29,11 @@ export class VideoWatchPlaylistComponent { autoPlayNextVideoPlaylist: boolean autoPlayNextVideoPlaylistSwitchText = '' + loopPlaylist: boolean loopPlaylistSwitchText = '' - noPlaylistVideos = false + noPlaylistVideos = false currentPlaylistPosition: number constructor ( @@ -100,6 +102,7 @@ export class VideoWatchPlaylistComponent { const firstAvailableVideo = this.playlistElements.find(e => !!e.video) if (!firstAvailableVideo) { this.noPlaylistVideos = true + this.noVideoFound.emit() return } diff --git a/client/src/app/+videos/+video-watch/video-watch.component.html b/client/src/app/+videos/+video-watch/video-watch.component.html index 4c15ae3d7..1ea0cf6b8 100644 --- a/client/src/app/+videos/+video-watch/video-watch.component.html +++ b/client/src/app/+videos/+video-watch/video-watch.component.html @@ -11,12 +11,15 @@ Placeholder image
- +
- +
diff --git a/client/src/app/+videos/+video-watch/video-watch.component.ts b/client/src/app/+videos/+video-watch/video-watch.component.ts index 5fa31ec63..d05f08a5f 100644 --- a/client/src/app/+videos/+video-watch/video-watch.component.ts +++ b/client/src/app/+videos/+video-watch/video-watch.component.ts @@ -72,6 +72,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { playlist: VideoPlaylist = null remoteServerDown = false + noPlaylistVideoFound = false private nextVideoUUID = '' private nextVideoTitle = '' @@ -178,6 +179,10 @@ export class VideoWatchComponent implements OnInit, OnDestroy { this.loadVideo(videoId) } + onPlaylistNoVideoFound () { + this.noPlaylistVideoFound = true + } + isUserLoggedIn () { return this.authService.isLoggedIn() } @@ -286,6 +291,8 @@ export class VideoWatchComponent implements OnInit, OnDestroy { private loadPlaylist (playlistId: string) { if (this.isSameElement(this.playlist, playlistId)) return + this.noPlaylistVideoFound = false + this.playlistService.getVideoPlaylist(playlistId) .subscribe({ next: playlist => { From 62f53731cf807562ba885b180e71bb75b3902443 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 3 Jun 2022 14:28:43 +0200 Subject: [PATCH 3/3] Fix invalid download filename --- server/controllers/download.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server/controllers/download.ts b/server/controllers/download.ts index 43d525f83..a270180c0 100644 --- a/server/controllers/download.ts +++ b/server/controllers/download.ts @@ -86,7 +86,9 @@ async function downloadVideoFile (req: express.Request, res: express.Response) { } await VideoPathManager.Instance.makeAvailableVideoFile(videoFile.withVideoOrPlaylist(video), path => { - const filename = `${video.name}-${videoFile.resolution}p${videoFile.extname}` + // Express uses basename on filename parameter + const videoName = video.name.replace(/[/\\]/g, '_') + const filename = `${videoName}-${videoFile.resolution}p${videoFile.extname}` return res.download(path, filename) })