WIP torrent examples
This commit is contained in:
@@ -0,0 +1,28 @@
|
|||||||
|
GET / {
|
||||||
|
echo "text/html" > @fifo:response/header/Content-Type
|
||||||
|
cat > @fifo:response/body <<-HTML
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
<a href='javascript: Array.from(document.querySelectorAll("a")).filter(x => x.href.indexOf("magnet") != -1 ).map(x => x.href = "http://localhost:8080/save/magnet?link="+encodeURI(x.href))'>Add me to your bookmarks!</a>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
HTML
|
||||||
|
}
|
||||||
|
|
||||||
|
GET /save/magnet {
|
||||||
|
set -x
|
||||||
|
link=@value:request/param/link
|
||||||
|
[ -z $link ] && echo 400 > @fifo:response/status && exit 0
|
||||||
|
|
||||||
|
watch_folder=/tmp
|
||||||
|
cd $watch_folder
|
||||||
|
[[ "$link" =~ xt=urn:btih:([^&/]+) ]] || exit;
|
||||||
|
echo "d10:magnet-uri${#link}:${link}e" > "meta-${BASH_REMATCH[1]}.torrent"
|
||||||
|
|
||||||
|
echo 302 > @fifo:response/status
|
||||||
|
echo "/torrent/list" > @fifo:response/header/Location
|
||||||
|
}
|
||||||
|
|
||||||
|
GET /torrent/list {
|
||||||
|
echo "..." > @fifo:response/body
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user