User:Jonas Lund/In-Search-Of-Lost-Time

From Media Design: Networked & Lens-Based wiki
Jump to navigation Jump to search


In Search Of Lost Time (1913 - 1927, À la recherche du temps perdu) by Marcel Proust, split up into blocks of 140 characters, tweeted by


The complete text is read by python, the first 140 characters are extracted and stored as a variable, the remaining text is kept in another. The text files is overwritten with the reamining text, so next time it's read, it will be the following 140 characters that are extracted. Once the 140 chars are stored in a variable, next step is to post them as a tweet by @proust2000. This can be done with the python-twitter library, which is a wrapper for the Twitter Api. To be able to send a tweet, you need to make a twitter app that can do the actual tweeting. You can send tweets on someones behalf by asking them to login to twitter, and create a authentication token, this can be accomplished by running this script.

Get Twitter Token

Once the correct tokens are generated, it's just a matter of using the python-twitter function api.PostUpdate(text), where text is the variable that stores the 140 chars.

To run it every hour, I created a cronjob on a server (ideally it should be living on the PZ sever, but didn't have access to it at the time of writing), which calls the python script

@hourly /usr/local/bin/setlock -n /tmp/cronlock.3549243.115331 sh -c $'/home/pandl/env/bin/python /home/pandl/proust/'

The Python script

#Output 'In Search Of Lost Time' to @proust2000
#Dependencies, +
import twitter
import urlparse
import oauth2 as oauth

f = open("insearchoflosttime.txt", 'r+')
swan =

#Get first 140 char from text
first = swan[0:140]

#The Remaining text
rest = swan[140:]

#Overwrite the text with the remaining chars

#Publish first to twitter stream
#Twitter Authentication
oauth_token_secret = ''
user_id = ''
oauth_token = ''
screen_name = ''

#Initate the API
api = twitter.Api(consumer_key=consumer_key,
consumer_secret=consumer_secret, access_token_key=oauth_token, access_token_secret=oauth_token_secret)

#Send Tweet
status = api.PostUpdate(first)

#output first for good measure
print first


In Search Of Lost Time is known for being one of the longest novels ever written, the novel consists of 7 volumes and has a total of approximately 1.5 million words (depending on translation). I've been wanting to read it for a long time but haven't been able to get around it, so I thought if I can integrate into my daily stream of information, I would just read it on the go, without any considerate effort. Just like a status update from one of my friends, In Search Of Lost Time can also become part of my social graph.