TwitterDL

A stupid simple bash script to download twitter media
git clone git://xatko.vsos.ethz.ch/TwitterDL.git
Log | Files | Refs

commit 3a9157d0d1ef6ddc2e4639d84828b6239e75d2e6
Author: Dominik Schmidt <das1993@hotmail.com>
Date:   Sun,  5 Aug 2018 22:38:05 +0200

Initial Commit

Diffstat:
README.md | 21+++++++++++++++++++++
twitterdl.sh | 27+++++++++++++++++++++++++++
2 files changed, 48 insertions(+), 0 deletions(-)

diff --git a/README.md b/README.md @@ -0,0 +1,21 @@ +TwitterDL +========= + +A stupid twitter downloader + + +Dependencies +------------ + +* curl +* jq +* bash + +Usage +----- + +``` + ./twitterdl.sh <Twitter-ID> <Latest Post> +``` + +This will output a list of all images to stdout, pipe it into a file or pass it to wget. diff --git a/twitterdl.sh b/twitterdl.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +function cleanup(){ + rm "${tmpfile}" + exit 1 +} + +trap ERR cleanup + +hmi="true" +mpos="$2" + +tmpfile="$(mktemp -p twitterdl.XXXXXX)" + +while : +do + curl "https://twitter.com/i/profiles/show/${1}/media_timeline?include_available_features=1&include_entities=1&max_position=${mpos}&reset_error_state=false" > "${tmpfile}" + hmi="$(jq '.has_more_items' -r < "${tmpfile}")" + mpos="$(jq '.min_position' -r < "${tmpfile}")" + + jq '.items_html' -r <"${tmpfile}" | sed -n 's|.*data-image-url="\([^"]\+\)".*|\1|p' + + if [ "$hmi" != "true" ] + then + break; + fi +done