Support vmap/amplify video card

This commit is contained in:
Zed 2019-08-19 20:53:57 +02:00
parent ce6dace1d7
commit 8a45afdd46
3 changed files with 31 additions and 10 deletions

View File

@ -970,6 +970,14 @@ video, .video-container img {
display: block;
}
.card-content-container {
color: unset;
}
.card-content-container:hover {
text-decoration: none;
}
.card-image-container {
width: 98px;
flex-shrink: 0;

View File

@ -191,6 +191,12 @@ routes:
let client = newAsyncHttpClient()
var content = await client.getContent(url)
if ".vmap" in url:
var m: RegexMatch
discard content.find(re"""url="(.+.m3u8)"""", m)
url = decodeUrl(content[m.group(0)[0]])
content = await client.getContent(url)
if ".m3u8" in url:
content = proxifyVideo(content, prefs.proxyVideos)

View File

@ -117,22 +117,29 @@ proc renderCardImage(card: Card): VNode =
tdiv(class="card-overlay-circle"):
span(class="card-overlay-triangle")
proc renderCardContent(card: Card): VNode =
buildHtml(tdiv(class="card-content")):
h2(class="card-title"): text card.title
p(class="card-description"): text card.text
span(class="card-destination"): text card.dest
proc renderCard(card: Card; prefs: Prefs): VNode =
const largeCards = {summaryLarge, liveEvent, promoWebsite, promoVideo}
let large = if card.kind in largeCards: " large" else: ""
let url = replaceUrl(card.url, prefs)
buildHtml(tdiv(class=("card" & large))):
a(class="card-container", href=replaceUrl(card.url, prefs)):
if card.image.isSome:
renderCardImage(card)
elif card.video.isSome:
if card.video.isSome:
tdiv(class="card-container"):
renderVideo(get(card.video), prefs)
tdiv(class="card-content-container"):
tdiv(class="card-content"):
h2(class="card-title"): text card.title
p(class="card-description"): text card.text
span(class="card-destination"): text card.dest
a(class="card-content-container", href=url):
renderCardContent(card)
else:
a(class="card-container", href=url):
if card.image.isSome:
renderCardImage(card)
tdiv(class="card-content-container"):
renderCardContent(card)
proc renderStats(stats: TweetStats): VNode =
buildHtml(tdiv(class="tweet-stats")):