mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-06-23 15:30:34 -04:00
Reworking the crawler to use only one regex and adding movies support
This commit is contained in:
parent
eb0aa23293
commit
e5bb71084b
@ -26,9 +26,11 @@ namespace Kyoo.Models
|
|||||||
[JsonIgnore] public string ImgBackdrop { get; set; }
|
[JsonIgnore] public string ImgBackdrop { get; set; }
|
||||||
|
|
||||||
public string ExternalIDs { get; set; }
|
public string ExternalIDs { get; set; }
|
||||||
|
|
||||||
|
public bool IsMovie { get; set; }
|
||||||
|
|
||||||
public bool IsCollection;
|
public bool IsCollection;
|
||||||
|
|
||||||
[JsonIgnore] public virtual IEnumerable<Genre> Genres
|
[JsonIgnore] public virtual IEnumerable<Genre> Genres
|
||||||
{
|
{
|
||||||
get { return GenreLinks?.Select(x => x.Genre).OrderBy(x => x.Name); }
|
get { return GenreLinks?.Select(x => x.Genre).OrderBy(x => x.Name); }
|
||||||
|
@ -68,6 +68,7 @@ namespace Kyoo.Controllers
|
|||||||
|
|
||||||
private async Task RegisterFile(string path, string relativePath, Library library)
|
private async Task RegisterFile(string path, string relativePath, Library library)
|
||||||
{
|
{
|
||||||
|
Console.WriteLine("Registering episode at: " + path);
|
||||||
string patern = _config.GetValue<string>("regex");
|
string patern = _config.GetValue<string>("regex");
|
||||||
Regex regex = new Regex(patern, RegexOptions.IgnoreCase);
|
Regex regex = new Regex(patern, RegexOptions.IgnoreCase);
|
||||||
Match match = regex.Match(relativePath);
|
Match match = regex.Match(relativePath);
|
||||||
@ -75,35 +76,23 @@ namespace Kyoo.Controllers
|
|||||||
string showPath = Path.GetDirectoryName(path);
|
string showPath = Path.GetDirectoryName(path);
|
||||||
string collectionName = match.Groups["Collection"]?.Value;
|
string collectionName = match.Groups["Collection"]?.Value;
|
||||||
string showName = match.Groups["ShowTitle"].Value;
|
string showName = match.Groups["ShowTitle"].Value;
|
||||||
bool seasonSuccess = long.TryParse(match.Groups["Season"].Value, out long seasonNumber);
|
long seasonNumber = long.TryParse(match.Groups["Season"].Value, out long tmp) ? tmp : -1;
|
||||||
bool episodeSucess = long.TryParse(match.Groups["Episode"].Value, out long episodeNumber);
|
long episodeNumber = long.TryParse(match.Groups["Episode"].Value, out tmp) ? tmp : -1;
|
||||||
long absoluteNumber = -1;
|
long absoluteNumber = long.TryParse(match.Groups["Absolute"].Value, out tmp) ? tmp : -1;
|
||||||
|
|
||||||
Console.WriteLine("Registering episode at: " + path);
|
|
||||||
if (!seasonSuccess || !episodeSucess)
|
|
||||||
{
|
|
||||||
//Considering that the episode is using absolute path.
|
|
||||||
seasonNumber = -1;
|
|
||||||
episodeNumber = -1;
|
|
||||||
|
|
||||||
regex = new Regex(_config.GetValue<string>("absoluteRegex"));
|
|
||||||
match = regex.Match(relativePath);
|
|
||||||
|
|
||||||
showName = match.Groups["ShowTitle"].Value;
|
|
||||||
bool absoluteSucess = long.TryParse(match.Groups["AbsoluteNumber"].Value, out absoluteNumber);
|
|
||||||
|
|
||||||
if (!absoluteSucess)
|
|
||||||
{
|
|
||||||
Console.Error.WriteLine("Couldn't find basic data for the episode (regexs didn't match) " + relativePath);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Collection collection = await GetCollection(collectionName, library);
|
Collection collection = await GetCollection(collectionName, library);
|
||||||
Show show = await GetShow(showName, showPath, library);
|
Show show = await GetShow(showName, showPath, library);
|
||||||
Season season = seasonNumber != -1 ? await GetSeason(show, seasonNumber, library) : null;
|
if (seasonNumber == -1 && episodeNumber == -1 && absoluteNumber == -1)
|
||||||
Episode episode = await GetEpisode(show, season, episodeNumber, absoluteNumber, path, library);
|
{
|
||||||
_libraryManager.RegisterEpisode(episode);
|
show.IsMovie = true;
|
||||||
|
_libraryManager.RegisterShow(show);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Season season = await GetSeason(show, seasonNumber, library);
|
||||||
|
Episode episode = await GetEpisode(show, season, episodeNumber, absoluteNumber, path, library);
|
||||||
|
_libraryManager.RegisterEpisode(episode);
|
||||||
|
}
|
||||||
_libraryManager.RegisterShowLinks(library, collection, show);
|
_libraryManager.RegisterShowLinks(library, collection, show);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,6 +120,8 @@ namespace Kyoo.Controllers
|
|||||||
|
|
||||||
private async Task<Season> GetSeason(Show show, long seasonNumber, Library library)
|
private async Task<Season> GetSeason(Show show, long seasonNumber, Library library)
|
||||||
{
|
{
|
||||||
|
if (seasonNumber == -1)
|
||||||
|
return null;
|
||||||
Season season = _libraryManager.GetSeason(show.Slug, seasonNumber);
|
Season season = _libraryManager.GetSeason(show.Slug, seasonNumber);
|
||||||
if (season != null)
|
if (season != null)
|
||||||
return await Task.FromResult(season);
|
return await Task.FromResult(season);
|
||||||
|
@ -16,6 +16,5 @@
|
|||||||
"transcodeTempPath": "/tmp/cached/kyoo/transcode",
|
"transcodeTempPath": "/tmp/cached/kyoo/transcode",
|
||||||
"peoplePath": "/tmp/people",
|
"peoplePath": "/tmp/people",
|
||||||
"plugins": "plugins/",
|
"plugins": "plugins/",
|
||||||
"regex": "^(\\/(?<Collection>.+?))?\\/.*\\/(?<ShowTitle>.+?) S(?<Season>\\d+)E(?<Episode>\\d+)",
|
"regex": "(\\/(?<Collection>.*)\\/)?.*\\/(?<ShowTitle>.+?)(( S(?<Season>\\d+)E(?<Episode>\\d+)| (?<Absolute>\\d+)))?\\.",
|
||||||
"absoluteRegex": ".*\\/(?<ShowTitle>.+?) (?<AbsoluteNumber>\\d+)"
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user