Skip to content

Instantly share code, notes, and snippets.

@oguz-ismail
Last active October 9, 2022 14:04
Show Gist options
  • Save oguz-ismail/acc35e9139ebfb48c105e192d872593a to your computer and use it in GitHub Desktop.
Save oguz-ismail/acc35e9139ebfb48c105e192d872593a to your computer and use it in GitHub Desktop.
printf '%s\n' "$@" \
| awk '
{
sub(/boards\.4chan(nel)?/, "a.4cdn")
print "url=" $0 ".json"
}
' \
| curl -sS -K - -w '"%{url}"' \
| jq -nr '
def url($board):
"url=https://i.4cdn.org/\($board)/\(.tim).webm";
def output($dir):
if .filename == "" then
"remote-name"
else
"output=\"\($dir)/\(.filename).webm\""
end;
def config($board; posts; $dir):
posts | output($dir), url($board);
foreach inputs as $in (
{url};
if has("url") then
{json: $in}
else
. + {url: $in}
end;
if has("json") and has("url") then
config(
.url | split("/")[3];
.json.posts[] | select(.ext == ".webm");
.json.posts[0].semantic_url
)
else
empty
end
)
' \
| curl -sSZ --create-dirs --http1.1 -K -
# vim: ft=sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment