Skip to content

Commit

Permalink
Add api
Browse files Browse the repository at this point in the history
  • Loading branch information
jerry08 committed Oct 4, 2024
1 parent 10759b7 commit 5279efa
Show file tree
Hide file tree
Showing 35 changed files with 1,078 additions and 1 deletion.
10 changes: 10 additions & 0 deletions Juro.Core/Models/Provider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Juro.Core.Models;

public class Provider
{
public string Key { get; set; } = default!;

public string Name { get; set; } = default!;

public ProviderType Type { get; set; }
}
8 changes: 8 additions & 0 deletions Juro.Core/Models/ProviderType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace Juro.Core.Models;

public enum ProviderType
{
Anime,
Manga,
Movie,
}
23 changes: 23 additions & 0 deletions Juro.DataBuilder/Juro.DataBuilder.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Httpz" Version="1.1.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.8" PrivateAssets="all" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.8" PrivateAssets="all" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.8" />
<PackageReference Include="Spectre.Console" Version="0.49.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Juro.Providers.Adult\Juro.Providers.Adult.csproj" />
<ProjectReference Include="..\Juro.Providers\Juro.Providers.csproj" />
<ProjectReference Include="..\Juro\Juro.csproj" />
</ItemGroup>

</Project>
40 changes: 40 additions & 0 deletions Juro.DataBuilder/JuroContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
using Juro.DataBuilder.Models;
using Microsoft.EntityFrameworkCore;

namespace Juro.DataBuilder;

public class JuroContext : DbContext
{
public DbSet<ManamiAnimeItem> AnimeItems { get; set; }

public DbSet<AnimeSeason> AnimeSeasons { get; set; }

public DbSet<AnimeModel> Gogoanime { get; set; }

public DbSet<AnimeModel> AnimePahe { get; set; }

public DbSet<AnimeModel> Kaido { get; set; }

public DbSet<AnimeModel> Aniwave { get; set; }

public DbSet<AnimeModel> OtakuDesu { get; set; }

public string DbPath { get; }

public JuroContext()
{
var folder = Environment.SpecialFolder.LocalApplicationData;
var path = Environment.GetFolderPath(folder);
DbPath = Path.Join(path, "juro.db");
}

public JuroContext(string dbPath)
{
DbPath = dbPath;
}

// The following configures EF to create a Sqlite database file in the
// special "local" folder for your platform.
protected override void OnConfiguring(DbContextOptionsBuilder options) =>
options.UseSqlite($"Data Source={DbPath}");
}
36 changes: 36 additions & 0 deletions Juro.DataBuilder/Models/AnimeModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.ComponentModel.DataAnnotations;
using Juro.Core.Models.Anime;

namespace Juro.DataBuilder.Models;

public class AnimeModel
{
[Key]
public int AnimeId { get; set; }

public string Id { get; set; } = default!;

public AnimeSites Site { get; set; }

public string Title { get; set; } = default!;

public string? Released { get; set; }

public string? Category { get; set; }

public string? Link { get; set; }

public string? Image { get; set; }

public string? Type { get; set; }

public string? Status { get; set; }

public string? OtherNames { get; set; }

public string? Summary { get; set; }

public List<GenreModel> Genres { get; set; } = [];

public override string ToString() => $"{Title}";
}
28 changes: 28 additions & 0 deletions Juro.DataBuilder/Models/GenreModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System.ComponentModel.DataAnnotations;

namespace Juro.DataBuilder.Models;

public class GenreModel
{
[Key]
public int GenreId { get; set; }

public string Name { get; set; } = default!;

public string? Url { get; set; }

public GenreModel() { }

public GenreModel(string name)
{
Name = name;
}

public GenreModel(string name, string url)
{
Name = name;
Url = url;
}

public override string ToString() => $"{Name}";
}
87 changes: 87 additions & 0 deletions Juro.DataBuilder/Models/ManamiAnimeItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
using System.ComponentModel.DataAnnotations;
using System.Text.Json.Serialization;

namespace Juro.DataBuilder.Models;

public class License
{
[JsonPropertyName("name")]
public string Name { get; set; } = default!;

[JsonPropertyName("url")]
public string Url { get; set; } = default!;
}

public class Root
{
[JsonPropertyName("license")]
public License License { get; set; } = default!;

[JsonPropertyName("repository")]
public string Repository { get; set; } = default!;

[JsonPropertyName("lastUpdate")]
public string LastUpdate { get; set; } = default!;

[JsonPropertyName("data")]
public List<ManamiAnimeItem> Data { get; set; } = [];
}

public class ManamiAnimeItem
{
[Key]
[JsonIgnore]
public int Id { get; set; }

[JsonPropertyName("sources")]
public List<string> Sources { get; set; } = [];

[JsonPropertyName("title")]
public string Title { get; set; } = default!;

[JsonPropertyName("type")]
public string Type { get; set; } = default!;

[JsonPropertyName("episodes")]
public int Episodes { get; set; }

[JsonPropertyName("status")]
public int Status { get; set; }

[JsonPropertyName("animeSeason")]
public AnimeSeason AnimeSeason { get; set; } = default!;

[JsonPropertyName("picture")]
public string Picture { get; set; } = default!;

[JsonPropertyName("thumbnail")]
public string Thumbnail { get; set; } = default!;

[JsonPropertyName("synonyms")]
public List<string> Synonyms { get; set; } = [];

[JsonPropertyName("relatedAnime")]
public List<string> RelatedAnime { get; set; } = [];

[JsonPropertyName("tags")]
public List<string> Tags { get; set; } = [];

public string? GogoanimeId { get; set; }
public string? AnimePaheId { get; set; }
public string? KaidoId { get; set; }
public string? AniwaveId { get; set; }
public string? OtakuDesuId { get; set; }
}

public class AnimeSeason
{
[Key]
[JsonIgnore]
public int Id { get; set; }

[JsonPropertyName("season")]
public string Season { get; set; } = default!;

[JsonPropertyName("year")]
public int Year { get; set; }
}
Loading

0 comments on commit 5279efa

Please sign in to comment.