Created
November 15, 2022 17:57
-
-
Save LeeHolmes/4ebeed5df73ac04678d7c954f74701e6 to your computer and use it in GitHub Desktop.
Recover your Twitter threads from your Twitter export data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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