mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-09 03:04:20 -04:00
Fixing bugs with the crawler that keep appening, cleaning the regex
This commit is contained in:
parent
7be4133af9
commit
74fabb11ea
@ -1,10 +1,11 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Kyoo.Models.Attributes;
|
||||
|
||||
namespace Kyoo.Models
|
||||
{
|
||||
public class Episode
|
||||
public class Episode : IOnMerge
|
||||
{
|
||||
[JsonIgnore] public int ID { get; set; }
|
||||
[JsonIgnore] public int ShowID { get; set; }
|
||||
@ -12,9 +13,9 @@ namespace Kyoo.Models
|
||||
[JsonIgnore] public int? SeasonID { get; set; }
|
||||
[JsonIgnore] public virtual Season Season { get; set; }
|
||||
|
||||
public int SeasonNumber { get; set; }
|
||||
public int EpisodeNumber { get; set; }
|
||||
public int AbsoluteNumber { get; set; }
|
||||
public int SeasonNumber { get; set; } = -1;
|
||||
public int EpisodeNumber { get; set; } = -1;
|
||||
public int AbsoluteNumber { get; set; } = -1;
|
||||
[JsonIgnore] public string Path { get; set; }
|
||||
public string Title { get; set; }
|
||||
public string Overview { get; set; }
|
||||
@ -94,5 +95,16 @@ namespace Kyoo.Models
|
||||
{
|
||||
return showSlug + "-s" + seasonNumber + "e" + episodeNumber;
|
||||
}
|
||||
|
||||
public void OnMerge(object merged)
|
||||
{
|
||||
Episode other = (Episode)merged;
|
||||
if (SeasonNumber == -1 && other.SeasonNumber != -1)
|
||||
SeasonNumber = other.SeasonNumber;
|
||||
if (EpisodeNumber == -1 && other.EpisodeNumber != -1)
|
||||
EpisodeNumber = other.EpisodeNumber;
|
||||
if (AbsoluteNumber == -1 && other.AbsoluteNumber != -1)
|
||||
AbsoluteNumber = other.AbsoluteNumber;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ using System.Text.RegularExpressions;
|
||||
using JetBrains.Annotations;
|
||||
using Kyoo.Models;
|
||||
using Kyoo.Models.Attributes;
|
||||
using Microsoft.VisualBasic;
|
||||
|
||||
namespace Kyoo
|
||||
{
|
||||
@ -93,7 +94,6 @@ namespace Kyoo
|
||||
|
||||
public static T Merge<T>(T first, T second)
|
||||
{
|
||||
// TODO During the merge, reference to the second values are not set to the first value (for child objects).
|
||||
if (first == null)
|
||||
return second;
|
||||
if (second == null)
|
||||
@ -124,8 +124,8 @@ namespace Kyoo
|
||||
}
|
||||
}
|
||||
|
||||
if (first is IOnMerge)
|
||||
((IOnMerge)first).OnMerge(second);
|
||||
if (first is IOnMerge merge)
|
||||
merge.OnMerge(second);
|
||||
return first;
|
||||
}
|
||||
|
||||
|
@ -147,7 +147,7 @@ namespace Kyoo.Controllers
|
||||
|
||||
string showPath = Path.GetDirectoryName(path);
|
||||
string collectionName = match.Groups["Collection"]?.Value;
|
||||
string showName = match.Groups["ShowTitle"].Value;
|
||||
string showName = match.Groups["Show"].Value;
|
||||
int seasonNumber = int.TryParse(match.Groups["Season"].Value, out int tmp) ? tmp : -1;
|
||||
int episodeNumber = int.TryParse(match.Groups["Episode"].Value, out tmp) ? tmp : -1;
|
||||
int absoluteNumber = int.TryParse(match.Groups["Absolute"].Value, out tmp) ? tmp : -1;
|
||||
@ -272,12 +272,6 @@ namespace Kyoo.Controllers
|
||||
season ??= await GetSeason(libraryManager, show, episode.SeasonNumber, library);
|
||||
episode.Season = season;
|
||||
episode.SeasonID = season?.ID;
|
||||
if (season == null)
|
||||
{
|
||||
await Console.Error.WriteLineAsync("Error: You don't have any provider that support absolute epiode numbering. Install one and try again.");
|
||||
return default;
|
||||
}
|
||||
|
||||
await _thumbnailsManager.Validate(episode);
|
||||
await GetTracks(episode);
|
||||
return episode;
|
||||
|
@ -9,7 +9,8 @@
|
||||
"Microsoft": "Warning",
|
||||
"Microsoft.Hosting.Lifetime": "Information",
|
||||
"Microsoft.EntityFrameworkCore.DbUpdateException": "None",
|
||||
"Microsoft.EntityFrameworkCore.Update": "None"
|
||||
"Microsoft.EntityFrameworkCore.Update": "None",
|
||||
"Microsoft.EntityFrameworkCore.Database.Command": "None"
|
||||
}
|
||||
},
|
||||
"AllowedHosts": "*",
|
||||
@ -32,5 +33,5 @@
|
||||
"plugins": "plugins/",
|
||||
"defaultPermissions": "read,play,write,admin",
|
||||
"newUserPermissions": "read,play,write,admin",
|
||||
"regex": "(\\/(?<Collection>.*)\\/)?.*\\/(?<ShowTitle>.+?)( \\(\\d*\\))?(( S(?<Season>\\d+)E(?<Episode>\\d+)| (?<Absolute>\\d+)))?\\."
|
||||
}
|
||||
"regex": "(?:\\/(?<Collection>.*?))?\\/(?<Show>.*)(?: \\(\\d+\\))?\\/\\k<Show>(?: \\(\\d+\\))?(?:(?: S(?<Season>\\d+)E(?<Episode>\\d+))| (?<Absolute>\\d+))?.*$"
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
cd /opt/kyoo
|
||||
dotnet Kyoo.dll
|
||||
cd /opt/kyoo || exit 1
|
||||
dotnet Kyoo.dll
|
5
Kyoo/regexTesterr.sh
Executable file
5
Kyoo/regexTesterr.sh
Executable file
@ -0,0 +1,5 @@
|
||||
#! /usr/bin/bash
|
||||
|
||||
REGEX="(?:\/(?<Collection>.*?))?\/(?<ShowTitle>.*)(?: \(\d+\))?\/\k<ShowTitle>(?: \(\d+\))?(?:(?: S(?<SeasonNumber>\d+)E(?<EpisodeNumber>\d+))| (?<AbsoluteNumber>\d+))?.*$"
|
||||
|
||||
find "$1" -type f \( -name '*.mp4' -o -name '*.mkv' \) | cut -c $((${#1} + 1))- | grep -viP "$REGEX"
|
Loading…
x
Reference in New Issue
Block a user