summaryrefslogtreecommitdiff
path: root/4viewer
diff options
context:
space:
mode:
authorTyler Hoang <tyler@tylerhoang.xyz>2021-11-06 21:07:20 -0700
committerTyler Hoang <tyler@tylerhoang.xyz>2021-11-06 21:07:20 -0700
commit3e5458c95c50c06523de4c3cd8dc425f67d4dea5 (patch)
tree4d0d6e8e4c8d41b3b3e1b9072ce9b9503d8cd48f /4viewer
initial commit
Diffstat (limited to '4viewer')
-rwxr-xr-x4viewer22
1 files changed, 22 insertions, 0 deletions
diff --git a/4viewer b/4viewer
new file mode 100755
index 0000000..47b7f32
--- /dev/null
+++ b/4viewer
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+archivegif () {
+LINK=$(curl -s "${1}")
+title=$(echo "$LINK" | grep -oE post_title.*\<\/h2\> | head -1 | sed 's/post_title">//' | sed 's/<\/h2>//')
+urls=$(echo "$LINK" | grep -oP '"\K[^"\047]+(?=["\047])' | grep -E ".gif|.webm" | grep -v "s\." | grep "//" | grep torako | uniq)
+}
+
+
+mpv-chan() {
+ URL=$1
+ BOARD=$(echo $URL| grep -Po '([\w\d]+)\/thread' |cut -d'/' -f1)
+ title=$(curl -sL "${URL}.json" | jq -cr '.posts[0].sub')
+ urls=$(curl -sL "${URL}.json"|jq -cr '.posts[]|("https://i.4cdn.org/'${BOARD}'/"+(.tim|tostring) + .ext )'|grep -v null|paste -sd ' ')
+}
+
+if [[ "$1" == *"boards"* ]]; then
+ mpv-chan "$1"
+ else
+ archivegif "$1"
+fi
+mpv --quiet --prefetch-playlist=yes --no-pause --force-media-title="$title" --demuxer-cache-wait=no $urls