mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2026-04-24 22:55:21 -04:00
New: Bulk Grab Releases and Parameter Search
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user