My own archive of tweets
I put my own Twitter archive online, hosted here with individual tweet URLs like here. The “server” is all static HTML but the list of tweets is an infinite scroll thing. Oct 2006 to Nov 2022.
I made this with Julia Evans setup, itself based on Darius Kazemi’s tool. Darius’ program generates its own HTML view but it’s got an idiosyncratic presentation. Julia’s code takes the tweet data (from searchDocuments.js) and the media files and constructs a new HTML archive borrowed broadly from Nitter’s UI. The Vue-based infinite scrolling wouldn’t be my first choice for an archive but it works fine and only took a half hour to set up. The main thing I miss is thread nesting.
I mostly just followed Julia’s instructions, getting something basically working is very easy. The scripts aren’t a polished product but if you are comfortable hacking a little code it’s not hard to get working. I’m glad she shared them! Some details:
Here are the specific edits to the code to customize my archive:
- app.js: Replace two instances of b0rk with nelson
- index.html: Replace four instances of “julia” or her full name with mine. Replace two instances of “b0rk” with “nelson”.
- build.py: 5 instances of “b0rk” for “nelson”. 4 instances of “julia” for “Nelson”. (this page includes HTML similar to index.html).
- profile.jpg: replaced with my own image
Deployed by rsyncing the entire github package, Julia’s scripts write stuff in that directory. Then on the web server I deleted things that weren’t necessary for the static HTML: .git, scripts,
The other thing I did was write a script to filter my tweets by date. I decided to cut off the archive at Nov 3 2022, the stuff I posted afterwards is all not something I care to preserve, just bearing witness to Elon Musk’s destruction of the company and product.
#!/usr/bin/python
import json, pytz
from datetime import datetime
cutoff_dt = datetime(2022, 11, 4, tzinfo=pytz.UTC)
def cutoff(item):
created_at = item["created_at"]
dt = datetime.strptime(created_at, "%a %b %d %H:%M:%S %z %Y")
# print(dt, dt >= cutoff_dt, cutoff_dt)
if dt >= cutoff_dt:
return True
else:
return False
jsonp_header = 'const searchDocuments = '
data = open("searchDocuments.orig").read()
data = data[len(jsonp_header):]
tweets = json.loads(data)
filtered = tuple(t for t in tweets if not cutoff(t))
print(f'{len(tweets)} tweets in archive, {len(filtered)} passed filter')
with open('searchDocuments.js', 'w') as fp:
fp.write(jsonp_header)
json.dump(filtered, fp, separators=(',', ':'))