diff --git a/src/BirdsiteLive.Twitter/TwitterTweetsService.cs b/src/BirdsiteLive.Twitter/TwitterTweetsService.cs index b7df5ed..8278ef5 100644 --- a/src/BirdsiteLive.Twitter/TwitterTweetsService.cs +++ b/src/BirdsiteLive.Twitter/TwitterTweetsService.cs @@ -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") diff --git a/src/Tests/BirdsiteLive.Twitter.Tests/TweetTests.cs b/src/Tests/BirdsiteLive.Twitter.Tests/TweetTests.cs index 8fad641..2ddd069 100644 --- a/src/Tests/BirdsiteLive.Twitter.Tests/TweetTests.cs +++ b/src/Tests/BirdsiteLive.Twitter.Tests/TweetTests.cs @@ -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 couldn’t 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/")); + } } -} \ No newline at end of file +}