public Task <string> GetUpdateUrlAsync(CupContentType type, [NotNull] string id) { var information = GetInformation(type, id); if (information == null || information._updateUrl != null) { return(Task.FromResult(information?._updateUrl)); } return(_installationUrlTaskCache.Get(async() => { try { var url = $"{information.SourceRegistry}/{type.ToString().ToLowerInvariant()}/{id}/get"; using (var client = new CookieAwareWebClient()) { var updateUrl = await client.GetFinalRedirectAsync(url); if (updateUrl != null) { information._updateUrl = updateUrl; } return updateUrl; } } catch (Exception e) { NonfatalError.NotifyBackground("Can’t download an update", e); return null; } }, type, id)); }
protected override async Task <string> GetRedirectOverrideAsync(string url, CookieAwareWebClient client, CancellationToken cancellation) { if (IsYouTubeWrapped(url)) { return(new Uri(url, UriKind.RelativeOrAbsolute).GetQueryParam("q")); } if (IsFacebookWrapped(url)) { return(new Uri(url, UriKind.RelativeOrAbsolute).GetQueryParam("u")); } return(await client.GetFinalRedirectAsync(url)); }