diff --git a/public/css/style.css b/public/css/style.css index e826cc3..7ce480f 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -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 { diff --git a/src/parser.nim b/src/parser.nim index a0056d7..bda011a 100644 --- a/src/parser.nim +++ b/src/parser.nim @@ -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 diff --git a/src/types.nim b/src/types.nim index bcb9a0a..943f5b1 100644 --- a/src/types.nim +++ b/src/types.nim @@ -44,6 +44,7 @@ db("cache.db", "", "", ""): thumb*: string views*: string available*: bool + reason*: string playbackType* {. dbType: "STRING" parseIt: parseEnum[VideoType](it.s) diff --git a/src/views/tweet.nim b/src/views/tweet.nim index 265b55e..974725e 100644 --- a/src/views/tweet.nim +++ b/src/views/tweet.nim @@ -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 "
" - else: - renderVideoDisabled(video) proc renderGif(gif: Gif; prefs: Prefs): VNode = buildHtml(tdiv(class="attachments media-gif")):