Skip to content

Commit

Permalink
Merge pull request #55 from AbreuHD/39-fix-scraper-update-source-url-…
Browse files Browse the repository at this point in the history
…from-cuevana3ch-to-cuevanabiz

Code cleanup and dependency updates.
  • Loading branch information
AbreuHD authored Feb 9, 2025
2 parents ca7b6a9 + 77db217 commit 6582a63
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 9 deletions.
27 changes: 26 additions & 1 deletion Core.Application/DTOs/TMDB/TMDBResult.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,43 @@
namespace Core.Application.DTOs.TMDB
using Newtonsoft.Json;
using System.Text.Json.Serialization;

namespace Core.Application.DTOs.TMDB
{
public class TmdbResult
{
public int ID { get; set; }

[JsonProperty("title")]
public required string Title { get; set; }

[JsonProperty("original_title")]
public string? OriginalTitle { get; set; }

[JsonProperty("genre_ids")]
public List<int>? GenreIds { get; set; }

[JsonProperty("adult")]
public bool? Adult { get; set; }

[JsonProperty("vote_average")]
public double? VoteAverage { get; set; }

[JsonProperty("vote_count")]
public int? VoteCount { get; set; }

[JsonProperty("overview")]
public string? Overview { get; set; }

[JsonProperty("video")]
public string? Video { get; set; }

[JsonProperty("poster_path")]
public string? PosterPath { get; set; }

[JsonProperty("backdrop_path")]
public string? BackdropPath { get; set; }

[JsonProperty("release_date")]
public string? ReleaseDate { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class Cuevana3Services(int DB_WEB_ID, string ORIGINAL_URI)
/// <summary>
/// Gets or sets the base URI to retrieve movie pages with different page numbers.
/// </summary>
public virtual string PageNumberUri { get; set; } = "/peliculas?page=";
public virtual string PageNumberUri { get; set; } = "/peliculas/page/";

/// <summary>
/// Gets or sets the URI to be replaced for the movie image source.
Expand All @@ -37,17 +37,17 @@ public class Cuevana3Services(int DB_WEB_ID, string ORIGINAL_URI)
/// <summary>
/// Gets or sets the XPath to the node containing the movie name.
/// </summary>
public virtual string GetMovieName { get; set; } = "//div[@class=\"Title\"]";
public virtual string GetMovieName { get; set; } = "./div/div/div[@class=\"Title\"]";

/// <summary>
/// Gets or sets the XPath to the node containing the movie image.
/// </summary>
public virtual string GetMovieImage { get; set; } = "//div[@class=\"Image\"]/img";
public virtual string GetMovieImage { get; set; } = "./div/a/div[@class=\"Image\"]/img";

/// <summary>
/// Gets or sets the XPath to the node containing the movie URL.
/// </summary>
public virtual string GetMovieUrl { get; set; } = "//div[@class=\"TPost C hentry\"]/a";
public virtual string GetMovieUrl { get; set; } = "./div/a";

/// <summary>
/// Gets or sets the XPath to the node containing the movie description.
Expand Down Expand Up @@ -97,7 +97,7 @@ private MovieWebDto GetMovieInfo(HtmlNode node)
var movieName = node.SelectSingleNode(GetMovieName).InnerText;
var movieUrl = node.SelectSingleNode(GetMovieUrl).GetAttributeValue("href", "ERROR");
var movieImage = WebUtility.UrlDecode(
node.SelectSingleNode(GetMovieImage)
node.SelectSingleNode(GetMovieImage)?
.GetAttributeValue("src", "ERROR")
.Replace(ReplaceMovieUri, "")
);
Expand Down Expand Up @@ -127,7 +127,7 @@ private string GetOverView(string uri)
{
HtmlWeb web = new();
var htmlDoc = web.Load(ORIGINAL_URI + uri);
node = htmlDoc.DocumentNode.SelectSingleNode(GetMovieDescription).InnerText;
node = htmlDoc.DocumentNode.SelectSingleNode(GetMovieDescription)?.InnerText;
}
catch
{
Expand Down
3 changes: 2 additions & 1 deletion Presentation.KuhakuCentral/KuhakuCentral.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@
<PackageReference Include="Auth" Version="0.0.0-alpha.0.27" />
<PackageReference Include="HtmlAgilityPack" Version="1.11.71" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="8.0.11" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.11" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.12" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.11" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.11">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="MimeKit" Version="4.9.0" />
<PackageReference Include="Scalar.AspNetCore" Version="2.0.12" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="7.1.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="7.1.0" />
</ItemGroup>
Expand Down
8 changes: 7 additions & 1 deletion Presentation.KuhakuCentral/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using KuhakuCentral.Extensions;
using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.AspNetCore.Mvc;
using Scalar.AspNetCore;
using Swashbuckle.AspNetCore.SwaggerUI;

var builder = WebApplication.CreateBuilder(args);
Expand Down Expand Up @@ -52,6 +53,7 @@
options.SwaggerEndpoint("/swagger/v1/swagger.json", "Kuhaku API");
options.DefaultModelRendering(ModelRendering.Model);
});

}

app.UseForwardedHeaders(new ForwardedHeadersOptions
Expand All @@ -60,7 +62,11 @@
});

//app.UseHttpsRedirection();

app.UseSwagger(options =>
{
options.RouteTemplate = "/openapi/{documentName}.json";
});
app.MapScalarApiReference();
app.UseAuthorization();

app.MapControllers();
Expand Down

0 comments on commit 6582a63

Please sign in to comment.