Skip to content

Convert the t.co URLs in your Twitter archive back to their full form

Notifications You must be signed in to change notification settings

DocNow/twitter-archive-unshorten

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

twitter-archive-unshorten

Twitter's archive download includes shortened t.co URLs instead of the original URLs that you tweeted. If Twitter ever goes away, the server at t.co won't be available to respond to requests.

twitter-archive-unshorten is a small Python program that will examine all the JavaScript files in the archive download and rewrite the t.co short URLs to their original full URL form. This means the context for your archived tweets will make a little more sense after Twitter is gone. Maybe you can look up those URLs in the Internet Archive if they are no longer available. This would be impossible if all you had was the short URL.

Install

$ pip3 install twitter-archive-unshorten

Run

  1. Unzip your Twitter archive zip file.
  2. Open a terminal window and run: twitter-archive-unshorten /path/to/your/archive/directory/

It might take a while, depending on how many tweets you have. Once it's finished you should be able open your archive and interact with it without the t.co URLs.

The mapping of short URLs to long URLs that was used is saved in your archive directory as data/shorturls.json.

Test

If you'd like to develop further you can run the existing tests:

$ pip3 install pytest
$ pytest test.py

About

Convert the t.co URLs in your Twitter archive back to their full form

Resources

Stars

Watchers

Forks

Packages

No packages published