Skip to content

Instantly share code, notes, and snippets.

@lloyddavis
Last active August 29, 2015 13:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lloyddavis/9807117 to your computer and use it in GitHub Desktop.
Save lloyddavis/9807117 to your computer and use it in GitHub Desktop.
qik URL grabber

Download your qik videos from command line

Disclaimer: This is what I got working for me:

it's provided free for you to use but you should take care not to swallow my code unthinkingly look at it and think about what it's doing. I can't guarantee that it will work or that it won't damage your computer.
If you know me, you might trust me a little bit more, but still - use your noggin too :) Note also that this only gets you your media files (with nonsensical file names) I haven't had time to think about metadata

If you have better ideas for achieving the same thing before 30th March APRIL 2014, please shout in the comments!!!! I'd really appreciate if someone who knows what they're doing could have a look :) #IANAD

You'll need:

  • your username and password and the number of pages of videos you have on qik.com

  • a system on which you can use (or install & use) the bash command line tools:

grep, wget (curl does similar, but I'm not as familiar with it) & sed

I've run it on terminal for Mac OS X (but I think I had to install wget - I use homebrew for that sort of thing)

  1. The following (with NUM_PAGES and YOUR_USERNAME replaced) will give you a list in the file "qik-video-urls.txt" of individual page URLS

for i in {1..NUM_PAGES}; do wget -q -O- http://qik.com/YOUR_USERNAME/videos?page=$i | grep play-button | sed -e 's/<a .*href=['"'"'"]//' -e 's/["'"'"'].*$//' -e '/^$/ d'; done > qik-video-urls.txt

** you could replace wget -q -O- with curl -s if you don't have wget **

Explanation: We loop through NUM_PAGES times getting the contents of the pages that your presented with under YOUR_USERNAME; we select those lines that have the phrase "play-button" and then strip out the bits that aren't the URL.

  1. You need to authenticate with qik.com for the next stage. You also will be sending your username and password in plaintext so be sure you're on your own, secure wifi and preferably change your password especially for this stage - it's going to be useless in a few days anyway, but if you're using one that's the same or similar to one you use on other systems, better safe than sorry.

a) first you send your login details to the site

`wget --save-cookies cookies.txt --keep-session-cookies --post-data 'login=USERNAME&password=PASSWORD' https://qik.com/session`

b) then get the links to the downloads and put them in a file

`wget --load-cookies cookies.txt -q -O- -i qik-video-urls.txt | grep video-download > qik-download-links.txt`

c) optional at this stage you might also like to make a sub-directory html and run this in that directory:

`wget --load-cookies cookies.txt -q -i qik-video-urls.txt` 

That will give you a copy of each page in html which you can fillet for the metadata later on if you want.

  1. Now you have a file with a bunch of HTML code for links in it. All the href and attributes stuff is there

here's an example:

`<a href="http://media.qik.com/vod/mp4-download/4b6447b98836494eb0a7550054d1bd84?download" class="video-button video-download" data-tooltip="click to download&hellip;"></a>`

you may be able to strip that out with a single command, but the combination of sed commands that I used in step 1 don't seem to work for me. You should be able to use find and replace in a text editor to strip out everything EXCEPT the URL ie the bit that starts 'http' and ends 'download' be sure to take the " off the end of download!

so assuming you now have a file with a list of URLs in you can do

wget -i qik-download-links.txt and then watch while your precious videos get sucked down.

Once it's all done, you can add an '.mp4' extension to each file and then what you do with them all is up to you.

@lloyddavis
Copy link
Author

How to download your qik.com videos (which is going down on 30th March 2014) without sitting and clicking on every page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment