-
-
Save oguz-ismail/acc35e9139ebfb48c105e192d872593a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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