update tests
This commit is contained in:
parent
c269a9ba92
commit
3684e678e3
3 changed files with 9 additions and 11 deletions
|
|
@ -56,8 +56,6 @@ func (result *result) parse() *Tweet {
|
||||||
if result.QuotedStatusResult.Result != nil {
|
if result.QuotedStatusResult.Result != nil {
|
||||||
tw.QuotedStatus = result.QuotedStatusResult.Result.parse()
|
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
|
return tw
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ func TestGetTweetWithVideo(t *testing.T) {
|
||||||
Name: "X",
|
Name: "X",
|
||||||
PermanentURL: "https://twitter.com/X/status/1697304622749086011",
|
PermanentURL: "https://twitter.com/X/status/1697304622749086011",
|
||||||
Photos: nil,
|
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,
|
Timestamp: 1693503931,
|
||||||
UserID: "783214",
|
UserID: "783214",
|
||||||
Username: "X",
|
Username: "X",
|
||||||
|
|
@ -125,7 +125,7 @@ func TestGetTweetWithMultiplePhotos(t *testing.T) {
|
||||||
URL: "https://pbs.twimg.com/media/FeUJKuxXEAAa6t7.jpg",
|
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,
|
Timestamp: 1664982561,
|
||||||
UserID: "17874544",
|
UserID: "17874544",
|
||||||
Username: "Support",
|
Username: "Support",
|
||||||
|
|
@ -147,7 +147,7 @@ func TestGetTweetWithGIF(t *testing.T) {
|
||||||
ID: "1517535384833605632",
|
ID: "1517535384833605632",
|
||||||
Name: "Support",
|
Name: "Support",
|
||||||
PermanentURL: "https://twitter.com/Support/status/1517535384833605632",
|
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,
|
Timestamp: 1650643604,
|
||||||
UserID: "17874544",
|
UserID: "17874544",
|
||||||
Username: "Support",
|
Username: "Support",
|
||||||
|
|
@ -170,7 +170,7 @@ func TestGetTweetWithPhotoAndGIF(t *testing.T) {
|
||||||
Name: "Spaces",
|
Name: "Spaces",
|
||||||
PermanentURL: "https://twitter.com/XSpaces/status/1583186305722507265",
|
PermanentURL: "https://twitter.com/XSpaces/status/1583186305722507265",
|
||||||
Photos: []twitterscraper.Photo{{ID: "1583186295626539020", URL: "https://pbs.twimg.com/media/FfibjDwWIAwvbtJ.jpg"}},
|
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,
|
Timestamp: 1666296004,
|
||||||
UserID: "1065249714214457345",
|
UserID: "1065249714214457345",
|
||||||
Username: "XSpaces",
|
Username: "XSpaces",
|
||||||
|
|
@ -197,7 +197,7 @@ func TestTweetMentions(t *testing.T) {
|
||||||
func TestQuotedAndReply(t *testing.T) {
|
func TestQuotedAndReply(t *testing.T) {
|
||||||
sample := &twitterscraper.Tweet{
|
sample := &twitterscraper.Tweet{
|
||||||
ConversationID: "1237110546383724547",
|
ConversationID: "1237110546383724547",
|
||||||
HTML: "The Easiest Problem Everyone Gets Wrong <br><br>[new video] --> <a href=\"https://youtu.be/ytfCdqWhmdg\">https://t.co/YdaeDYmPAU</a> <br><a href=\"https://t.co/iKu4Xs6o2V\"><img src=\"https://pbs.twimg.com/media/ESsZa9AXgAIAYnF.jpg\"/></a>",
|
HTML: "The Easiest Problem Everyone Gets Wrong <br><br>[new video] --> <a href=\"https://youtu.be/ytfCdqWhmdg\">https://youtu.be/ytfCdqWhmdg</a> <br><a href=\"https://t.co/iKu4Xs6o2V\"><img src=\"https://pbs.twimg.com/media/ESsZa9AXgAIAYnF.jpg\"/></a>",
|
||||||
ID: "1237110546383724547",
|
ID: "1237110546383724547",
|
||||||
Likes: 485,
|
Likes: 485,
|
||||||
Name: "Vsauce2",
|
Name: "Vsauce2",
|
||||||
|
|
@ -208,7 +208,7 @@ func TestQuotedAndReply(t *testing.T) {
|
||||||
}},
|
}},
|
||||||
Replies: 12,
|
Replies: 12,
|
||||||
Retweets: 18,
|
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,
|
Timestamp: 1583785113,
|
||||||
URLs: []string{"https://youtu.be/ytfCdqWhmdg"},
|
URLs: []string{"https://youtu.be/ytfCdqWhmdg"},
|
||||||
UserID: "978944851",
|
UserID: "978944851",
|
||||||
|
|
@ -241,13 +241,13 @@ func TestQuotedAndReply(t *testing.T) {
|
||||||
func TestRetweet(t *testing.T) {
|
func TestRetweet(t *testing.T) {
|
||||||
sample := &twitterscraper.Tweet{
|
sample := &twitterscraper.Tweet{
|
||||||
ConversationID: "1758837061786779942",
|
ConversationID: "1758837061786779942",
|
||||||
HTML: "no ads, just bangers<br><br>aka your For You feed with Premium+<br><br>subscribe here → <a href=\"https://x.com/i/premium_sign_up\">https://t.co/APTO1t7kMk</a>",
|
HTML: "no ads, just bangers<br><br>aka your For You feed with Premium+<br><br>subscribe here → <a href=\"https://x.com/i/premium_sign_up\">https://x.com/i/premium_sign_up</a>",
|
||||||
ID: "1758837061786779942",
|
ID: "1758837061786779942",
|
||||||
URLs: []string{"https://x.com/i/premium_sign_up"},
|
URLs: []string{"https://x.com/i/premium_sign_up"},
|
||||||
IsSelfThread: false,
|
IsSelfThread: false,
|
||||||
Name: "Premium",
|
Name: "Premium",
|
||||||
PermanentURL: "https://twitter.com/premium/status/1758837061786779942",
|
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,
|
Timestamp: 1708174407,
|
||||||
UserID: "1399766153053061121",
|
UserID: "1399766153053061121",
|
||||||
Username: "premium",
|
Username: "premium",
|
||||||
|
|
|
||||||
2
util.go
2
util.go
|
|
@ -308,7 +308,7 @@ func parseLegacyTweet(user *legacyUser, tweet *legacyTweet) *Tweet {
|
||||||
tw.HTML = reTwitterURL.ReplaceAllStringFunc(tw.HTML, func(tco string) string {
|
tw.HTML = reTwitterURL.ReplaceAllStringFunc(tw.HTML, func(tco string) string {
|
||||||
for _, entity := range tweet.Entities.URLs {
|
for _, entity := range tweet.Entities.URLs {
|
||||||
if tco == entity.URL {
|
if tco == entity.URL {
|
||||||
return fmt.Sprintf(`<a href="%s">%s</a>`, entity.ExpandedURL, tco)
|
return fmt.Sprintf(`<a href="%s">%s</a>`, entity.ExpandedURL, entity.ExpandedURL)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, entity := range tweet.ExtendedEntities.Media {
|
for _, entity := range tweet.ExtendedEntities.Media {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue