ニジカ投稿局 https://tv.nizika.tv
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

video.ts 1.4 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. import { VideoPrivacy } from '@peertube/peertube-models'
  2. import { CONFIG } from '@server/initializers/config.js'
  3. import { isStreamingPlaylist, MStreamingPlaylistVideo, MVideo } from '@server/types/models/index.js'
  4. import { Response } from 'express'
  5. export function getVideoWithAttributes (res: Response) {
  6. return res.locals.videoAPI || res.locals.videoAll || res.locals.onlyVideo
  7. }
  8. export function extractVideo (videoOrPlaylist: MVideo | MStreamingPlaylistVideo) {
  9. return isStreamingPlaylist(videoOrPlaylist)
  10. ? videoOrPlaylist.Video
  11. : videoOrPlaylist
  12. }
  13. export function getPrivaciesForFederation () {
  14. return (CONFIG.FEDERATION.VIDEOS.FEDERATE_UNLISTED === true)
  15. ? [ { privacy: VideoPrivacy.PUBLIC }, { privacy: VideoPrivacy.UNLISTED } ]
  16. : [ { privacy: VideoPrivacy.PUBLIC } ]
  17. }
  18. export function getExtFromMimetype (mimeTypes: { [id: string]: string | string[] }, mimeType: string) {
  19. const value = mimeTypes[mimeType]
  20. if (Array.isArray(value)) return value[0]
  21. return value
  22. }
  23. export function peertubeLicenceToSPDX (licence: number) {
  24. return {
  25. 1: 'CC-BY-4.0',
  26. 2: 'CC-BY-SA-4.0',
  27. 3: 'CC-BY-ND-4.0',
  28. 4: 'CC-BY-NC-4.0',
  29. 5: 'CC-BY-NC-SA-4.0',
  30. 6: 'CC-BY-NC-ND-4.0',
  31. 7: 'CC0'
  32. }[licence]
  33. }
  34. export function spdxToPeertubeLicence (licence: string) {
  35. return {
  36. 'CC-BY-4.0': 1,
  37. 'CC-BY-SA-4.0': 2,
  38. 'CC-BY-ND-4.0': 3,
  39. 'CC-BY-NC-4.0': 4,
  40. 'CC-BY-NC-SA-4.0': 5,
  41. 'CC-BY-NC-ND-4.0': 6,
  42. 'CC0': 7
  43. }[licence]
  44. }