From 2a69baf84002620837b1f4287af739405c8f1bb1 Mon Sep 17 00:00:00 2001 From: Paul Wilde Date: Mon, 23 Dec 2024 10:22:41 +0000 Subject: [PATCH] added iframe for rss feed --- src/Pimvidious.nim | 15 +++++++++--- src/genpage.nim | 58 ++++++++++++++++++++++++++++++++-------------- 2 files changed, 52 insertions(+), 21 deletions(-) diff --git a/src/Pimvidious.nim b/src/Pimvidious.nim index 6c7ecda..d3071e8 100644 --- a/src/Pimvidious.nim +++ b/src/Pimvidious.nim @@ -22,6 +22,14 @@ proc videoHandler(request: Request) = headers["content-type"] = "text/html" 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) = var file = request.uri[1..^1] if file == "favicon.ico": file = "favicon.png" @@ -47,9 +55,10 @@ proc createRouter(): Router = var router: Router router.get("/", pageHandler) router.get("/new/*", pageHandler) - router.get("/video.*/*", videoHandler) - router.get("/video.*/*/*", videoHandler) - router.get("/video.*/*/*/*", videoHandler) + for x in countup(1,5): + var s = "/video.*" & "/*".repeat(x) + router.get(s, videoHandler) + router.get("/only" & s, onlyVideoHandler) router.get("/favicon.ico", staticFileHandler) router.get("/favicon.png", staticFileHandler) router.get("/css.css", staticFileHandler) diff --git a/src/genpage.nim b/src/genpage.nim index aed5050..bffac65 100644 --- a/src/genpage.nim +++ b/src/genpage.nim @@ -4,6 +4,12 @@ import os, strutils, strformat, tables, re, sugar, uri, times type Urls = seq[string] Thumbs = seq[string] +type + Video = object + thumb: string + uri: string + low: string + hls: string proc cacheResources(): Table[string, string] = echo "Compiling Resources..." @@ -41,29 +47,34 @@ proc parseThumbs(content: string): seq[string] = thumb.split("\"")[1] return thumbs -proc setUpVideo(content: string, video_uri: string): (string, Urls, Thumbs) = - let - rel_vids_re = re"""video_related=(.+)""" + +proc getVideoStreamURI(content: string, video_uri: string): Video = + let vid_h_url_re = re"""setVideoUrlHigh(.*)""" vid_l_url_re = re"""setVideoUrlLow(.*)""" - vid_hls_re = re"""setVideoHLS(.*)""" 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: for vid in content.findAll(rel_vids_re): vid.replace(",","\n") - - var video = content.findAll(vid_h_url_re)[0].split("'")[1] - let video_low = content.findAll(vid_l_url_re)[0].split("'")[1] - 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"""
""" - if video_hls != "": - HTML_VIDEO &= fmt"""

HD Stream:


(use with a video player)""" + var HTML_VIDEO = fmt"""
""" + if video.hls != "": + HTML_VIDEO &= fmt"""

HD Stream:

{video.hls}
(use with a video player)""" HTML_VIDEO &= "
" var thumbs: Thumbs = @[] var urls: Urls = @[] @@ -82,6 +93,11 @@ proc getPagination(content:string): string = if pagination.len > 0: return pagination[0] +proc compileVideo(content: string, video_uri: string): string = + let video = getVideoStreamURI(content, video_uri) + let page = fmt"""
""" + return page + proc compilePage(content: string, video_uri: string = "", search_query: string = ""): string = var page: string = "" @@ -133,6 +149,7 @@ proc compileRSSPage(content: string, search_query: string = ""): string = else: vid_url = url.replace("THUMBNUM","1") vid_thumb = thumbs[^1].replace("THUMBNUM","1") + let o_vid_uri = "/only" & vid_url let title = vid_url.split("/")[^1].replace("_"," ") rss &= fmt""" @@ -140,7 +157,8 @@ proc compileRSSPage(content: string, search_query: string = ""): string = {title} {vid_url} {title}<br /> - <img src="{vid_thumb}"> + <img src="{vid_thumb}"><br /> + <iframe src="{o_vid_uri}" height="300" width="400"></iframe> adult @@ -161,6 +179,10 @@ proc findSearchQuery(query: string): string = break 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 = let content = request(XV & path) let search_query = findSearchQuery(path)