Skip to content

Instantly share code, notes, and snippets.

Forked from anonymous/gist:4356672
Last active Dec 10, 2015
What would you like to do?
Fetch all books from Wolne Lektury
import simplejson, requests, urllib, re
# -*- encoding: utf-8 -*-
from slughifi import slughifi
### with django's slugify hardcoded inside from:
for z in simplejson.loads(requests.get("").content.decode('utf8')):
p = simplejson.loads(requests.get(z['href']).content)
if p['parent'] is None:
authorList = z['author'].split(' ')
authLen = len(authorList)
if authLen > 1:
lName = authorList[-1]
fNames = ' '.join(authorList[:-1])
author = "%s, %s" % (lName, fNames)
author = z['author']
slug = slughifi(author+' - '+p['title'])
print "Fetching %s by %s (%s) to" % (p['title'], author, p['mobi'], slug)
urllib.urlretrieve(p['mobi'], slug + '.mobi')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment