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; display: block;
} }
.card-content-container {
color: unset;
}
.card-content-container:hover {
text-decoration: none;
}
.card-image-container { .card-image-container {
width: 98px; width: 98px;
flex-shrink: 0; flex-shrink: 0;

View file

@ -191,6 +191,12 @@ routes:
let client = newAsyncHttpClient() let client = newAsyncHttpClient()
var content = await client.getContent(url) 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: if ".m3u8" in url:
content = proxifyVideo(content, prefs.proxyVideos) content = proxifyVideo(content, prefs.proxyVideos)

View file

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