Pull out images from a Minus Gallery, using vim.

I was recently told via reddit that it was hard to pull images from Minus.com as they’ve hidden it behind javascript, and I just took a look to see what I could do, and lo and behold, vim comes to our rescue. In the spirit of Derek Wyatt, I wanted to make a quick tutorial on how to pull those images, in maybe a dozen vim commands.  So just check out that reddit link and enjoy.

Turns a page source into a bunch of valid image links.

 

Here’s a bit of what it might look like, with comments quickly added. I’m
making some significant assumptions that these are always jpgs and that all the
ids are valid.

"#open a minus page
e http://minus.com/mPrwtuN5NAAIH 
"#delete everything upto "items"
normal ggD/"items" 
"#delete from the line under that to end of file
normal jdG
"# split the sets of curly braces onto their own line
s/{\{-}},/&\r/
"# put each key/value pair onto their own line
%s/"\{-},/&\r
"# delete all lines not containing  "id"
v/^ "id"/d
"# remove everything upto the beginning of the id
%s/^.*": "//
"# remove everything after
%s/",$//
"# prepend the necessary URL stuff
%s/^/http:\/\/www.i.minus.com\/i/
"# append the filetype
%s/$/.jpg/
Bookmark the permalink.

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>