Linksnappy Command Line Downloader (Python)

Simple Python script to download files via Linksnappy.

#! /usr/bin/env python

import requests
import json
import sys

USERNAME = 'my username'
PASSWORD = 'my pass'

params = {'link': sys.argv[1],
'type': '',
'username': USERNAME,
'password': PASSWORD}

resp ='',
data={'genLinks': json.dumps(params)})

url = json.loads(resp.text)['links'][0]['generated']

local_filename = url.split('/')[-1]

r = requests.get(url, stream=True)
    with open(local_filename, 'wb') as f:
        for chunk in r.iter_content(chunk_size=1024):
            if chunk: # filter out keep-alive new chunks
print local_filename