mirror of
https://github.com/zedeus/nitter.git
synced 2024-05-19 17:48:10 +00:00
Compare commits
3 commits
e3e78b3e01
...
8a457f8535
Author | SHA1 | Date | |
---|---|---|---|
8a457f8535 | |||
cdff5e9b1c | |||
75316a55ad |
5
public/js/hls.light.min.js
vendored
5
public/js/hls.light.min.js
vendored
File diff suppressed because one or more lines are too long
5
public/js/hls.min.js
vendored
Normal file
5
public/js/hls.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
|
@ -82,6 +82,8 @@ proc proxifyVideo*(manifest: string; proxy: bool): string =
|
||||||
for line in manifest.splitLines:
|
for line in manifest.splitLines:
|
||||||
let url =
|
let url =
|
||||||
if line.startsWith("#EXT-X-MAP:URI"): line[16 .. ^2]
|
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
|
else: line
|
||||||
if url.startsWith('/'):
|
if url.startsWith('/'):
|
||||||
let path = "https://video.twimg.com" & url
|
let path = "https://video.twimg.com" & url
|
||||||
|
|
|
@ -15,7 +15,7 @@ proc redisKey*(page, name, cursor: string): string =
|
||||||
if cursor.len > 0:
|
if cursor.len > 0:
|
||||||
result &= ":" & cursor
|
result &= ":" & cursor
|
||||||
|
|
||||||
proc timelineRss*(req: Request; cfg: Config; query: Query): Future[Rss] {.async.} =
|
proc timelineRss*(req: Request; cfg: Config; query: Query; tab, param: string): Future[Rss] {.async.} =
|
||||||
var profile: Profile
|
var profile: Profile
|
||||||
let
|
let
|
||||||
name = req.params.getOrDefault("name")
|
name = req.params.getOrDefault("name")
|
||||||
|
@ -39,7 +39,7 @@ proc timelineRss*(req: Request; cfg: Config; query: Query): Future[Rss] {.async.
|
||||||
return Rss(feed: profile.user.username, cursor: "suspended")
|
return Rss(feed: profile.user.username, cursor: "suspended")
|
||||||
|
|
||||||
if profile.user.fullname.len > 0:
|
if profile.user.fullname.len > 0:
|
||||||
let rss = renderTimelineRss(profile, cfg, multi=(names.len > 1))
|
let rss = renderTimelineRss(profile, cfg, tab, param, multi=(names.len > 1))
|
||||||
return Rss(feed: rss, cursor: profile.tweets.bottom)
|
return Rss(feed: rss, cursor: profile.tweets.bottom)
|
||||||
|
|
||||||
template respRss*(rss, page) =
|
template respRss*(rss, page) =
|
||||||
|
@ -94,7 +94,7 @@ proc createRssRouter*(cfg: Config) =
|
||||||
if rss.cursor.len > 0:
|
if rss.cursor.len > 0:
|
||||||
respRss(rss, "User")
|
respRss(rss, "User")
|
||||||
|
|
||||||
rss = await timelineRss(request, cfg, Query(fromUser: @[name]))
|
rss = await timelineRss(request, cfg, Query(fromUser: @[name]), "", "")
|
||||||
|
|
||||||
await cacheRss(key, rss)
|
await cacheRss(key, rss)
|
||||||
respRss(rss, "User")
|
respRss(rss, "User")
|
||||||
|
@ -113,8 +113,10 @@ proc createRssRouter*(cfg: Config) =
|
||||||
of "search": initQuery(params(request), name=name)
|
of "search": initQuery(params(request), name=name)
|
||||||
else: Query(fromUser: @[name])
|
else: Query(fromUser: @[name])
|
||||||
|
|
||||||
|
let param = if tab != "search": ""
|
||||||
|
else: genQueryUrl(query)
|
||||||
let searchKey = if tab != "search": ""
|
let searchKey = if tab != "search": ""
|
||||||
else: ":" & $hash(genQueryUrl(query))
|
else: ":" & $hash(param)
|
||||||
|
|
||||||
let key = redisKey(tab, name & searchKey, getCursor())
|
let key = redisKey(tab, name & searchKey, getCursor())
|
||||||
|
|
||||||
|
@ -122,7 +124,7 @@ proc createRssRouter*(cfg: Config) =
|
||||||
if rss.cursor.len > 0:
|
if rss.cursor.len > 0:
|
||||||
respRss(rss, "User")
|
respRss(rss, "User")
|
||||||
|
|
||||||
rss = await timelineRss(request, cfg, query)
|
rss = await timelineRss(request, cfg, query, tab, param)
|
||||||
|
|
||||||
await cacheRss(key, rss)
|
await cacheRss(key, rss)
|
||||||
respRss(rss, "User")
|
respRss(rss, "User")
|
||||||
|
|
|
@ -31,9 +31,7 @@ proc getHmac*(data: string): string =
|
||||||
|
|
||||||
proc getVidUrl*(link: string): string =
|
proc getVidUrl*(link: string): string =
|
||||||
if link.len == 0: return
|
if link.len == 0: return
|
||||||
let
|
let sig = getHmac(link)
|
||||||
link = link.replace("cmaf", "fmp4")
|
|
||||||
sig = getHmac(link)
|
|
||||||
if base64Media:
|
if base64Media:
|
||||||
&"/video/enc/{sig}/{encode(link, safe=true)}"
|
&"/video/enc/{sig}/{encode(link, safe=true)}"
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -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")
|
link(rel="alternate", type="application/rss+xml", href=rss, title="RSS feed")
|
||||||
|
|
||||||
if prefs.hlsPlayback:
|
if prefs.hlsPlayback:
|
||||||
script(src="/js/hls.light.min.js", `defer`="")
|
script(src="/js/hls.min.js", `defer`="")
|
||||||
script(src="/js/hlsPlayback.js", `defer`="")
|
script(src="/js/hlsPlayback.js", `defer`="")
|
||||||
|
|
||||||
if prefs.infiniteScroll:
|
if prefs.infiniteScroll:
|
||||||
|
|
|
@ -82,8 +82,20 @@ Twitter feed for: ${desc}. Generated by ${cfg.hostname}
|
||||||
#end for
|
#end for
|
||||||
#end proc
|
#end proc
|
||||||
#
|
#
|
||||||
#proc renderTimelineRss*(profile: Profile; cfg: Config; multi=false): string =
|
#proc renderTimelineRss*(profile: Profile; cfg: Config; tab, param: string; multi=false): string =
|
||||||
#let urlPrefix = getUrlPrefix(cfg)
|
#let urlPrefix = getUrlPrefix(cfg)
|
||||||
|
#var atomLink = &"{urlPrefix}/{profile.user.username}"
|
||||||
|
#var link = &"{urlPrefix}/{profile.user.username}"
|
||||||
|
#if tab != "":
|
||||||
|
# atomLink &= "/" & tab
|
||||||
|
# link &= "/" & tab
|
||||||
|
#end if
|
||||||
|
#atomLink &= "/rss"
|
||||||
|
#if param != "":
|
||||||
|
# let escParam = xmltree.escape(param)
|
||||||
|
# atomLink &= "?" & escParam
|
||||||
|
# link &= "?" & escParam
|
||||||
|
#end if
|
||||||
#result = ""
|
#result = ""
|
||||||
#let handle = (if multi: "" else: "@") & profile.user.username
|
#let handle = (if multi: "" else: "@") & profile.user.username
|
||||||
#var title = profile.user.fullname
|
#var title = profile.user.fullname
|
||||||
|
@ -93,9 +105,9 @@ Twitter feed for: ${desc}. Generated by ${cfg.hostname}
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
|
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
|
||||||
<channel>
|
<channel>
|
||||||
<atom:link href="${urlPrefix}/${profile.user.username}/rss" rel="self" type="application/rss+xml" />
|
<atom:link href="${atomLink}" rel="self" type="application/rss+xml" />
|
||||||
<title>${title}</title>
|
<title>${title}</title>
|
||||||
<link>${urlPrefix}/${profile.user.username}</link>
|
<link>${link}</link>
|
||||||
<description>${getDescription(handle, cfg)}</description>
|
<description>${getDescription(handle, cfg)}</description>
|
||||||
<language>en-us</language>
|
<language>en-us</language>
|
||||||
<ttl>40</ttl>
|
<ttl>40</ttl>
|
||||||
|
@ -131,15 +143,16 @@ ${renderRssTweets(tweets, cfg)}
|
||||||
#end proc
|
#end proc
|
||||||
#
|
#
|
||||||
#proc renderSearchRss*(tweets: seq[Tweets]; name, param: string; cfg: Config): string =
|
#proc renderSearchRss*(tweets: seq[Tweets]; name, param: string; cfg: Config): string =
|
||||||
#let link = &"{getUrlPrefix(cfg)}/search"
|
#let urlPrefix = getUrlPrefix(cfg)
|
||||||
#let escName = xmltree.escape(name)
|
#let escName = xmltree.escape(name)
|
||||||
|
#let escParam = xmltree.escape(param)
|
||||||
#result = ""
|
#result = ""
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
|
<rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
|
||||||
<channel>
|
<channel>
|
||||||
<atom:link href="${link}" rel="self" type="application/rss+xml" />
|
<atom:link href="${urlPrefix}/search/rss?${escParam}" rel="self" type="application/rss+xml" />
|
||||||
<title>Search results for "${escName}"</title>
|
<title>Search results for "${escName}"</title>
|
||||||
<link>${link}</link>
|
<link>${urlPrefix}/search?${escParam}</link>
|
||||||
<description>${getDescription(&"Search \"{escName}\"", cfg)}</description>
|
<description>${getDescription(&"Search \"{escName}\"", cfg)}</description>
|
||||||
<language>en-us</language>
|
<language>en-us</language>
|
||||||
<ttl>40</ttl>
|
<ttl>40</ttl>
|
||||||
|
|
Loading…
Reference in a new issue