Пример #1
0
        private void ProcessMissingInformation(List <RequestQueue> requests)
        {
            if (!requests.Any())
            {
                return;
            }

            var sonarrSettings   = SonarrSettings.GetSettings();
            var sickrageSettings = SickrageSettings.GetSettings();

            var tv = requests.Where(x => x.Type == RequestType.TvShow);

            // TV
            var tvApi = new TvMazeApi();

            foreach (var t in tv)
            {
                var providerId = int.Parse(t.PrimaryIdentifier);
                var showInfo   = tvApi.ShowLookup(providerId);

                if (showInfo.externals?.thetvdb != null)
                {
                    // We now have the info
                    var tvModel = ByteConverterHelper.ReturnObject <RequestedModel>(t.Content);
                    tvModel.ProviderId = showInfo.externals.thetvdb.Value;
                    var result = ProcessTvShow(tvModel, sonarrSettings, sickrageSettings);

                    if (!result)
                    {
                        // we now have the info but couldn't add it, so add it back into the queue but with a different fault
                        t.Content   = ByteConverterHelper.ReturnBytes(tvModel);
                        t.FaultType = FaultType.RequestFault;
                        t.LastRetry = DateTime.UtcNow;
                        Repo.Update(t);
                    }
                    else
                    {
                        // Make sure it's been requested
                        var existingRequests = RequestService.GetAll();
                        var thisItem         = existingRequests.Any(x => x.Title.Equals(tvModel.Title));
                        if (!thisItem)
                        {
                            tvModel.Approved = true;
                            RequestService.AddRequest(tvModel);
                        }

                        // Successful, remove from the fault queue
                        Repo.Delete(t);
                    }
                }
            }
        }
Пример #2
0
        public async Task <IEnumerable <SearchTvShowViewModel> > NowPlayingMovies()
        {
            var rand      = new Random();
            var responses = new List <SearchTvShowViewModel>();

            for (int i = 0; i < 10; i++)
            {
                var item = rand.Next(_demoLists.TvShows.Length);
                var tv   = _demoLists.TvShows[item];
                if (responses.Any(x => x.Id == tv))
                {
                    i--;
                    continue;
                }

                var movieResult = await TvMazeApi.ShowLookup(tv);

                responses.Add(await ProcessResult(movieResult, false));
            }

            return(responses);
        }