public async Task <FourChanThreadData[]> GetMainPageData(string board) { string catalogUrl = String.Format(baseUrl, board) + catalogPostfix; byte[] bs = await httpClient.GetByteArrayAsync(catalogUrl); string contents = GetStringFromBytes(bs); Match m = Regex.Match(contents, threadsParseRegex); string json = m.Groups["contents"].Value; var deserialized = JsonConvert.DeserializeObject <Dictionary <long, ThreadJsonBackEnd> >(json); List <FourChanThreadData> list = new List <FourChanThreadData>(deserialized.Count); foreach (var kvp in deserialized) { ThreadJsonBackEnd be = kvp.Value; FourChanThreadData fcti = new FourChanThreadData() { Id = kvp.Key, Board = board, Images = be.i, Replies = be.r, Sub = WebUtility.HtmlDecode(be.sub), Teaser = WebUtility.HtmlDecode(be.teaser) }; list.Add(fcti); } FourChanThreadData[] ret = list.ToArray(); return(ret); }
private async Task <byte[]> GetThumbnail(CancellationToken cancellationToken, VideoData video) { try { return(await _httpClientWrapper.GetByteArrayAsync(video.ThumbnailUrl, cancellationToken)); } catch { // TODO: Log? return(new byte[0]); } }
private async Task <byte[]> GetThumbnail(CancellationToken cancellationToken, VideoData video) { try { return(await _httpClientWrapper.GetByteArrayAsync(video.ThumbnailUrl, cancellationToken)); } catch (Exception ex) { _logger.Debug($"Video {video.DisplayInfo()} has no thumbnail, or we errored - Error: {ex}"); return(new byte[0]); } }