private async Task <TvRequestRow> CreateRequest(CreateTvRequestCommand request)
        {
            var tvDetails   = _theMovieDbService.GetTvDetails(request.TheMovieDbId);
            var externalIds = _theMovieDbService.GetTvExternalIds(request.TheMovieDbId);

            await Task.WhenAll(tvDetails, externalIds);

            var tvRequest = new TvRequestRow
            {
                RequestStatus = RequestStatuses.PendingApproval,
                Title         = tvDetails.Result.Name,
                AirDateUtc    = DateTime.Parse(tvDetails.Result.First_Air_Date),
                ImagePath     = tvDetails.Result.Poster_Path,
                Track         = request.TrackShow,
                TheMovieDbId  = request.TheMovieDbId
            };

            tvRequest.TvRequestAgents.Add(new TvRequestAgentRow(AgentTypes.TheMovieDb, request.TheMovieDbId.ToString()));

            if (!string.IsNullOrEmpty(externalIds.Result.TvDb_Id))
            {
                tvRequest.TvRequestAgents.Add(new TvRequestAgentRow(AgentTypes.TheTvDb, externalIds.Result.TvDb_Id));
            }

            await _requestService.Add(tvRequest);

            return(tvRequest);
        }
Beispiel #2
0
        public async Task <PlexMediaItemRow> Get(int theMovieDbId)
        {
            var plexMediaItem = await GetPlexMediaItem(AgentTypes.TheMovieDb, theMovieDbId.ToString());

            if (plexMediaItem == null)
            {
                var externalIds = await _theMovieDbService.GetTvExternalIds(theMovieDbId);

                if (!string.IsNullOrEmpty(externalIds.TvDb_Id))
                {
                    plexMediaItem = await GetPlexMediaItem(AgentTypes.TheTvDb, externalIds.TvDb_Id);
                }

                if (plexMediaItem == null && !string.IsNullOrEmpty(externalIds.Imdb_Id))
                {
                    plexMediaItem = await GetPlexMediaItem(AgentTypes.Imdb, externalIds.Imdb_Id);
                }
            }

            return(plexMediaItem);
        }