New: Bulk Grab Releases and Parameter Search

This commit is contained in:
Qstick
2021-11-20 02:52:26 -06:00
parent f69f96695b
commit 5d32bcf8b9
20 changed files with 961 additions and 50 deletions
@@ -1,7 +1,14 @@
using System.Text.RegularExpressions;
namespace NzbDrone.Core.IndexerSearch
{
public class NewznabRequest
{
private static readonly Regex TvRegex = new Regex(@"\{((?:imdbid\:)(?<imdbid>[^{]+)|(?:tvdbid\:)(?<tvdbid>[^{]+)|(?:season\:)(?<season>[^{]+)|(?:episode\:)(?<episode>[^{]+))\}", RegexOptions.Compiled | RegexOptions.IgnoreCase);
private static readonly Regex MovieRegex = new Regex(@"\{((?:imdbid\:)(?<imdbid>[^{]+)|(?:tmdbid\:)(?<tmdbid>[^{]+))\}", RegexOptions.Compiled | RegexOptions.IgnoreCase);
private static readonly Regex MusicRegex = new Regex(@"\{((?:artist\:)(?<artist>[^{]+)|(?:album\:)(?<album>[^{]+)|(?:label\:)(?<label>[^{]+))\}", RegexOptions.Compiled | RegexOptions.IgnoreCase);
private static readonly Regex BookRegex = new Regex(@"\{((?:author\:)(?<author>[^{]+)|(?:title\:)(?<title>[^{]+))\}", RegexOptions.Compiled | RegexOptions.IgnoreCase);
public string t { get; set; }
public string q { get; set; }
public string cat { get; set; }
@@ -28,5 +35,103 @@ namespace NzbDrone.Core.IndexerSearch
public string source { get; set; }
public string host { get; set; }
public string server { get; set; }
public void QueryToParams()
{
if (t == "tvsearch")
{
var matches = TvRegex.Matches(q);
foreach (Match match in matches)
{
if (match.Groups["tvdbid"].Success)
{
tvdbid = int.TryParse(match.Groups["tvdbid"].Value, out var tvdb) ? tvdb : null;
}
if (match.Groups["season"].Success)
{
season = int.TryParse(match.Groups["season"].Value, out var seasonParsed) ? seasonParsed : null;
}
if (match.Groups["imdbid"].Success)
{
imdbid = match.Groups["imdbid"].Value;
}
if (match.Groups["episode"].Success)
{
ep = match.Groups["episode"].Value;
}
q = q.Replace(match.Value, "");
}
}
if (t == "movie")
{
var matches = MovieRegex.Matches(q);
foreach (Match match in matches)
{
if (match.Groups["tmdbid"].Success)
{
tmdbid = int.TryParse(match.Groups["tmdbid"].Value, out var tmdb) ? tmdb : null;
}
if (match.Groups["imdbid"].Success)
{
imdbid = match.Groups["imdbid"].Value;
}
q = q.Replace(match.Value, "").Trim();
}
}
if (t == "music")
{
var matches = MusicRegex.Matches(q);
foreach (Match match in matches)
{
if (match.Groups["artist"].Success)
{
artist = match.Groups["artist"].Value;
}
if (match.Groups["album"].Success)
{
album = match.Groups["album"].Value;
}
if (match.Groups["label"].Success)
{
label = match.Groups["label"].Value;
}
q = q.Replace(match.Value, "").Trim();
}
}
if (t == "book")
{
var matches = BookRegex.Matches(q);
foreach (Match match in matches)
{
if (match.Groups["author"].Success)
{
author = match.Groups["author"].Value;
}
if (match.Groups["title"].Success)
{
title = match.Groups["title"].Value;
}
q = q.Replace(match.Value, "").Trim();
}
}
}
}
}