Show overlay for unavailable videos

This commit is contained in:
Zed 2019-08-19 22:03:00 +02:00
parent 8b31f58998
commit 728a335f2c
4 changed files with 23 additions and 6 deletions

View File

@ -307,6 +307,8 @@ video, .video-container img {
text-align: center; text-align: center;
top: calc(50% - 20px); top: calc(50% - 20px);
font-size: 20px; font-size: 20px;
line-height: 1.3;
margin: 0 20px;
} }
.video-overlay div { .video-overlay div {

View File

@ -170,12 +170,14 @@ proc parseVideo*(node: JsonNode; tweetId: string): Video =
durationMs: track["durationMs"].to(int), durationMs: track["durationMs"].to(int),
views: track["viewCount"].to(string), views: track["viewCount"].to(string),
url: track["playbackUrl"].to(string), url: track["playbackUrl"].to(string),
available: track{"mediaAvailability"}["status"].to(string) == "available") available: track{"mediaAvailability"}["status"].to(string) == "available",
reason: track{"mediaAvailability"}["reason"].to(string))
of "vmap": of "vmap":
result = Video( result = Video(
playbackType: vmap, playbackType: vmap,
durationMs: track["durationMs"].to(int), durationMs: track["durationMs"].to(int),
url: track["vmapUrl"].to(string)) url: track["vmapUrl"].to(string),
available: true)
else: else:
echo "Can't parse video of type ", cType echo "Can't parse video of type ", cType

View File

@ -44,6 +44,7 @@ db("cache.db", "", "", ""):
thumb*: string thumb*: string
views*: string views*: string
available*: bool available*: bool
reason*: string
playbackType* {. playbackType* {.
dbType: "STRING" dbType: "STRING"
parseIt: parseEnum[VideoType](it.s) parseIt: parseEnum[VideoType](it.s)

View File

@ -60,12 +60,26 @@ proc renderVideoDisabled(video: Video): VNode =
of m3u8, vmap: of m3u8, vmap:
p: text "hls playback disabled in preferences" p: text "hls playback disabled in preferences"
proc renderVideoUnavailable(video: Video): VNode =
buildHtml(tdiv):
img(src=video.thumb.getSigUrl("pic"))
tdiv(class="video-overlay"):
case video.reason
of "dmcaed":
p: text "This media has been disabled in response to a report by the copyright owner"
else:
p: text "This media is unavailable"
proc renderVideo(video: Video; prefs: Prefs): VNode = proc renderVideo(video: Video; prefs: Prefs): VNode =
buildHtml(tdiv(class="attachments")): buildHtml(tdiv(class="attachments")):
tdiv(class="gallery-video"): tdiv(class="gallery-video"):
tdiv(class="attachment video-container"): tdiv(class="attachment video-container"):
if prefs.isPlaybackEnabled(video):
let thumb = video.thumb.getSigUrl("pic") let thumb = video.thumb.getSigUrl("pic")
if not video.available:
renderVideoUnavailable(video)
elif not prefs.isPlaybackEnabled(video):
renderVideoDisabled(video)
else:
let source = video.url.getSigUrl("video") let source = video.url.getSigUrl("video")
case video.playbackType case video.playbackType
of mp4: of mp4:
@ -80,8 +94,6 @@ proc renderVideo(video: Video; prefs: Prefs): VNode =
verbatim "<div class=\"video-overlay\" onclick=\"playVideo(this)\">" verbatim "<div class=\"video-overlay\" onclick=\"playVideo(this)\">"
verbatim "<div class=\"overlay-circle\">" verbatim "<div class=\"overlay-circle\">"
verbatim "<span class=\"overlay-triangle\"</span></div></div>" verbatim "<span class=\"overlay-triangle\"</span></div></div>"
else:
renderVideoDisabled(video)
proc renderGif(gif: Gif; prefs: Prefs): VNode = proc renderGif(gif: Gif; prefs: Prefs): VNode =
buildHtml(tdiv(class="attachments media-gif")): buildHtml(tdiv(class="attachments media-gif")):