fix for gifs

This commit is contained in:
Vincent Cloutier 2023-01-13 10:11:50 -05:00
parent 83842f5874
commit 7a840d83b2
2 changed files with 15 additions and 4 deletions

View file

@ -241,9 +241,9 @@ namespace BirdsiteLive.Twitter
{
var type = media.GetProperty("type").GetString();
string url = "";
if (type == "video")
if (type == "video" || type == "animated_gif")
{
var bitrate = 0;
var bitrate = -1;
foreach (JsonElement v in media.GetProperty("video_info").GetProperty("variants").EnumerateArray())
{
if (v.GetProperty("content_type").GetString() != "video/mp4")

View file

@ -42,7 +42,7 @@ namespace BirdsiteLive.ActivityPub.Tests
var tweet = await _tweetService.GetTweetAsync(1593344577385160704);
Assert.AreEqual(tweet.MessageContent, "Speaker Nancy Pelosi will go down as one of most accomplished legislators in American history—breaking barriers, opening doors for others, and working every day to serve the American people. I couldnt be more grateful for her friendship and leadership.");
// TODO validate media type
Assert.AreEqual(tweet.Media[0].MediaType, "image/jpeg");
Assert.AreEqual(tweet.Media.Length, 1);
// TODO test alt-text of images
}
@ -64,5 +64,16 @@ namespace BirdsiteLive.ActivityPub.Tests
Assert.AreEqual(tweet.Media[0].MediaType, "video/mp4");
Assert.IsTrue(tweet.Media[0].Url.StartsWith("https://video.twimg.com/"));
}
[TestMethod]
public async Task GifAndQT()
{
var tweet = await _tweetService.GetTweetAsync(1612901861874343936);
// TODO test QT
Assert.AreEqual(tweet.Media.Length, 1);
Assert.AreEqual(tweet.Media[0].MediaType, "image/gif");
Assert.IsTrue(tweet.Media[0].Url.StartsWith("https://video.twimg.com/"));
}
}
}
}