mirror of
https://github.com/rwinkhart/backtone.git
synced 2026-08-28 04:46:54 -04:00
Add unicode interpretation; add example for cached VideoCardz feed
This commit is contained in:
+16
-1
@@ -72,5 +72,20 @@ func stitchFields(info []string, connectors []string, indices []int8) string {
|
|||||||
output.WriteString(info[indices[i]])
|
output.WriteString(info[indices[i]])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return output.String()
|
return interpretUnicode(output.String())
|
||||||
|
}
|
||||||
|
|
||||||
|
func interpretUnicode(s string) string {
|
||||||
|
// match \uXXXX patterns
|
||||||
|
r := regexp.MustCompile(`\\u([0-9a-fA-F]{4})`)
|
||||||
|
result := r.ReplaceAllStringFunc(s, func(match string) string {
|
||||||
|
// extract the hex value
|
||||||
|
hexStr := match[2:] // skip the \u part
|
||||||
|
code, err := strconv.ParseInt(hexStr, 16, 32)
|
||||||
|
if err != nil {
|
||||||
|
return match // if parsing fails, return original
|
||||||
|
}
|
||||||
|
return string(rune(code))
|
||||||
|
})
|
||||||
|
return result
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
<?php
|
||||||
|
$command = "/usr/local/bin/backtone";
|
||||||
|
$argument = "BASE64ENCODEDINPUTXML";
|
||||||
|
$cacheFile = __DIR__ . "/cache/feed.xml";
|
||||||
|
$tempFile = "/tmp/feed.xml" . ".tmp";
|
||||||
|
|
||||||
|
// serve cached file immediately
|
||||||
|
header("Content-Type: application/xml; charset=utf-8");
|
||||||
|
readfile($cacheFile);
|
||||||
|
|
||||||
|
// trigger background regeneration
|
||||||
|
exec(escapeshellcmd($command) . " " . escapeshellarg($argument) . " > " . escapeshellarg($tempFile) . " 2>&1 && mv " . escapeshellarg($tempFile) . " " . escapeshellarg($cacheFile) . " &");
|
||||||
|
?>
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
<input>
|
||||||
|
<flareSolverrEndpoint>http://PLACEHOLDER:8191/v1</flareSolverrEndpoint>
|
||||||
|
<regex
|
||||||
|
><![CDATA[<item>.*?<title>(.*?)<\/title>.*?<link>(.*?)<\/link>.*?<description><!\[CDATA\[ (.*?)<br\/>]]></regex>
|
||||||
|
<loadSeconds>0</loadSeconds>
|
||||||
|
<maxFeedItems>10</maxFeedItems>
|
||||||
|
<feed>
|
||||||
|
<title>
|
||||||
|
<parent>VideoCardz</parent>
|
||||||
|
<captureGroupIndex>1</captureGroupIndex>
|
||||||
|
</title>
|
||||||
|
<link><parent>https://videocardz.com/rss-feed</parent>
|
||||||
|
<captureGroupIndex>2</captureGroupIndex>
|
||||||
|
</link>
|
||||||
|
<description>
|
||||||
|
<parent>Official RSS Feed from VideoCardz.com translated to Atom.</parent>
|
||||||
|
<captureGroupIndex>3</captureGroupIndex>
|
||||||
|
</description>
|
||||||
|
<authorName>
|
||||||
|
<parent>VideoCardz.com</parent>
|
||||||
|
</authorName>
|
||||||
|
<authorEmail>
|
||||||
|
<parent>maciej+rssfeed@videocardz.com</parent>
|
||||||
|
</authorEmail>
|
||||||
|
</feed>
|
||||||
|
</input>
|
||||||
Reference in New Issue
Block a user