using System.Web;
using System.Xml.Linq;
using System.Xml.XPath;
+using OpenTween.Connection;
+using OpenTween.Models;
namespace OpenTween.Thumbnail.Services
{
class Tinami : IThumbnailService
{
public static readonly Regex UrlPatternRegex =
- new Regex(@"^http://www\.tinami\.com/view/(?<ContentId>\d+)$");
+ new Regex(@"^https?://www\.tinami\.com/view/(?<ContentId>\d+)$");
- protected readonly HttpClient http;
+ protected HttpClient http
+ {
+ get { return this.localHttpClient ?? Networking.Http; }
+ }
+ private readonly HttpClient localHttpClient;
+
+ public Tinami()
+ : this(null)
+ {
+ }
public Tinami(HttpClient http)
{
- this.http = http;
+ this.localHttpClient = http;
}
public override async Task<ThumbnailInfo> GetThumbnailInfoAsync(string url, PostClass post, CancellationToken token)
return new ThumbnailInfo
{
- ImageUrl = url,
- ThumbnailUrl = thumbUrlElm.Attribute("url").Value,
- TooltipText = descElm == null ? null : descElm.Value,
+ MediaPageUrl = url,
+ ThumbnailImageUrl = thumbUrlElm.Attribute("url").Value,
+ TooltipText = descElm?.Value,
};
}
catch (HttpRequestException) { }
{
var query = new Dictionary<string, string>
{
- {"api_key", ApplicationSettings.TINAMIApiKey},
- {"cont_id", contentId},
+ ["api_key"] = ApplicationSettings.TINAMIApiKey,
+ ["cont_id"] = contentId,
};
var apiUrl = new Uri("http://api.tinami.com/content/info?" + MyCommon.BuildQueryString(query));