1
0
mirror of https://github.com/zedeus/nitter synced 2024-11-26 03:29:14 +01:00

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;
top: calc(50% - 20px);
font-size: 20px;
line-height: 1.3;
margin: 0 20px;
}
.video-overlay div {

View File

@ -170,12 +170,14 @@ proc parseVideo*(node: JsonNode; tweetId: string): Video =
durationMs: track["durationMs"].to(int),
views: track["viewCount"].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":
result = Video(
playbackType: vmap,
durationMs: track["durationMs"].to(int),
url: track["vmapUrl"].to(string))
url: track["vmapUrl"].to(string),
available: true)
else:
echo "Can't parse video of type ", cType

View File

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

View File

@ -60,12 +60,26 @@ proc renderVideoDisabled(video: Video): VNode =
of m3u8, vmap:
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 =
buildHtml(tdiv(class="attachments")):
tdiv(class="gallery-video"):
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")
case video.playbackType
of mp4:
@ -80,8 +94,6 @@ proc renderVideo(video: Video; prefs: Prefs): VNode =
verbatim "<div class=\"video-overlay\" onclick=\"playVideo(this)\">"
verbatim "<div class=\"overlay-circle\">"
verbatim "<span class=\"overlay-triangle\"</span></div></div>"
else:
renderVideoDisabled(video)
proc renderGif(gif: Gif; prefs: Prefs): VNode =
buildHtml(tdiv(class="attachments media-gif")):