diff options
Diffstat (limited to 'client/src')
-rw-r--r-- | client/src/standalone/videos/embed.ts | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/client/src/standalone/videos/embed.ts b/client/src/standalone/videos/embed.ts index f12b8c9ac..a2902ce58 100644 --- a/client/src/standalone/videos/embed.ts +++ b/client/src/standalone/videos/embed.ts | |||
@@ -143,8 +143,11 @@ export class PeerTubeEmbed { | |||
143 | return fetch(this.getPlaylistUrl(playlistId)) | 143 | return fetch(this.getPlaylistUrl(playlistId)) |
144 | } | 144 | } |
145 | 145 | ||
146 | loadPlaylistElements (playlistId: string): Promise<Response> { | 146 | loadPlaylistElements (playlistId: string, start = 0): Promise<Response> { |
147 | return fetch(this.getPlaylistUrl(playlistId) + '/videos') | 147 | const url = new URL(this.getPlaylistUrl(playlistId) + '/videos') |
148 | url.search = new URLSearchParams({ start: '' + start, count: '100' }).toString() | ||
149 | |||
150 | return fetch(url.toString()) | ||
148 | } | 151 | } |
149 | 152 | ||
150 | loadConfig (): Promise<ServerConfig> { | 153 | loadConfig (): Promise<ServerConfig> { |
@@ -257,6 +260,28 @@ export class PeerTubeEmbed { | |||
257 | } | 260 | } |
258 | } | 261 | } |
259 | 262 | ||
263 | private async loadAllPlaylistVideos (playlistId: string, baseResult: ResultList<VideoPlaylistElement>) { | ||
264 | let elements = baseResult.data | ||
265 | let total = baseResult.total | ||
266 | let i = 0 | ||
267 | |||
268 | while (total > elements.length && i < 10) { | ||
269 | const result = await this.loadPlaylistElements(playlistId, elements.length) | ||
270 | |||
271 | const json = await result.json() as ResultList<VideoPlaylistElement> | ||
272 | total = json.total | ||
273 | |||
274 | elements = elements.concat(json.data) | ||
275 | i++ | ||
276 | } | ||
277 | |||
278 | if (i === 10) { | ||
279 | console.error('Cannot fetch all playlists elements, there are too many!') | ||
280 | } | ||
281 | |||
282 | return elements | ||
283 | } | ||
284 | |||
260 | private async loadPlaylist (playlistId: string) { | 285 | private async loadPlaylist (playlistId: string) { |
261 | const playlistPromise = this.loadPlaylistInfo(playlistId) | 286 | const playlistPromise = this.loadPlaylistInfo(playlistId) |
262 | const playlistElementsPromise = this.loadPlaylistElements(playlistId) | 287 | const playlistElementsPromise = this.loadPlaylistElements(playlistId) |
@@ -534,7 +559,7 @@ export class PeerTubeEmbed { | |||
534 | this.playlist = await res.playlistResponse.json() | 559 | this.playlist = await res.playlistResponse.json() |
535 | 560 | ||
536 | const playlistElementResult = await res.videosResponse.json() | 561 | const playlistElementResult = await res.videosResponse.json() |
537 | this.playlistElements = playlistElementResult.data | 562 | this.playlistElements = await this.loadAllPlaylistVideos(playlistId, playlistElementResult) |
538 | 563 | ||
539 | this.currentPlaylistElement = this.playlistElements[0] | 564 | this.currentPlaylistElement = this.playlistElements[0] |
540 | videoId = this.currentPlaylistElement.video.uuid | 565 | videoId = this.currentPlaylistElement.video.uuid |