1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-09 04:22:30 +01:00

Added first iteration of adding movies.

Currently working:
- Searching for new Movies on IMDb (very hacky)
- Adding movie as a series with one season and episode (very hacky)
- Rarbg.to indexer. (somewhat hacky)

TODO:
- Tweak release specifications so that they do not cause exceptions.
- Add Movie struct so that searching for ones is not so hacky.
- rework movies UI.
This commit is contained in:
Leonardo Galli 2016-12-27 18:31:38 +01:00
parent 426448ed98
commit 20dbdfb344
7 changed files with 120 additions and 16 deletions

View File

@ -80,7 +80,8 @@ private IEnumerable<DownloadDecision> GetDecisions(List<ReleaseInfo> reports, Se
if (remoteEpisode.Series == null) if (remoteEpisode.Series == null)
{ {
decision = new DownloadDecision(remoteEpisode, new Rejection("Unknown Series")); remoteEpisode.DownloadAllowed = true; //Fuck you :)
decision = GetDecisionForReport(remoteEpisode, searchCriteria);
} }
else if (remoteEpisode.Episodes.Empty()) else if (remoteEpisode.Episodes.Empty())
{ {
@ -143,8 +144,9 @@ private Rejection EvaluateSpec(IDecisionEngineSpecification spec, RemoteEpisode
{ {
e.Data.Add("report", remoteEpisode.Release.ToJson()); e.Data.Add("report", remoteEpisode.Release.ToJson());
e.Data.Add("parsed", remoteEpisode.ParsedEpisodeInfo.ToJson()); e.Data.Add("parsed", remoteEpisode.ParsedEpisodeInfo.ToJson());
_logger.Error(e, "Couldn't evaluate decision on " + remoteEpisode.Release.Title); _logger.Error(e, "Couldn't evaluate decision on " + remoteEpisode.Release.Title + ", with spec: " + spec.GetType().Name);
return new Rejection(string.Format("{0}: {1}", spec.GetType().Name, e.Message)); //return new Rejection(string.Format("{0}: {1}", spec.GetType().Name, e.Message));//TODO UPDATE SPECS!
//return null;
} }
return null; return null;

View File

@ -30,7 +30,7 @@ public virtual Decision IsSatisfiedBy(RemoteEpisode subject, SearchCriteriaBase
if (subject.Episodes.Any(e => !e.AirDateUtc.HasValue || e.AirDateUtc.Value.After(DateTime.UtcNow))) if (subject.Episodes.Any(e => !e.AirDateUtc.HasValue || e.AirDateUtc.Value.After(DateTime.UtcNow)))
{ {
_logger.Debug("Full season release {0} rejected. All episodes haven't aired yet.", subject.Release.Title); _logger.Debug("Full season release {0} rejected. All episodes haven't aired yet.", subject.Release.Title);
return Decision.Reject("Full season release rejected. All episodes haven't aired yet."); //return Decision.Reject("Full season release rejected. All episodes haven't aired yet.");
} }
} }

View File

@ -28,7 +28,8 @@ public Decision IsSatisfiedBy(RemoteEpisode remoteEpisode, SearchCriteriaBase se
if (singleEpisodeSpec.SeasonNumber != remoteEpisode.ParsedEpisodeInfo.SeasonNumber) if (singleEpisodeSpec.SeasonNumber != remoteEpisode.ParsedEpisodeInfo.SeasonNumber)
{ {
_logger.Debug("Season number does not match searched season number, skipping."); _logger.Debug("Season number does not match searched season number, skipping.");
return Decision.Reject("Wrong season"); //return Decision.Reject("Wrong season");
//Unnecessary for Movies
} }
return Decision.Accept(); return Decision.Accept();

View File

@ -29,19 +29,19 @@ public Decision IsSatisfiedBy(RemoteEpisode remoteEpisode, SearchCriteriaBase se
if (singleEpisodeSpec.SeasonNumber != remoteEpisode.ParsedEpisodeInfo.SeasonNumber) if (singleEpisodeSpec.SeasonNumber != remoteEpisode.ParsedEpisodeInfo.SeasonNumber)
{ {
_logger.Debug("Season number does not match searched season number, skipping."); _logger.Debug("Season number does not match searched season number, skipping.");
return Decision.Reject("Wrong season"); //return Decision.Reject("Wrong season");
} }
if (!remoteEpisode.ParsedEpisodeInfo.EpisodeNumbers.Any()) if (!remoteEpisode.ParsedEpisodeInfo.EpisodeNumbers.Any())
{ {
_logger.Debug("Full season result during single episode search, skipping."); _logger.Debug("Full season result during single episode search, skipping.");
return Decision.Reject("Full season pack"); //return Decision.Reject("Full season pack");
} }
if (!remoteEpisode.ParsedEpisodeInfo.EpisodeNumbers.Contains(singleEpisodeSpec.EpisodeNumber)) if (!remoteEpisode.ParsedEpisodeInfo.EpisodeNumbers.Contains(singleEpisodeSpec.EpisodeNumber))
{ {
_logger.Debug("Episode number does not match searched episode number, skipping."); _logger.Debug("Episode number does not match searched episode number, skipping.");
return Decision.Reject("Wrong episode"); //return Decision.Reject("Wrong episode");
} }
return Decision.Accept(); return Decision.Accept();

View File

@ -88,12 +88,13 @@ private IEnumerable<IndexerRequest> GetPagedRequests(string mode, int? tvdbId, s
if (tvdbId.HasValue) if (tvdbId.HasValue)
{ {
requestBuilder.AddQueryParam("search_tvdb", tvdbId.Value); string imdbId = string.Format("tt{0:D7}", tvdbId);
requestBuilder.AddQueryParam("search_imdb", imdbId);
} }
if (query.IsNotNullOrWhiteSpace()) if (query.IsNotNullOrWhiteSpace())
{ {
requestBuilder.AddQueryParam("search_string", string.Format(query, args)); //requestBuilder.AddQueryParam("search_string", string.Format(query, args));
} }
if (!Settings.RankedOnly) if (!Settings.RankedOnly)
@ -101,7 +102,7 @@ private IEnumerable<IndexerRequest> GetPagedRequests(string mode, int? tvdbId, s
requestBuilder.AddQueryParam("ranked", "0"); requestBuilder.AddQueryParam("ranked", "0");
} }
requestBuilder.AddQueryParam("category", "18;41"); requestBuilder.AddQueryParam("category", "movies");
requestBuilder.AddQueryParam("limit", "100"); requestBuilder.AddQueryParam("limit", "100");
requestBuilder.AddQueryParam("token", _tokenProvider.GetToken(Settings)); requestBuilder.AddQueryParam("token", _tokenProvider.GetToken(Settings));
requestBuilder.AddQueryParam("format", "json_extended"); requestBuilder.AddQueryParam("format", "json_extended");

View File

@ -10,6 +10,7 @@
using NzbDrone.Core.MediaCover; using NzbDrone.Core.MediaCover;
using NzbDrone.Core.MetadataSource.SkyHook.Resource; using NzbDrone.Core.MetadataSource.SkyHook.Resource;
using NzbDrone.Core.Tv; using NzbDrone.Core.Tv;
using Newtonsoft.Json;
namespace NzbDrone.Core.MetadataSource.SkyHook namespace NzbDrone.Core.MetadataSource.SkyHook
{ {
@ -37,7 +38,11 @@ public Tuple<Series, List<Episode>> GetSeriesInfo(int tvdbSeriesId)
httpRequest.AllowAutoRedirect = true; httpRequest.AllowAutoRedirect = true;
httpRequest.SuppressHttpError = true; httpRequest.SuppressHttpError = true;
var httpResponse = _httpClient.Get<ShowResource>(httpRequest); string imdbId = string.Format("tt{0:D7}", tvdbSeriesId);
var imdbRequest = new HttpRequest("http://www.omdbapi.com/?i="+ imdbId + "&plot=full&r=json");
var httpResponse = _httpClient.Get(imdbRequest);
if (httpResponse.HasHttpError) if (httpResponse.HasHttpError)
{ {
@ -51,8 +56,43 @@ public Tuple<Series, List<Episode>> GetSeriesInfo(int tvdbSeriesId)
} }
} }
var episodes = httpResponse.Resource.Episodes.Select(MapEpisode); var response = httpResponse.Content;
var series = MapSeries(httpResponse.Resource);
dynamic json = JsonConvert.DeserializeObject(response);
var series = new Series();
series.Title = json.Title;
series.TitleSlug = series.Title.ToLower().Replace(" ", "-");
series.Overview = json.Plot;
series.CleanTitle = series.Title;
series.TvdbId = tvdbSeriesId;
string airDateStr = json.Released;
DateTime airDate = DateTime.Parse(airDateStr);
series.FirstAired = airDate;
series.Year = airDate.Year;
series.ImdbId = imdbId;
series.Images = new List<MediaCover.MediaCover>();
string url = json.Poster;
var imdbPoster = new MediaCover.MediaCover(MediaCoverTypes.Poster, url);
series.Images.Add(imdbPoster);
var season = new Season();
season.SeasonNumber = 1;
season.Monitored = true;
series.Seasons.Add(season);
var episode = new Episode();
episode.AirDate = airDate.ToShortTimeString();
episode.Title = json.Title;
episode.SeasonNumber = 1;
episode.EpisodeNumber = 1;
episode.Overview = series.Overview;
episode.AirDate = airDate.ToShortDateString();
var episodes = new List<Episode> { episode };
return new Tuple<Series, List<Episode>>(series, episodes.ToList()); return new Tuple<Series, List<Episode>>(series, episodes.ToList());
} }
@ -89,6 +129,66 @@ public List<Series> SearchForNewSeries(string title)
.AddQueryParam("term", title.ToLower().Trim()) .AddQueryParam("term", title.ToLower().Trim())
.Build(); .Build();
var searchTerm = lowerTitle.Replace("+", "_").Replace(" ", "_");
var firstChar = searchTerm.First();
var imdbRequest = new HttpRequest("https://v2.sg.media-imdb.com/suggests/"+firstChar+"/" + searchTerm + ".json");
var response = _httpClient.Get(imdbRequest);
var imdbCallback = "imdb$" + searchTerm + "(";
var responseCleaned = response.Content.Replace(imdbCallback, "").TrimEnd(")");
dynamic json = JsonConvert.DeserializeObject(responseCleaned);
var imdbMovies = new List<Series>();
foreach (dynamic entry in json.d)
{
var imdbMovie = new Series();
imdbMovie.ImdbId = entry.id;
string noTT = imdbMovie.ImdbId.Replace("tt", "");
try
{
imdbMovie.TvdbId = (int)Double.Parse(noTT);
}
catch
{
imdbMovie.TvdbId = 0;
}
try
{
imdbMovie.SortTitle = entry.l;
imdbMovie.Title = entry.l;
string titleSlug = entry.l;
imdbMovie.TitleSlug = titleSlug.ToLower().Replace(" ", "-");
imdbMovie.Year = entry.y;
imdbMovie.Images = new List<MediaCover.MediaCover>();
try
{
string url = entry.i[0];
var imdbPoster = new MediaCover.MediaCover(MediaCoverTypes.Poster, url);
imdbMovie.Images.Add(imdbPoster);
}
catch (Exception e)
{
_logger.Debug(entry);
continue;
}
imdbMovies.Add(imdbMovie);
}
catch
{
}
}
return imdbMovies;
var httpResponse = _httpClient.Get<List<ShowResource>>(httpRequest); var httpResponse = _httpClient.Get<List<ShowResource>>(httpRequest);
return httpResponse.Resource.SelectList(MapSeries); return httpResponse.Resource.SelectList(MapSeries);

View File

@ -19,7 +19,7 @@
</div> </div>
<div class="navbar-collapse collapse x-navbar-collapse"> <div class="navbar-collapse collapse x-navbar-collapse">
<ul class="nav navbar-nav"> <ul class="nav navbar-nav">
<li><a href="{{UrlBase}}/" class="x-series-nav"><i class="icon-sonarr-navbar-icon icon-sonarr-navbar-series"></i> Series</a></li> <li><a href="{{UrlBase}}/" class="x-series-nav"><i class="icon-sonarr-navbar-icon icon-sonarr-navbar-series"></i> Movies</a></li>
<li><a href="{{UrlBase}}/calendar" class="x-calendar-nav"><i class="icon-sonarr-navbar-icon icon-sonarr-navbar-calendar"></i> Calendar</a></li> <li><a href="{{UrlBase}}/calendar" class="x-calendar-nav"><i class="icon-sonarr-navbar-icon icon-sonarr-navbar-calendar"></i> Calendar</a></li>
<li><a href="{{UrlBase}}/activity" class="x-activity-nav"><i class="icon-sonarr-navbar-icon icon-sonarr-navbar-activity"></i> Activity<span id="x-queue-count" class="navbar-info"></span></a></li> <li><a href="{{UrlBase}}/activity" class="x-activity-nav"><i class="icon-sonarr-navbar-icon icon-sonarr-navbar-activity"></i> Activity<span id="x-queue-count" class="navbar-info"></span></a></li>
<li><a href="{{UrlBase}}/wanted" class="x-wanted-nav"><i class="icon-sonarr-navbar-icon icon-sonarr-navbar-wanted"></i> Wanted</a></li> <li><a href="{{UrlBase}}/wanted" class="x-wanted-nav"><i class="icon-sonarr-navbar-icon icon-sonarr-navbar-wanted"></i> Wanted</a></li>