mirror of
https://github.com/zedeus/nitter.git
synced 2024-12-13 03:26:30 +00:00
Prefer mp4 to m3u8 for Video Playback if proxyVideos is off
m3u8 videos only work when the proxy is enabled. Further, this allows video playback without Javascript. This is only done when proxying is disabled to avoid excessive memory usage on the nitter instance that would result from loading longer videos in a single chunk.
This commit is contained in:
parent
683c052036
commit
0633ec2c39
1 changed files with 12 additions and 6 deletions
|
@ -62,11 +62,14 @@ proc renderAlbum(tweet: Tweet): VNode =
|
|||
a(href=getPicUrl(orig), class="still-image", target="_blank"):
|
||||
genImg(small)
|
||||
|
||||
proc isPlaybackEnabled(prefs: Prefs; video: Video): bool =
|
||||
case video.playbackType
|
||||
proc isPlaybackEnabled(prefs: Prefs; playbackType: VideoType): bool =
|
||||
case playbackType
|
||||
of mp4: prefs.mp4Playback
|
||||
of m3u8, vmap: prefs.hlsPlayback
|
||||
|
||||
proc hasMp4Url(video: Video): bool =
|
||||
video.variants.anyIt(it.contentType == mp4)
|
||||
|
||||
proc renderVideoDisabled(video: Video; path: string): VNode =
|
||||
buildHtml(tdiv(class="video-overlay")):
|
||||
case video.playbackType
|
||||
|
@ -87,6 +90,9 @@ proc renderVideo*(video: Video; prefs: Prefs; path: string): VNode =
|
|||
let container =
|
||||
if video.description.len > 0 or video.title.len > 0: " card-container"
|
||||
else: ""
|
||||
let playbackType =
|
||||
if not prefs.proxyVideos and video.hasMp4Url: mp4
|
||||
else: video.playbackType
|
||||
|
||||
buildHtml(tdiv(class="attachments card")):
|
||||
tdiv(class="gallery-video" & container):
|
||||
|
@ -95,13 +101,13 @@ proc renderVideo*(video: Video; prefs: Prefs; path: string): VNode =
|
|||
if not video.available:
|
||||
img(src=thumb)
|
||||
renderVideoUnavailable(video)
|
||||
elif not prefs.isPlaybackEnabled(video):
|
||||
elif not prefs.isPlaybackEnabled(playbackType):
|
||||
img(src=thumb)
|
||||
renderVideoDisabled(video, path)
|
||||
else:
|
||||
let vid = video.variants.filterIt(it.contentType == video.playbackType)
|
||||
let source = getVidUrl(vid[0].url)
|
||||
case video.playbackType
|
||||
let vid = video.variants.filterIt(it.contentType == playbackType)
|
||||
let source = if prefs.proxyVideos: getVidUrl(vid[0].url) else: vid[0].url
|
||||
case playbackType
|
||||
of mp4:
|
||||
if prefs.muteVideos:
|
||||
video(poster=thumb, controls="", muted=""):
|
||||
|
|
Loading…
Reference in a new issue