Exemplo n.º 1
0
        public DanbooruPost(int postId, HtmlNode documentNode, Json.Post postJson, string md5 = null)
            : base(postId, md5)
        {
            if (postJson == null)
            {
                throw new ArgumentNullException(nameof(postJson));
            }
            if (documentNode == null)
            {
                throw new ArgumentNullException(nameof(documentNode));
            }

            ParsePost(postJson, documentNode);
        }
Exemplo n.º 2
0
        private void ParsePost(Json.Post postJson, HtmlNode documentNode)
        {
            ParseTags(postJson);
            ParseStats(postJson);
            ParseIsDeleted(postJson);

            if (PostExistState == ExistState.Exist)
            {
                ParsePools(documentNode);
                ParseNotes(documentNode);
            }

            ParseRelations(documentNode);
        }
Exemplo n.º 3
0
 private void ParseTags(Json.Post postJson)
 {
     foreach (var tag in postJson.tag_string_artist.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries))
     {
         Tags.Add(Tag.CreateOrGetTag(TagType.Artist, tag.Replace('_', ' '), null));
     }
     foreach (var tag in postJson.tag_string_character.Split(new [] { " " }, StringSplitOptions.RemoveEmptyEntries))
     {
         Tags.Add(Tag.CreateOrGetTag(TagType.Character, tag.Replace('_', ' '), null));
     }
     foreach (var tag in postJson.tag_string_copyright.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries))
     {
         Tags.Add(Tag.CreateOrGetTag(TagType.Copyright, tag.Replace('_', ' '), null));
     }
     foreach (var tag in postJson.tag_string_general.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries))
     {
         Tags.Add(Tag.CreateOrGetTag(TagType.General, tag.Replace('_', ' '), null));
     }
     foreach (var tag in postJson.tag_string_meta.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries))
     {
         Tags.Add(Tag.CreateOrGetTag(TagType.Meta, tag.Replace('_', ' '), null));
     }
 }
Exemplo n.º 4
0
        private void ParseStats(Json.Post postJson)
        {
            PostedDateTime = DateTime.Parse(postJson.created_at);
            PostedUser     = new User
            {
                Id   = postJson.uploader_id,
                Name = postJson.uploader_name
            };


            Md5       = postJson.md5;
            ByteSize  = postJson.file_size;
            ImageSize = new Size
            {
                Height = postJson.image_height,
                Width  = postJson.image_width
            };

            Source = postJson.source;

            (ImageRating, RatingSafeLevel) = GetRatingFromChar(postJson.rating);

            OriginalUrl = postJson.file_url;
        }
Exemplo n.º 5
0
 private void ParseIsDeleted(Json.Post postJson)
 {
     PostExistState = (postJson.is_banned || postJson.is_deleted) ? ExistState.MarkDeleled : ExistState.Exist;
 }