From d32915b2daa6efb683b9d55589299fcafddbcb80 Mon Sep 17 00:00:00 2001 From: Nick/Nelson Date: Fri, 15 Sep 2017 03:21:39 +0000 Subject: [PATCH] Initial commit --- README.md | 14 ++++++++++++++ vsco-dl.rb | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 README.md create mode 100644 vsco-dl.rb diff --git a/README.md b/README.md new file mode 100644 index 0000000..a6f38ba --- /dev/null +++ b/README.md @@ -0,0 +1,14 @@ +vsco-dl +======= + +dependency-less ruby script that downloads - [in other words, steals](https://nakedsecurity.sophos.com/2017/09/12/why-are-redditors-ripping-images-from-instagram-because-they-can/) - all the images on a vsco user's account (including metadata) + +usage +----- + ruby vsco-dl.rb username + +y tho +----- +¯\\_(ツ)_/¯ + +s/o to the [instagram archiving project on /r/DataHoarder](https://www.reddit.com/r/DataHoarder/comments/5m36zr/distributed_archivingsnapshots_of_instagram/), which is what inspired me to write this in the first place diff --git a/vsco-dl.rb b/vsco-dl.rb new file mode 100644 index 0000000..053bae4 --- /dev/null +++ b/vsco-dl.rb @@ -0,0 +1,32 @@ +require 'json' +require 'open-uri' + +user = ARGV[0] +Dir.mkdir user unless File.exist? user + +# this is v gross, but they probably do it like this on purpose +initial = open "https://vsco.co/#{user}/images/1" +vs = /vs=(\S*);/.match(initial.meta['set-cookie']).captures[0] +siteId = JSON.parse(/window.VSCOVARS.SiteSettings = ({.*})/.match(initial.read).captures[0])['id'] + +images = JSON.load(open("https://vsco.co/ajxp/#{vs}/2.0/medias?site_id=#{siteId}&page=0&size=-1", 'Cookie' => "vs=#{vs};"))['media'] + +images.each_with_index do |r, i| + print "Image #{i + 1} of #{images.length}\r" + $stdout.flush + + unless File.exist? "#{user}/#{r['upload_date']}.json" and File.exist? "#{user}/#{r['upload_date']}.jpg" + File.open "#{user}/#{r['upload_date']}.json", 'w' do |file| + file.write JSON.pretty_generate r + end + open "https://#{r['responsive_url']}" do |f| + File.open "#{user}/#{r['upload_date']}.jpg", 'wb' do |file| + file.write f.read + end + end + end + + if (i + 1) == images.length + puts "Image #{i + 1} of #{images.length} ...done!" + end +end