diff --git a/timeline_v2.go b/timeline_v2.go index 3246b03..372941d 100644 --- a/timeline_v2.go +++ b/timeline_v2.go @@ -56,8 +56,6 @@ func (result *result) parse() *Tweet { if result.QuotedStatusResult.Result != nil { tw.QuotedStatus = result.QuotedStatusResult.Result.parse() } - tw.HTML = expandURLs(tw.HTML, legacy.Entities.URLs, legacy.ExtendedEntities.Media) - tw.HTML = expandURLs(tw.Text, legacy.Entities.URLs, legacy.ExtendedEntities.Media) return tw } diff --git a/tweets_test.go b/tweets_test.go index 3b916f4..aec02e9 100644 --- a/tweets_test.go +++ b/tweets_test.go @@ -92,7 +92,7 @@ func TestGetTweetWithVideo(t *testing.T) { Name: "X", PermanentURL: "https://twitter.com/X/status/1697304622749086011", Photos: nil, - Text: "on iOS & Android, you can now swipe to reply when you slide into their DMs https://t.co/evuWpMfBxQ", + Text: "on iOS & Android, you can now swipe to reply when you slide into their DMs https://pbs.twimg.com/amplify_video_thumb/1697304568550330368/img/BUlESpef6FmWV_j2.jpg", Timestamp: 1693503931, UserID: "783214", Username: "X", @@ -125,7 +125,7 @@ func TestGetTweetWithMultiplePhotos(t *testing.T) { URL: "https://pbs.twimg.com/media/FeUJKuxXEAAa6t7.jpg", }, }, - Text: "More ways to discover videos on Twitter are here!\n\nNow on iOS, videos on your timeline will open in our full screen immersive video player, where you can swipe up to keep discovering more content. https://t.co/XI2vM8DKXA", + Text: "More ways to discover videos on Twitter are here!\n\nNow on iOS, videos on your timeline will open in our full screen immersive video player, where you can swipe up to keep discovering more content. https://pbs.twimg.com/media/FeUJKdnXEAEFe2j.jpg", Timestamp: 1664982561, UserID: "17874544", Username: "Support", @@ -147,7 +147,7 @@ func TestGetTweetWithGIF(t *testing.T) { ID: "1517535384833605632", Name: "Support", PermanentURL: "https://twitter.com/Support/status/1517535384833605632", - Text: "Video captions or no captions, it’s now easier to choose for some of you on iOS, and soon on Android.\n\nOn videos that have captions available, we’re testing the option to turn captions off/on with a new “CC” button. https://t.co/Q2Q2Wmr78U", + Text: "Video captions or no captions, it’s now easier to choose for some of you on iOS, and soon on Android.\n\nOn videos that have captions available, we’re testing the option to turn captions off/on with a new “CC” button. https://pbs.twimg.com/tweet_video_thumb/FQ9eXEhXEAA-haj.jpg", Timestamp: 1650643604, UserID: "17874544", Username: "Support", @@ -170,7 +170,7 @@ func TestGetTweetWithPhotoAndGIF(t *testing.T) { Name: "Spaces", PermanentURL: "https://twitter.com/XSpaces/status/1583186305722507265", Photos: []twitterscraper.Photo{{ID: "1583186295626539020", URL: "https://pbs.twimg.com/media/FfibjDwWIAwvbtJ.jpg"}}, - Text: "“we need to talk” \n\nirl vs on Spaces https://t.co/hrflPpbpif", + Text: "“we need to talk” \n\nirl vs on Spaces https://pbs.twimg.com/tweet_video_thumb/FfibjDnWIBIt5fn.jpg", Timestamp: 1666296004, UserID: "1065249714214457345", Username: "XSpaces", @@ -197,7 +197,7 @@ func TestTweetMentions(t *testing.T) { func TestQuotedAndReply(t *testing.T) { sample := &twitterscraper.Tweet{ ConversationID: "1237110546383724547", - HTML: "The Easiest Problem Everyone Gets Wrong

[new video] --> https://t.co/YdaeDYmPAU
", + HTML: "The Easiest Problem Everyone Gets Wrong

[new video] --> https://youtu.be/ytfCdqWhmdg
", ID: "1237110546383724547", Likes: 485, Name: "Vsauce2", @@ -208,7 +208,7 @@ func TestQuotedAndReply(t *testing.T) { }}, Replies: 12, Retweets: 18, - Text: "The Easiest Problem Everyone Gets Wrong \n\n[new video] --> https://t.co/YdaeDYmPAU https://t.co/iKu4Xs6o2V", + Text: "The Easiest Problem Everyone Gets Wrong \n\n[new video] --> https://youtu.be/ytfCdqWhmdg https://pbs.twimg.com/media/ESsZa9AXgAIAYnF.jpg", Timestamp: 1583785113, URLs: []string{"https://youtu.be/ytfCdqWhmdg"}, UserID: "978944851", @@ -241,13 +241,13 @@ func TestQuotedAndReply(t *testing.T) { func TestRetweet(t *testing.T) { sample := &twitterscraper.Tweet{ ConversationID: "1758837061786779942", - HTML: "no ads, just bangers

aka your For You feed with Premium+

subscribe here → https://t.co/APTO1t7kMk", + HTML: "no ads, just bangers

aka your For You feed with Premium+

subscribe here → https://x.com/i/premium_sign_up", ID: "1758837061786779942", URLs: []string{"https://x.com/i/premium_sign_up"}, IsSelfThread: false, Name: "Premium", PermanentURL: "https://twitter.com/premium/status/1758837061786779942", - Text: "no ads, just bangers\n\naka your For You feed with Premium+\n\nsubscribe here → https://t.co/APTO1t7kMk", + Text: "no ads, just bangers\n\naka your For You feed with Premium+\n\nsubscribe here → https://x.com/i/premium_sign_up", Timestamp: 1708174407, UserID: "1399766153053061121", Username: "premium", diff --git a/util.go b/util.go index e7e5311..525065c 100644 --- a/util.go +++ b/util.go @@ -308,7 +308,7 @@ func parseLegacyTweet(user *legacyUser, tweet *legacyTweet) *Tweet { tw.HTML = reTwitterURL.ReplaceAllStringFunc(tw.HTML, func(tco string) string { for _, entity := range tweet.Entities.URLs { if tco == entity.URL { - return fmt.Sprintf(`%s`, entity.ExpandedURL, tco) + return fmt.Sprintf(`%s`, entity.ExpandedURL, entity.ExpandedURL) } } for _, entity := range tweet.ExtendedEntities.Media {