mirror of
https://github.com/knightcrawler-stremio/knightcrawler.git
synced 2024-12-20 03:29:51 +00:00
trigram performance increased and housekeeping (#184)
* add new indexes, and change year column to int * Change gist to gin, and change year to int * Producer changes for new gin query * Fully map the rtn response using json dump from Pydantic Also updates Rtn to 0.1.9 * Add housekeeping script to reconcile imdb ids. * Join Torrent onto the ingested torrent table Ensure that a torrent can always find the details of where it came from, and how it was parsed. * Version bump for release * missing quote on table name
This commit is contained in:
@@ -14,34 +14,31 @@ public class RankTorrentName : IRankTorrentName
|
||||
}
|
||||
|
||||
public ParseTorrentTitleResponse Parse(string title) =>
|
||||
_pythonEngineService.ExecutePythonOperation(
|
||||
_pythonEngineService.ExecutePythonOperationWithDefault(
|
||||
() =>
|
||||
{
|
||||
var result = _rtn?.parse(title);
|
||||
return ParseResult(result);
|
||||
}, nameof(Parse), throwOnErrors: false);
|
||||
|
||||
}, new ParseTorrentTitleResponse(false, null), nameof(Parse), throwOnErrors: false, logErrors: false);
|
||||
|
||||
|
||||
private static ParseTorrentTitleResponse ParseResult(dynamic result)
|
||||
{
|
||||
if (result == null)
|
||||
{
|
||||
return new(false, string.Empty, 0);
|
||||
return new(false, null);
|
||||
}
|
||||
|
||||
var json = result.model_dump_json()?.As<string?>();
|
||||
|
||||
if (json is null || string.IsNullOrEmpty(json))
|
||||
{
|
||||
return new(false, null);
|
||||
}
|
||||
|
||||
var parsedTitle = result.GetAttr("parsed_title")?.As<string>() ?? string.Empty;
|
||||
var year = result.GetAttr("year")?.As<int>() ?? 0;
|
||||
var seasons = GetIntArray(result, "season");
|
||||
var episodes = GetIntArray(result, "episode");
|
||||
var response = JsonSerializer.Deserialize<RtnResponse>(json);
|
||||
|
||||
return new ParseTorrentTitleResponse(true, parsedTitle, year, seasons, episodes);
|
||||
}
|
||||
|
||||
private static int[]? GetIntArray(dynamic result, string field)
|
||||
{
|
||||
var theList = result.GetAttr(field)?.As<PyList>();
|
||||
int[]? results = theList?.Length() > 0 ? theList.As<int[]>() : null;
|
||||
|
||||
return results;
|
||||
return new(true, response);
|
||||
}
|
||||
|
||||
private void InitModules() =>
|
||||
|
||||
Reference in New Issue
Block a user