Beispiel #1
0
            public PixivWork ToModel(KouContext context)
            {
                var             R18Flag = false;
                List <PixivTag> tags    = new();

                if (!Tags.IsNullOrEmptySet())
                {
                    foreach (var tagName in Tags)
                    {
                        if (R18 || tagName.IsMatch("r.*(18|17).*", RegexOptions.IgnoreCase))
                        {
                            R18Flag = true;
                        }
                        var newTag = new PixivTag {
                            Name = tagName
                        };
                        var oldTag = newTag.FindThis(context);
                        tags.Add(oldTag ?? newTag);
                    }
                }

                var author = new PixivAuthor()
                {
                    Name = Author, Uid = Uid
                };
                var oldAuthor = author.FindThis(context);

                if (oldAuthor != null)
                {
                    author = oldAuthor;
                }

                if (tags.Count == 0)
                {
                    tags = null;
                }
                return(new PixivWork()
                {
                    Author = author,
                    Pid = Pid,
                    P = P,
                    Title = Title,
                    R18 = R18Flag,
                    Width = Width,
                    Height = Height,
                    Ext = Ext,
                    UploadDateTimestamp = UploadDate,
                    Tags = tags
                });
            }