Compare commits

...

11 commits

Author SHA1 Message Date
Butter Cat 632ebc4a83
Merge ffcbec77b5 into cdff5e9b1c 2024-02-21 21:59:36 -08:00
jackyzy823 cdff5e9b1c
Fix for #1147, Proxy for audio URL and upgrade hls.js (#1178)
* Revert "Fix broken video playback by forcing fmp4"

This reverts commit 52db03b73a.

* Fix audio url in video m3u8

* Upgrade hls.js to 1.5.1 and use full version
2024-02-21 23:10:54 +00:00
Butter Cat ffcbec77b5 Bring up to date with guest_accounts branch 2023-11-14 19:25:16 -05:00
Butter Cat e6ff628103 Remove commented out services 2023-11-14 19:22:08 -05:00
Butter Cat dbbfa39c9d
Merge branch 'zedeus:master' into more_link_replacements 2023-11-14 19:19:22 -05:00
Butter Cat 4a6b998640 Add in link replacement for medium.com 2023-11-13 21:06:27 -05:00
Butter Cat a5c6fe0ed3 Fix accounting for imgur.io 2023-11-13 20:52:28 -05:00
Butter Cat 8a741f4d5f Account for imgur.io 2023-11-13 20:32:22 -05:00
Butter Cat 8670a71c30 Fix missing parentheses in Imgur regex 2023-11-13 20:28:21 -05:00
Butter Cat 1a804dc6e2 Account for more Imgur domains 2023-11-13 20:24:39 -05:00
Butter Cat cc931d02bb Initial test of imgur redirect 2023-11-13 20:03:26 -05:00
6 changed files with 27 additions and 9 deletions

File diff suppressed because one or more lines are too long

5
public/js/hls.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View file

@ -20,6 +20,10 @@ let
# so v.redd.it links will not be replaced.
# Images aren't supported due to errors from Teddit when the image
# wasn't first displayed via a post on the Teddit instance.
imgurRegex = re"((i|i.stack)\.)?imgur\.(com|io)"
mediumRegex = re"([a-zA-Z0-9_.-]+\.)?medium\.com"
wwwRegex = re"https?://(www[0-9]?\.)?"
m3u8Regex = re"""url="(.+.m3u8)""""
@ -68,6 +72,12 @@ proc replaceUrls*(body: string; prefs: Prefs; absolute=""): string =
result = result.replace(rdRegex, prefs.replaceReddit)
if prefs.replaceReddit in result and "/gallery/" in result:
result = result.replace("/gallery/", "/comments/")
if prefs.replaceImgur.len > 0 and "imgur" in result:
result = result.replace(imgurRegex, prefs.replaceImgur)
if prefs.replaceMedium.len > 0 and "medium.com" in result:
result = result.replace(mediumRegex, prefs.replaceMedium)
if absolute.len > 0 and "href" in result:
result = result.replace("href=\"/", &"href=\"{absolute}/")
@ -82,6 +92,8 @@ proc proxifyVideo*(manifest: string; proxy: bool): string =
for line in manifest.splitLines:
let url =
if line.startsWith("#EXT-X-MAP:URI"): line[16 .. ^2]
elif line.startsWith("#EXT-X-MEDIA") and "URI=" in line:
line[line.find("URI=") + 5 .. -1 + line.find("\"", start= 5 + line.find("URI="))]
else: line
if url.startsWith('/'):
let path = "https://video.twimg.com" & url

View file

@ -106,6 +106,14 @@ genPrefs:
replaceReddit(input, ""):
"Reddit -> Teddit/Libreddit"
placeholder: "Teddit hostname"
replaceImgur(input, ""):
"Imgur -> Rimgo"
placeholder: "Rimgo hostname"
replaceMedium(input, ""):
"Medium -> Scribe"
placeholder: "Scribe hostname"
iterator allPrefs*(): Pref =
for k, v in prefList:

View file

@ -31,9 +31,7 @@ proc getHmac*(data: string): string =
proc getVidUrl*(link: string): string =
if link.len == 0: return
let
link = link.replace("cmaf", "fmp4")
sig = getHmac(link)
let sig = getHmac(link)
if base64Media:
&"/video/enc/{sig}/{encode(link, safe=true)}"
else:

View file

@ -73,7 +73,7 @@ proc renderHead*(prefs: Prefs; cfg: Config; req: Request; titleText=""; desc="";
link(rel="alternate", type="application/rss+xml", href=rss, title="RSS feed")
if prefs.hlsPlayback:
script(src="/js/hls.light.min.js", `defer`="")
script(src="/js/hls.min.js", `defer`="")
script(src="/js/hlsPlayback.js", `defer`="")
if prefs.infiniteScroll: