Example #1
0
        private async Task <string> GetTheMovieDbId(bool hasTvDbId, bool hasImdb, string tvdbID, string imdbId, string title)
        {
            _log.LogInformation("The Media item {0} does not have a TheMovieDbId, searching for TheMovieDbId", title);
            FindResult result    = null;
            var        hasResult = false;

            if (hasTvDbId)
            {
                result = await _movieApi.Find(tvdbID, ExternalSource.tvdb_id);

                hasResult = result?.tv_results?.Length > 0;

                _log.LogInformation("Setting Show {0} because we have TvDbId, result: {1}", title, hasResult);
            }
            if (hasImdb && !hasResult)
            {
                result = await _movieApi.Find(imdbId, ExternalSource.imdb_id);

                hasResult = result?.tv_results?.Length > 0;

                _log.LogInformation("Setting Show {0} because we have ImdbId, result: {1}", title, hasResult);
            }
            if (hasResult)
            {
                return(result.tv_results?[0]?.id.ToString() ?? string.Empty);
            }
            return(string.Empty);
        }
Example #2
0
        private async Task ProcessEmbyMovies(IQueryable <EmbyContent> embyContent, StringBuilder sb, string defaultLangaugeCode, string customUrl)
        {
            int count   = 0;
            var ordered = embyContent.OrderByDescending(x => x.AddedAt);

            foreach (var content in ordered)
            {
                var theMovieDbId = content.TheMovieDbId;
                if (!content.TheMovieDbId.HasValue())
                {
                    var imdbId     = content.ImdbId;
                    var findResult = await _movieApi.Find(imdbId, ExternalSource.imdb_id);

                    var result = findResult.movie_results?.FirstOrDefault();
                    if (result == null)
                    {
                        continue;
                    }

                    theMovieDbId = result.id.ToString();
                }

                var mediaurl = content.Url;
                if (customUrl.HasValue())
                {
                    mediaurl = customUrl;
                }
                var info = await _movieApi.GetMovieInformationWithExtraInfo(StringHelper.IntParseLinq(theMovieDbId), defaultLangaugeCode);

                if (info == null)
                {
                    continue;
                }
                try
                {
                    CreateMovieHtmlContent(sb, info, mediaurl);
                    count += 1;
                }
                catch (Exception e)
                {
                    _log.LogError(e, "Error when processing Emby Movies {0}", info.Title);
                }
                finally
                {
                    EndLoopHtml(sb);
                }

                if (count == 2)
                {
                    count = 0;
                    sb.Append("</tr>");
                    sb.Append("<tr>");
                }
            }
        }
Example #3
0
        private async Task ProcessEmbyMovies(IQueryable <EmbyContent> embyContent, StringBuilder sb)
        {
            sb.Append(
                "<table border=\"0\" cellpadding=\"0\"  align=\"center\" cellspacing=\"0\" style=\"border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%;\" width=\"100%\">");
            var ordered = embyContent.OrderByDescending(x => x.AddedAt);

            foreach (var content in ordered)
            {
                var theMovieDbId = content.TheMovieDbId;
                if (!content.TheMovieDbId.HasValue())
                {
                    var imdbId     = content.ImdbId;
                    var findResult = await _movieApi.Find(imdbId, ExternalSource.imdb_id);

                    var result = findResult.movie_results?.FirstOrDefault();
                    if (result == null)
                    {
                        continue;
                    }

                    theMovieDbId = result.id.ToString();
                }

                var info = await _movieApi.GetMovieInformationWithExtraInfo(int.Parse(theMovieDbId));

                if (info == null)
                {
                    continue;
                }
                try
                {
                    CreateMovieHtmlContent(sb, info);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    throw;
                }
                finally
                {
                    EndLoopHtml(sb);
                }
            }
        }
Example #4
0
        private async Task ProcessPlexMovies(IQueryable <PlexServerContent> plexContentToSend, StringBuilder sb)
        {
            sb.Append(
                "<table border=\"0\" cellpadding=\"0\"  align=\"center\" cellspacing=\"0\" style=\"border-collapse: separate; mso-table-lspace: 0pt; mso-table-rspace: 0pt; width: 100%;\" width=\"100%\">");
            var ordered = plexContentToSend.OrderByDescending(x => x.AddedAt);

            foreach (var content in ordered)
            {
                if (content.TheMovieDbId.IsNullOrEmpty())
                {
                    // Maybe we should try the ImdbId?
                    if (content.ImdbId.HasValue())
                    {
                        var findResult = await _movieApi.Find(content.ImdbId, ExternalSource.imdb_id);

                        var movieId = findResult.movie_results?[0]?.id ?? 0;
                        content.TheMovieDbId = movieId.ToString();
                    }
                }

                int.TryParse(content.TheMovieDbId, out var movieDbId);
                var info = await _movieApi.GetMovieInformationWithExtraInfo(movieDbId);

                if (info == null)
                {
                    continue;
                }
                try
                {
                    CreateMovieHtmlContent(sb, info);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    throw;
                }
                finally
                {
                    EndLoopHtml(sb);
                }
            }
        }
Example #5
0
        private async Task GetProviderIds(PlexMetadata showMetadata, PlexServerContent existingContent)
        {
            var metadata = showMetadata.MediaContainer.Metadata.FirstOrDefault();
            var guids    = new List <string>
            {
                metadata.guid
            };

            if (metadata.Guid != null)
            {
                foreach (var g in metadata.Guid)
                {
                    guids.Add(g.Id);
                }
            }
            var providerIds =
                PlexHelper.GetProviderIdsFromMetadata(guids.ToArray());

            if (providerIds.ImdbId.HasValue())
            {
                existingContent.ImdbId = providerIds.ImdbId;
            }

            if (providerIds.TheMovieDb.HasValue())
            {
                existingContent.TheMovieDbId = providerIds.TheMovieDb;
            }

            if (providerIds.TheTvDb.HasValue())
            {
                // Lookup TheMovieDbId
                var findResult = await _movieApi.Find(providerIds.TheTvDb, ExternalSource.tvdb_id);

                var tvResult = findResult.tv_results.FirstOrDefault();
                if (tvResult != null)
                {
                    existingContent.TheMovieDbId = tvResult.id.ToString();
                }
                existingContent.TvDbId = providerIds.TheTvDb;
            }
        }