added iframe for rss feed
This commit is contained in:
parent
8eb5c63f9c
commit
2a69baf840
2 changed files with 52 additions and 21 deletions
|
@ -22,6 +22,14 @@ proc videoHandler(request: Request) =
|
||||||
headers["content-type"] = "text/html"
|
headers["content-type"] = "text/html"
|
||||||
request.respond(200, headers, content)
|
request.respond(200, headers, content)
|
||||||
|
|
||||||
|
proc onlyVideoHandler(request: Request) =
|
||||||
|
echo request.uri
|
||||||
|
let real_uri = request.uri.replace("/only","")
|
||||||
|
var headers: HttpHeaders
|
||||||
|
let content = genVideo(path=real_uri, video_uri=real_uri)
|
||||||
|
headers["content-type"] = "text/html"
|
||||||
|
request.respond(200, headers, content)
|
||||||
|
|
||||||
proc staticFileHandler(request: Request) =
|
proc staticFileHandler(request: Request) =
|
||||||
var file = request.uri[1..^1]
|
var file = request.uri[1..^1]
|
||||||
if file == "favicon.ico": file = "favicon.png"
|
if file == "favicon.ico": file = "favicon.png"
|
||||||
|
@ -47,9 +55,10 @@ proc createRouter(): Router =
|
||||||
var router: Router
|
var router: Router
|
||||||
router.get("/", pageHandler)
|
router.get("/", pageHandler)
|
||||||
router.get("/new/*", pageHandler)
|
router.get("/new/*", pageHandler)
|
||||||
router.get("/video.*/*", videoHandler)
|
for x in countup(1,5):
|
||||||
router.get("/video.*/*/*", videoHandler)
|
var s = "/video.*" & "/*".repeat(x)
|
||||||
router.get("/video.*/*/*/*", videoHandler)
|
router.get(s, videoHandler)
|
||||||
|
router.get("/only" & s, onlyVideoHandler)
|
||||||
router.get("/favicon.ico", staticFileHandler)
|
router.get("/favicon.ico", staticFileHandler)
|
||||||
router.get("/favicon.png", staticFileHandler)
|
router.get("/favicon.png", staticFileHandler)
|
||||||
router.get("/css.css", staticFileHandler)
|
router.get("/css.css", staticFileHandler)
|
||||||
|
|
|
@ -4,6 +4,12 @@ import os, strutils, strformat, tables, re, sugar, uri, times
|
||||||
type
|
type
|
||||||
Urls = seq[string]
|
Urls = seq[string]
|
||||||
Thumbs = seq[string]
|
Thumbs = seq[string]
|
||||||
|
type
|
||||||
|
Video = object
|
||||||
|
thumb: string
|
||||||
|
uri: string
|
||||||
|
low: string
|
||||||
|
hls: string
|
||||||
|
|
||||||
proc cacheResources(): Table[string, string] =
|
proc cacheResources(): Table[string, string] =
|
||||||
echo "Compiling Resources..."
|
echo "Compiling Resources..."
|
||||||
|
@ -41,29 +47,34 @@ proc parseThumbs(content: string): seq[string] =
|
||||||
thumb.split("\"")[1]
|
thumb.split("\"")[1]
|
||||||
return thumbs
|
return thumbs
|
||||||
|
|
||||||
proc setUpVideo(content: string, video_uri: string): (string, Urls, Thumbs) =
|
|
||||||
let
|
proc getVideoStreamURI(content: string, video_uri: string): Video =
|
||||||
rel_vids_re = re"""video_related=(.+)"""
|
let
|
||||||
vid_h_url_re = re"""setVideoUrlHigh(.*)"""
|
vid_h_url_re = re"""setVideoUrlHigh(.*)"""
|
||||||
vid_l_url_re = re"""setVideoUrlLow(.*)"""
|
vid_l_url_re = re"""setVideoUrlLow(.*)"""
|
||||||
vid_hls_re = re"""setVideoHLS(.*)"""
|
|
||||||
vid_thumb_re = re"""setThumbUrl(.*)"""
|
vid_thumb_re = re"""setThumbUrl(.*)"""
|
||||||
|
vid_hls_re = re"""setVideoHLS(.*)"""
|
||||||
|
var video = Video()
|
||||||
|
video.uri = content.findAll(vid_h_url_re)[0].split("'")[1]
|
||||||
|
video.low = content.findAll(vid_l_url_re)[0].split("'")[1]
|
||||||
|
let video_hls_matches = content.findAll(vid_hls_re)
|
||||||
|
if video_hls_matches.len > 0:
|
||||||
|
video.hls = video_hls_matches[0].split("'")[1]
|
||||||
|
if video.uri == "":
|
||||||
|
video.uri = video.low
|
||||||
|
video.thumb = content.findAll(vid_thumb_re)[0].split("'")[1]
|
||||||
|
return video
|
||||||
|
|
||||||
|
proc setUpVideo(content: string, video_uri: string): (string, Urls, Thumbs) =
|
||||||
|
let video = getVideoStreamURI(content, video_uri)
|
||||||
|
let rel_vids_re = re"""video_related=(.+)"""
|
||||||
|
let
|
||||||
related_vids = collect:
|
related_vids = collect:
|
||||||
for vid in content.findAll(rel_vids_re):
|
for vid in content.findAll(rel_vids_re):
|
||||||
vid.replace(",","\n")
|
vid.replace(",","\n")
|
||||||
|
var HTML_VIDEO = fmt"""<center><video poster="{video.thumb}" controls autoplay loop><source src="{video.uri}"/></video></center><center id='infoblock'>"""
|
||||||
var video = content.findAll(vid_h_url_re)[0].split("'")[1]
|
if video.hls != "":
|
||||||
let video_low = content.findAll(vid_l_url_re)[0].split("'")[1]
|
HTML_VIDEO &= fmt"""<h3>HD Stream: </h3><a href="{video.hls}">{video.hls}</a><br/>(use with a video player)"""
|
||||||
var video_hls: string
|
|
||||||
var video_hls_matches = content.findAll(vid_hls_re)
|
|
||||||
if video_hls_matches.len > 0:
|
|
||||||
video_hls = video_hls_matches[0].split("'")[1]
|
|
||||||
if video == "":
|
|
||||||
video = video_low
|
|
||||||
let video_thumb = content.findAll(vid_thumb_re)[0].split("'")[1]
|
|
||||||
var HTML_VIDEO = fmt"""<center><video poster="{video_thumb}" controls autoplay loop><source src="{video}"/></video></center><center id='infoblock'>"""
|
|
||||||
if video_hls != "":
|
|
||||||
HTML_VIDEO &= fmt"""<h3>HD Stream: </h3><input type='text' size='50' value='{video_hls}' /><br/>(use with a video player)"""
|
|
||||||
HTML_VIDEO &= "</center>"
|
HTML_VIDEO &= "</center>"
|
||||||
var thumbs: Thumbs = @[]
|
var thumbs: Thumbs = @[]
|
||||||
var urls: Urls = @[]
|
var urls: Urls = @[]
|
||||||
|
@ -82,6 +93,11 @@ proc getPagination(content:string): string =
|
||||||
if pagination.len > 0:
|
if pagination.len > 0:
|
||||||
return pagination[0]
|
return pagination[0]
|
||||||
|
|
||||||
|
proc compileVideo(content: string, video_uri: string): string =
|
||||||
|
let video = getVideoStreamURI(content, video_uri)
|
||||||
|
let page = fmt"""<center><video poster="{video.thumb}" controls autoplay loop><source src="{video.uri}"/></video></center>"""
|
||||||
|
return page
|
||||||
|
|
||||||
proc compilePage(content: string, video_uri: string = "", search_query: string = ""): string =
|
proc compilePage(content: string, video_uri: string = "", search_query: string = ""): string =
|
||||||
var
|
var
|
||||||
page: string = ""
|
page: string = ""
|
||||||
|
@ -133,6 +149,7 @@ proc compileRSSPage(content: string, search_query: string = ""): string =
|
||||||
else:
|
else:
|
||||||
vid_url = url.replace("THUMBNUM","1")
|
vid_url = url.replace("THUMBNUM","1")
|
||||||
vid_thumb = thumbs[^1].replace("THUMBNUM","1")
|
vid_thumb = thumbs[^1].replace("THUMBNUM","1")
|
||||||
|
let o_vid_uri = "/only" & vid_url
|
||||||
let title = vid_url.split("/")[^1].replace("_"," ")
|
let title = vid_url.split("/")[^1].replace("_"," ")
|
||||||
rss &= fmt"""
|
rss &= fmt"""
|
||||||
<item>
|
<item>
|
||||||
|
@ -140,7 +157,8 @@ proc compileRSSPage(content: string, search_query: string = ""): string =
|
||||||
<title>{title}</title>
|
<title>{title}</title>
|
||||||
<link>{vid_url}</link>
|
<link>{vid_url}</link>
|
||||||
<description>{title}<br />
|
<description>{title}<br />
|
||||||
<img src="{vid_thumb}">
|
<img src="{vid_thumb}"><br />
|
||||||
|
<iframe src="{o_vid_uri}" height="300" width="400"></iframe>
|
||||||
</description>
|
</description>
|
||||||
<media:content url="{vid_thumb}" type="image/png" medium="image">
|
<media:content url="{vid_thumb}" type="image/png" medium="image">
|
||||||
<media:rating scheme="urn:simple">adult</media:rating>
|
<media:rating scheme="urn:simple">adult</media:rating>
|
||||||
|
@ -161,6 +179,10 @@ proc findSearchQuery(query: string): string =
|
||||||
break
|
break
|
||||||
return search_query
|
return search_query
|
||||||
|
|
||||||
|
proc genvideo*(path: string, video_uri: string): string =
|
||||||
|
let content = request(XV & path)
|
||||||
|
return compileVideo(content, video_uri)
|
||||||
|
|
||||||
proc genpage*(path: string, video_uri: string = ""): string =
|
proc genpage*(path: string, video_uri: string = ""): string =
|
||||||
let content = request(XV & path)
|
let content = request(XV & path)
|
||||||
let search_query = findSearchQuery(path)
|
let search_query = findSearchQuery(path)
|
||||||
|
|
Loading…
Reference in a new issue