Exemplo n.º 1
0
        private async Task LoadUgoiraMeta(Post post)
        {
            try
            {
                var postJsonString = await _booruLoader
                                     .LoadPageAsync(string.Format(POST_JSON_UGOIRA_META, post.PostId))
                                     .ConfigureAwait(false);

                var postJson = JsonConvert.DeserializeObject <PostUgoiraInfo>(postJsonString);
                post.UgoiraFrameData = postJson.FrameData;
            }
            catch (Exception e)
            {
                Logger.LogError(e, "An error occurred while loading ugoira info");
            }
        }
    private static MetaParsingResults ToMetadataParsingResults(Post post)
    {
        var(parentId, parentMd5) = GetParentInfo(post.ParentId);

        return(new MetaParsingResults(
                   post.Source,
                   post.PostId.ToString(),
                   post.ActualDateTime.ToString(Constants.DateTimeFormat),
                   post.Md5,
                   post.PostedDateTime.ToLongTimeString(),
                   post.PostedUser?.Id?.ToString(),
                   post.PostedUser?.Name,
                   post.ImageRating.ToString(),
                   post.RatingSafeLevel.ToString(),
                   parentId,
                   parentMd5,
                   post.ChildrenIds,
                   post.Pools.Select(x => x.Id + "||" + x.Name).ToArray(),
                   post.Tags.Select(ConvertTag).ToArray(),
                   post.Notes.Select(ConvertNote).ToArray(),
                   post.UgoiraFrameData));
    }
    public SearchResult Convert(
        Post post,
        Image image,
        SearchEngineType searchEngineType)
    {
        var metadataParsingDto = ToMetadataParsingResults(post);

        var metaTags = metadataParsingDto
                       .GetMetaTags()
                       .Select(x => new Tag(x.TagType, x.Tag, x.Value));
        var postTags = metadataParsingDto
                       .Tags
                       .Select(x => new Tag(x.TagType, x.Tag, x.Value, x.Synonyms));

        return(new Metadata(
                   image,
                   searchEngineType,
                   true,
                   metaTags.Union(postTags).ToArray(),
                   metadataParsingDto.Notes,
                   post.PostId));
    }