Skip to content

Instantly share code, notes, and snippets.

@LeeHolmes
Created November 15, 2022 17:57
Show Gist options
  • Save LeeHolmes/4ebeed5df73ac04678d7c954f74701e6 to your computer and use it in GitHub Desktop.
Save LeeHolmes/4ebeed5df73ac04678d7c954f74701e6 to your computer and use it in GitHub Desktop.
Recover your Twitter threads from your Twitter export data
$tweetJson = (Get-Content .\tweets.js -Raw).Substring("window.YTD.tweets.part0 =".Length)
$tweets = $tweetJson | ConvertFrom-Json
$currentThread = ""
foreach($currentTweetJson in $tweets)
{
$currentTweet = $currentTweetJson.tweet
if($currentTweet.in_reply_to_screen_name -eq "Lee_Holmes")
{
if($currentTweet.full_text -notmatch '@')
{
$currentThread = $currentTweet.full_text + "`r`n" + $currentThread
}
}
else
{
if($currentThread)
{
if($currentTweet.full_text -notmatch '@')
{
$currentThread = $currentTweet.full_text + "`r`n" + $currentThread
"-"*50
$currentThread
"-"*50
}
$currentThread = ""
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment