From ed8b7d3da6229b441622990b2249aed3cb715861 Mon Sep 17 00:00:00 2001 From: Kimura Youichi Date: Fri, 27 Nov 2015 18:57:11 +0900 Subject: [PATCH] =?utf8?q?PostClass.Media=E3=81=AB=20pic.twitter.com=20?= =?utf8?q?=E3=81=AA=E3=81=A9=E3=81=AEURL=E3=81=AE=E3=81=BF=E3=82=92?= =?utf8?q?=E5=90=AB=E3=82=81=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB=E3=81=99?= =?utf8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit ThumbnailGenerator などでは、PostClass.Media に加えて PostClass.GetExpandedUrls の返値を見てサムネイル表示の対象となる URL を探す --- OpenTween/Thumbnail/Services/TwitterComVideo.cs | 2 +- OpenTween/Thumbnail/ThumbnailGenerator.cs | 7 +++++-- OpenTween/TweetThumbnail.cs | 2 +- OpenTween/Twitter.cs | 19 +------------------ 4 files changed, 8 insertions(+), 22 deletions(-) diff --git a/OpenTween/Thumbnail/Services/TwitterComVideo.cs b/OpenTween/Thumbnail/Services/TwitterComVideo.cs index 2d82bf4e..c0b9524d 100644 --- a/OpenTween/Thumbnail/Services/TwitterComVideo.cs +++ b/OpenTween/Thumbnail/Services/TwitterComVideo.cs @@ -51,7 +51,7 @@ namespace OpenTween.Thumbnail.Services { // 前処理で動画用URLが準備されていればそれを使う var mediaInfo = post.Media.FirstOrDefault(x => x.Url == url); - if (mediaInfo.VideoUrl != null) + if (mediaInfo?.VideoUrl != null) { return new ThumbnailInfo { diff --git a/OpenTween/Thumbnail/ThumbnailGenerator.cs b/OpenTween/Thumbnail/ThumbnailGenerator.cs index b3942707..8caea6e2 100644 --- a/OpenTween/Thumbnail/ThumbnailGenerator.cs +++ b/OpenTween/Thumbnail/ThumbnailGenerator.cs @@ -219,9 +219,12 @@ namespace OpenTween.Thumbnail { var thumbnails = new List(); - foreach (var media in post.Media) + var expandedUrls = Enumerable.Concat( + post.GetExpandedUrls(), post.Media.Select(x => x.Url)); + + foreach (var expandedUrl in expandedUrls) { - var thumbInfo = await ThumbnailGenerator.GetThumbnailInfoAsync(media.Url, post, token) + var thumbInfo = await ThumbnailGenerator.GetThumbnailInfoAsync(expandedUrl, post, token) .ConfigureAwait(false); if (thumbInfo != null) diff --git a/OpenTween/TweetThumbnail.cs b/OpenTween/TweetThumbnail.cs index 2651c710..c7b4e862 100644 --- a/OpenTween/TweetThumbnail.cs +++ b/OpenTween/TweetThumbnail.cs @@ -67,7 +67,7 @@ namespace OpenTween this.scrollBar.Enabled = false; - if (post.Media.Count == 0 && post.PostGeo == null) + if (post.ExpandedUrls.Count == 0 && post.Media.Count == 0 && post.PostGeo == null) { this.SetThumbnailCount(0); return; diff --git a/OpenTween/Twitter.cs b/OpenTween/Twitter.cs index 8161a0a1..0913e878 100644 --- a/OpenTween/Twitter.cs +++ b/OpenTween/Twitter.cs @@ -2689,21 +2689,10 @@ namespace OpenTween this.CheckStatusCode(res, content); } - public async Task CreateHtmlAnchorAsync(string text, List AtList, TwitterEntities entities, List media) + public string CreateHtmlAnchor(string text, List AtList, TwitterEntities entities, List media) { if (entities != null) { - if (entities.Urls != null) - { - foreach (var ent in entities.Urls) - { - var expandedUrl = await ShortUrl.Instance.ExpandUrlAsync(ent.ExpandedUrl) - .ConfigureAwait(false); - - if (media != null && !media.Any(info => info.Url == expandedUrl)) - media.Add(new MediaInfo(expandedUrl)); - } - } if (entities.Hashtags != null) { lock (this.LockObj) @@ -2754,12 +2743,6 @@ namespace OpenTween return text; } - [Obsolete] - public string CreateHtmlAnchor(string text, List AtList, TwitterEntities entities, List media) - { - return this.CreateHtmlAnchorAsync(text, AtList, entities, media).Result; - } - /// /// Twitter APIから得たHTML形式のsource文字列を分析し、source名とURLに分離します /// -- 2.11.0