public static TorznabQuery ToTorznabQuery(TorznabRequest request) { var query = new TorznabQuery() { QueryType = "search", SearchTerm = request.q, ImdbID = request.imdbid, Episode = request.ep, }; if (request.t != null) { query.QueryType = request.t; } if (!request.extended.IsNullOrEmptyOrWhitespace()) { query.Extended = ParseUtil.CoerceInt(request.extended); } if (!request.limit.IsNullOrEmptyOrWhitespace()) { query.Limit = ParseUtil.CoerceInt(request.limit); } if (!request.offset.IsNullOrEmptyOrWhitespace()) { query.Offset = ParseUtil.CoerceInt(request.offset); } if (request.cat != null) { query.Categories = request.cat.Split(',').Where(s => !string.IsNullOrWhiteSpace(s)).Select(s => int.Parse(s)).ToArray(); } else { if (query.QueryType == "movie" && !string.IsNullOrWhiteSpace(request.imdbid)) { query.Categories = new int[] { TorznabCatType.Movies.ID } } ; else { query.Categories = new int[0]; } } if (!request.rid.IsNullOrEmptyOrWhitespace()) { query.RageID = int.Parse(request.rid); } if (!request.season.IsNullOrEmptyOrWhitespace()) { query.Season = int.Parse(request.season); } if (!request.album.IsNullOrEmptyOrWhitespace()) { query.Album = request.album; } if (!request.artist.IsNullOrEmptyOrWhitespace()) { query.Artist = request.artist; } if (!request.label.IsNullOrEmptyOrWhitespace()) { query.Label = request.label; } if (!request.track.IsNullOrEmptyOrWhitespace()) { query.Track = request.track; } if (!request.year.IsNullOrEmptyOrWhitespace()) { query.Year = int.Parse(request.year); } if (!request.genre.IsNullOrEmptyOrWhitespace()) { query.Genre = request.genre.Split(','); } query.ExpandCatsToSubCats(); return(query); }
public static TorznabQuery ToTorznabQuery(TorznabRequest request) { var query = new TorznabQuery() { QueryType = "search", SearchTerm = request.q, ImdbID = request.imdbid, Episode = request.ep, }; if (request.t != null) { query.QueryType = request.t; } if (!string.IsNullOrWhiteSpace(request.extended)) { query.Extended = ParseUtil.CoerceInt(request.extended); } if (!string.IsNullOrWhiteSpace(request.limit)) { query.Limit = ParseUtil.CoerceInt(request.limit); } if (!string.IsNullOrWhiteSpace(request.offset)) { query.Offset = ParseUtil.CoerceInt(request.offset); } bool _cache; if (bool.TryParse(request.cache, out _cache)) { query.Cache = _cache; } if (request.cat != null) { query.Categories = request.cat.Split(',').Where(s => !string.IsNullOrWhiteSpace(s)).Select(s => int.Parse(s)).ToArray(); } else { if (query.QueryType == "movie" && !string.IsNullOrWhiteSpace(request.imdbid)) { query.Categories = new int[] { TorznabCatType.Movies.ID } } ; else { query.Categories = new int[0]; } } if (!string.IsNullOrWhiteSpace(request.season)) { query.Season = int.Parse(request.season); } if (!string.IsNullOrWhiteSpace(request.rid)) { query.RageID = int.Parse(request.rid); } if (!string.IsNullOrWhiteSpace(request.tvdbid)) { query.TvdbID = int.Parse(request.tvdbid); } if (!string.IsNullOrWhiteSpace(request.tvmazeid)) { query.TvmazeID = int.Parse(request.tvmazeid); } if (!string.IsNullOrWhiteSpace(request.tmdbid)) { query.TmdbID = int.Parse(request.tmdbid); } if (!string.IsNullOrWhiteSpace(request.traktid)) { query.TraktID = int.Parse(request.traktid); } if (!string.IsNullOrWhiteSpace(request.doubanid)) { query.DoubanID = int.Parse(request.doubanid); } if (!string.IsNullOrWhiteSpace(request.album)) { query.Album = request.album; } if (!string.IsNullOrWhiteSpace(request.artist)) { query.Artist = request.artist; } if (!string.IsNullOrWhiteSpace(request.label)) { query.Label = request.label; } if (!string.IsNullOrWhiteSpace(request.track)) { query.Track = request.track; } if (!string.IsNullOrWhiteSpace(request.year)) { query.Year = int.Parse(request.year); } if (!string.IsNullOrWhiteSpace(request.genre)) { query.Genre = request.genre; } if (!string.IsNullOrWhiteSpace(request.title)) { query.Title = request.title; } if (!string.IsNullOrWhiteSpace(request.author)) { query.Author = request.author; } if (!string.IsNullOrWhiteSpace(request.publisher)) { query.Author = request.publisher; } return(query); }