From d6d1d7ac9652febe9f1c2af69201c176c79a56af Mon Sep 17 00:00:00 2001 From: Alex Thomassen Date: Sat, 1 Jul 2023 22:58:33 +0000 Subject: [PATCH] Initial implementation --- .gitignore | 4 ++++ GfycatGrab.sh | 19 +++++++++++++++++++ README.md | 19 +++++++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 .gitignore create mode 100755 GfycatGrab.sh create mode 100644 README.md diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..07c13f1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*.json + +data +!data/.gitkeep \ No newline at end of file diff --git a/GfycatGrab.sh b/GfycatGrab.sh new file mode 100755 index 0000000..9c50a94 --- /dev/null +++ b/GfycatGrab.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"; +FALLBACK_DATA_DIR="${SCRIPT_DIR}/data"; + +if [[ -z "${GFYCAT_DIR}" ]]; then + echo "GFYCAT_DIR not set, using: ${FALLBACK_DATA_DIR}"; + GFYCAT_DIR="${FALLBACK_DATA_DIR}"; +fi + +for json in $(ls *.json); +do + urls="$(cat $json | jq -r '.gfycats[] | .mp4Url')"; + for url in $urls; + do + echo "Downloading $url"; + curl --output-dir "${GFYCAT_DIR}" -O -C - "${url}"; + done +done \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..48586a6 --- /dev/null +++ b/README.md @@ -0,0 +1,19 @@ +# GfycatGrab + +Budget way of grabbing all Gfycats from your account. + +## Requirements + +1. jq +2. curl + - `v7.73.0+` since this script uses the `--output-dir` flag: https://daniel.haxx.se/blog/2020/09/10/store-the-curl-output-over-there/ + +## To use the script + +1. Visit your Gfycat profile page, with your browser's developer console (network tab) open +2. Filter URLs by `/me/gfycats` +3. Copy the JSON response from the "GET" request. Save it as `any-name.json` +4. If you have more than 100 GIFs in your profile, repeat steps 1-3 for the next page (scroll to bottom), and save it as `any-name-2.json` +5. Run the script: `./GfycatGrab.sh` + - By default the script downloads to `./data` (relative to where the script is saved). + - If you want to download to a different directory, specify the `GFYCAT_DIR` environment variable: `GFYCAT_DIR=/path/to/where/you/want/download/files ./GfycatGrab.sh` \ No newline at end of file