PluginType,
ClientHookName
} from '../../../../shared/models'
+import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
import { P2PMediaLoaderOptions, PeertubePlayerManagerOptions, PlayerMode } from '../../assets/player/peertube-player-manager'
import { VideoJSCaption } from '../../assets/player/peertube-videojs-typings'
import { TranslationsManager } from '../../assets/player/translations-manager'
refreshFetch (url: string, options?: RequestInit) {
return fetch(url, options)
.then((res: Response) => {
- if (res.status !== 401) return res
+ if (res.status !== HttpStatusCode.UNAUTHORIZED_401) return res
- const refreshingTokenPromise = new Promise((resolve, reject) => {
+ const refreshingTokenPromise = new Promise<void>((resolve, reject) => {
const clientId: string = peertubeLocalStorage.getItem(this.LOCAL_STORAGE_OAUTH_CLIENT_KEYS.CLIENT_ID)
const clientSecret: string = peertubeLocalStorage.getItem(this.LOCAL_STORAGE_OAUTH_CLIENT_KEYS.CLIENT_SECRET)
method: 'POST',
body: objectToUrlEncoded(data)
}).then(res => {
- if (res.status === 401) return undefined
+ if (res.status === HttpStatusCode.UNAUTHORIZED_401) return undefined
return res.json()
}).then((obj: UserRefreshToken & { code: 'invalid_grant'}) => {
this.setHeadersFromTokens()
resolve()
+ }).catch((refreshTokenError: any) => {
+ reject(refreshTokenError)
})
- .catch((refreshTokenError: any) => {
- reject(refreshTokenError)
- })
})
return refreshingTokenPromise
try {
playlistResponse = await playlistPromise
- isResponseOk = true
+ isResponseOk = playlistResponse.status === HttpStatusCode.OK_200
} catch (err) {
console.error(err)
isResponseOk = false
if (!isResponseOk) {
const serverTranslations = await this.translationsPromise
- if (playlistResponse?.status === 404) {
+ if (playlistResponse?.status === HttpStatusCode.NOT_FOUND_404) {
this.playlistNotFound(serverTranslations)
return undefined
}
try {
videoResponse = await videoPromise
- isResponseOk = true
+ isResponseOk = videoResponse.status === HttpStatusCode.OK_200
} catch (err) {
console.error(err)
if (!isResponseOk) {
const serverTranslations = await this.translationsPromise
- if (videoResponse?.status === 404) {
+ if (videoResponse?.status === HttpStatusCode.NOT_FOUND_404) {
this.videoNotFound(serverTranslations)
return undefined
}
videoCaptions,
inactivityTimeout: 2500,
videoViewUrl: this.getVideoUrl(videoInfo.uuid) + '/views',
+ videoUUID: videoInfo.uuid,
+
+ isLive: videoInfo.isLive,
playerElement: this.playerElement,
onPlayerElementChange: (element: HTMLVideoElement) => this.playerElement = element,
serverUrl: window.location.origin,
language: navigator.language,
- embedUrl: window.location.origin + videoInfo.embedPath
+ embedUrl: window.location.origin + videoInfo.embedPath,
+ embedTitle: videoInfo.name
},
webtorrent: {
Object.assign(options, {
p2pMediaLoader: {
- playlistUrl: 'http://localhost:9000/live/toto/master.m3u8',
+ playlistUrl: hlsPlaylist.playlistUrl,
segmentsSha256Url: hlsPlaylist.segmentsSha256Url,
- redundancyBaseUrls: [],
+ redundancyBaseUrls: hlsPlaylist.redundancies.map(r => r.baseUrl),
trackerAnnounce: videoInfo.trackerUrls,
videoFiles: hlsPlaylist.files
} as P2PMediaLoaderOptions
? '<span class="text">' + peertubeTranslate('Watching this video may reveal your IP address to others.') + '</span>'
: undefined
- this.player.dock({
- title,
- description
- })
+ if (title || description) {
+ this.player.dock({
+ title,
+ description
+ })
+ }
}
private buildCSS () {
await loadPlugin({
hooks: this.peertubeHooks,
pluginInfo,
+ onSettingsScripts: () => undefined,
peertubeHelpersFactory: _ => this.buildPeerTubeHelpers(translations)
})
}
showModal: unimplemented,
+ getServerConfig: unimplemented,
+
markdownRenderer: {
textMarkdownToHTML: unimplemented,
enhancedMarkdownToHTML: unimplemented