Refactor and novel18 support (added cookie support in general to AbstractScraper.cs
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
32
Common/Models/DBDomain/Author.cs
Normal file
32
Common/Models/DBDomain/Author.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Common.Models.DBDomain
|
||||
{
|
||||
public class Author : BaseEntity
|
||||
{
|
||||
[Key]
|
||||
public string Url { get; set; }
|
||||
public string Name { get; set; }
|
||||
[JsonIgnore]
|
||||
public List<Novel> Novels { get; set; }
|
||||
|
||||
protected bool Equals(Author other)
|
||||
{
|
||||
return Url == other.Url;
|
||||
}
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (ReferenceEquals(null, obj)) return false;
|
||||
if (ReferenceEquals(this, obj)) return true;
|
||||
if (obj.GetType() != this.GetType()) return false;
|
||||
return Equals((Author) obj);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Url.GetHashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
8
Common/Models/DBDomain/BaseEntity.cs
Normal file
8
Common/Models/DBDomain/BaseEntity.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
namespace Common.Models.DBDomain
|
||||
{
|
||||
public abstract class BaseEntity
|
||||
{
|
||||
public DateTime DateCreated { get; set; }
|
||||
public DateTime DateModified { get; set; }
|
||||
}
|
||||
}
|
||||
37
Common/Models/DBDomain/Chapter.cs
Normal file
37
Common/Models/DBDomain/Chapter.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Common.Models.DBDomain
|
||||
{
|
||||
public class Chapter : BaseEntity
|
||||
{
|
||||
public int ChapterNumber { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string? Content { get; set; }
|
||||
public string? RawContent { get; set; }
|
||||
[Key]
|
||||
public string Url { get; set; }
|
||||
public DateTime? DatePosted { get; set; }
|
||||
public DateTime? DateUpdated { get; set; }
|
||||
public DateTime? LastContentFetch { get; set; }
|
||||
[Required]
|
||||
public Novel Novel { get; set; }
|
||||
|
||||
protected bool Equals(Chapter other)
|
||||
{
|
||||
return Url == other.Url;
|
||||
}
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (ReferenceEquals(null, obj)) return false;
|
||||
if (ReferenceEquals(this, obj)) return true;
|
||||
if (obj.GetType() != this.GetType()) return false;
|
||||
return Equals((Chapter) obj);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Url.GetHashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
39
Common/Models/DBDomain/Novel.cs
Normal file
39
Common/Models/DBDomain/Novel.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Common.Models.Enums;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Common.Models.DBDomain
|
||||
{
|
||||
[Index(nameof(Guid))]
|
||||
public class Novel : BaseEntity
|
||||
{
|
||||
[Key]
|
||||
public string Url { get; set; }
|
||||
public Guid Guid { get; set; }
|
||||
public string Title { get; set; }
|
||||
public Author? Author { get; set; }
|
||||
public List<Tag> Tags { get; set; }
|
||||
public List<Chapter> Chapters { get; set; }
|
||||
public NovelStatus Status { get; set; }
|
||||
public DateTime LastUpdated { get; set; }
|
||||
public DateTime DatePosted { get; set; }
|
||||
|
||||
protected bool Equals(Novel other)
|
||||
{
|
||||
return Url == other.Url;
|
||||
}
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (ReferenceEquals(null, obj)) return false;
|
||||
if (ReferenceEquals(this, obj)) return true;
|
||||
if (obj.GetType() != this.GetType()) return false;
|
||||
return Equals((Novel) obj);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Url.GetHashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
46
Common/Models/DBDomain/Tag.cs
Normal file
46
Common/Models/DBDomain/Tag.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Common.Models.DBDomain
|
||||
{
|
||||
public class Tag : BaseEntity
|
||||
{
|
||||
[Key]
|
||||
public string TagValue { get; set; }
|
||||
[JsonIgnore]
|
||||
public List<Novel> Novels { get; set; }
|
||||
|
||||
protected bool Equals(Tag other)
|
||||
{
|
||||
return TagValue == other.TagValue;
|
||||
}
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (ReferenceEquals(null, obj)) return false;
|
||||
if (ReferenceEquals(this, obj)) return true;
|
||||
if (obj.GetType() != this.GetType()) return false;
|
||||
return Equals((Tag) obj);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return TagValue.GetHashCode();
|
||||
}
|
||||
|
||||
public static Tag GetSiteTag(string siteUrl)
|
||||
{
|
||||
return new Tag {TagValue = $"site:{siteUrl.TrimEnd('/')}"};
|
||||
}
|
||||
|
||||
public static Tag GetOriginalWorkTag()
|
||||
{
|
||||
return new Tag {TagValue = "original_work"};
|
||||
}
|
||||
|
||||
public static Tag GetNsfwTag()
|
||||
{
|
||||
return new Tag {TagValue = "NSFW"};
|
||||
}
|
||||
}
|
||||
}
|
||||
32
Common/Models/DBDomain/User.cs
Normal file
32
Common/Models/DBDomain/User.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Common.Models.DBDomain
|
||||
{
|
||||
[Index(nameof(Email))]
|
||||
public class User : BaseEntity
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
public string Email { get; set; }
|
||||
public List<UserNovel> WatchedNovels { get; set; }
|
||||
|
||||
protected bool Equals(User other)
|
||||
{
|
||||
return Id == other.Id;
|
||||
}
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (ReferenceEquals(null, obj)) return false;
|
||||
if (ReferenceEquals(this, obj)) return true;
|
||||
if (obj.GetType() != this.GetType()) return false;
|
||||
return Equals((User) obj);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Id;
|
||||
}
|
||||
}
|
||||
}
|
||||
32
Common/Models/DBDomain/UserNovel.cs
Normal file
32
Common/Models/DBDomain/UserNovel.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Common.Models.DBDomain
|
||||
{
|
||||
public class UserNovel
|
||||
{
|
||||
public int UserId { get; set; }
|
||||
public string NovelUrl { get; set; }
|
||||
public Novel Novel { get; set; }
|
||||
[JsonIgnore]
|
||||
public User User { get; set; }
|
||||
public int LastChapterRead { get; set; }
|
||||
|
||||
protected bool Equals(UserNovel other)
|
||||
{
|
||||
return UserId == other.UserId && NovelUrl == other.NovelUrl;
|
||||
}
|
||||
|
||||
public override bool Equals(object? obj)
|
||||
{
|
||||
if (ReferenceEquals(null, obj)) return false;
|
||||
if (ReferenceEquals(this, obj)) return true;
|
||||
if (obj.GetType() != this.GetType()) return false;
|
||||
return Equals((UserNovel) obj);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return HashCode.Combine(UserId, NovelUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
6
Common/Models/DTO/Requests/ScrapeNovelRequest.cs
Normal file
6
Common/Models/DTO/Requests/ScrapeNovelRequest.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Common.Models.DTO.Requests;
|
||||
|
||||
public class ScrapeNovelRequest
|
||||
{
|
||||
public string NovelUrl { get; set; }
|
||||
}
|
||||
9
Common/Models/DTO/Requests/ScrapeNovelsRequest.cs
Normal file
9
Common/Models/DTO/Requests/ScrapeNovelsRequest.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Common.Models.DTO.Requests;
|
||||
|
||||
public class ScrapeNovelsRequest
|
||||
{
|
||||
[JsonProperty("novelUrls")]
|
||||
public List<string> NovelUrls { get; set; }
|
||||
}
|
||||
9
Common/Models/DTO/Responses/ScrapeNovelsResponse.cs
Normal file
9
Common/Models/DTO/Responses/ScrapeNovelsResponse.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
using Common.Models.DBDomain;
|
||||
|
||||
namespace Common.Models.DTO.Responses;
|
||||
|
||||
public class ScrapeNovelsResponse
|
||||
{
|
||||
public List<Novel> SuccessfulNovels { get; set; }
|
||||
public Dictionary<string, Exception> Failures { get; set; }
|
||||
}
|
||||
9
Common/Models/Enums/NovelStatus.cs
Normal file
9
Common/Models/Enums/NovelStatus.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace Common.Models.Enums;
|
||||
|
||||
public enum NovelStatus
|
||||
{
|
||||
Unknown,
|
||||
InProgress,
|
||||
Completed,
|
||||
Hiatus
|
||||
}
|
||||
11
Common/Models/HttpResponseWrapper.cs
Normal file
11
Common/Models/HttpResponseWrapper.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace Common.Models;
|
||||
|
||||
public class HttpResponseWrapper<T> : HttpResponseWrapper
|
||||
{
|
||||
public T? ResponseObject { get; set; }
|
||||
}
|
||||
|
||||
public class HttpResponseWrapper
|
||||
{
|
||||
public HttpResponseMessage HttpResponseMessage { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user