How situations drive me to write my own applications?

This article shows how I created an audio book downloader because I am tired of manual downloading.

Who am I?

I am a good fan of books.I have an e-book reader.I listen to podcasts often.I always  download audio books before journey.It is pleasant to listen stories and novels rather than reading,means using ears rather than eyes.So I always aware of some websites which provide good audio books to listen online.They are,ITunes and many more.Only few provide the downloadable audio books free with no restrictions.The main players are: , , Everything is fine for some days. I was adjusted with them.Then came the actual problem.The recordings which are made by librivox,loyalbooks are volunteered.It means anybody can create and upload an audio book.Some books are good to listen,but many others are boring and voices are below average.I need premium voices for zero bucks.I searched on the web and found one such website.It is Lit2Go.   lit2go It consists of all classical books recorded with premium voices.But it kept as a free service because it is one of the academical project of .

What is drawback of Lit2Go?

Lit2Go is a free service.It divides each book into no of chapters.It allows you to play chapters online.But we can download those by  right clicking, a common way.But if chapters are more then downloading them is dead boring task.Going to each chapter link and right clicking.Next copying them to a folder.I do it frequently and always thought “why these people are not providing all chapters in a single file?”.

How I overcame that ?

This is my personal life and python is still playing a role in it.Computing is made simpler like talking about a movie to a friend.I created a home application called “createbook” that asks me which book to download.Moreover it  downloads all chapters within a single folder in a systematic order.Just by running a small script, I can select and download entire audio book now.

How createbook works?

mike Just i ran the script(You can just click on script,if you were a windows user) and I got listed with all classic book options. select I selected 199(Winesburg Ohio) and I saw this folder in my script directory after some time. ohio ohio1 All 26 chapters were downloaded excellently with a folder named after book. Now I am running it happily.Next copying the downloaded folder to my phone,so that enjoying the premium voices without having any pain of downloading.Python helped me in this situation.It may help you too.Just apply it and you will see the comfort you get.Below is the code for my application.I used lxml,requests to do this.In your case,find out the library that suits your situation and build your own fun applications.

#Just run it,select book and sit back,sip coffee
import requests
from lxml import html
import os

def createbook(url):
    res = requests.get(url)
    folder = url.split('/')[-2]
    if not os.path.exists(folder):
    tree  = html.fromstring(res.text)
    parts = tree.xpath('//dl/dt/a/@href')
    for i in parts:
        res = requests.get(i)
        tree  = html.fromstring(res.text)
        parturl = tree.xpath('//audio/source[@type="audio/mpeg"]/@src')
        for surl in parturl:
            with open('%s/%s'%(folder,surl.split('/')[-1]), 'wb') as handle:
                response = requests.get(surl, stream=True)
                for block in response.iter_content(1024):
                    if not block:

    print '"%s" is successfully downloaded.....'%folder

res = requests.get('')
tree = html.fromstring(res.text)
books = [i.encode('utf-8') for i in tree.xpath('//figcaption[@class="title"]/a/text()')]
links = tree.xpath('//figcaption[@class="title"]/a/@href')

catalog = dict(zip(books,links))
numcatalog = enumerate(books,1)
chose = {}
print '@@@@@@@@@@ Select from the books below @@@@@@@@@@\n'

for i,j in numcatalog:
    print '%d) %s'%(i,j)
    chose[i] = catalog[j]

choice = int(raw_input('\nSelect Book:'))

print 'Your book started downloading.......'

If you too have the same taste of listening to audio books ,feel free to use this script and download classic can find same code in my git repository.The output book folder will be on the same directory of your script.I advise you to use python computing power, wherever it is required.Create your own applications and be comfort.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s