Beispiel #1
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)
            {
                int.TryParse(content.TheMovieDbId, out var movieDbId);
                if (movieDbId <= 0)
                {
                    continue;
                }
                var info = await _movieApi.GetMovieInformationWithExtraInfo(movieDbId);

                if (info == null)
                {
                    continue;
                }
                try
                {
                    CreateMovieHtmlContent(sb, info);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    throw;
                }
                finally
                {
                    EndLoopHtml(sb);
                }
            }
        }
Beispiel #2
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);
                }
            }
        }
Beispiel #3
0
        private async Task ProcessPlexMovies(IQueryable <PlexServerContent> plexContentToSend, StringBuilder sb, string defaultLanguageCode)
        {
            int count   = 0;
            var ordered = plexContentToSend.OrderByDescending(x => x.AddedAt);

            foreach (var content in ordered)
            {
                int.TryParse(content.TheMovieDbId, out var movieDbId);
                if (movieDbId <= 0)
                {
                    continue;
                }
                var info = await _movieApi.GetMovieInformationWithExtraInfo(movieDbId, defaultLanguageCode);

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

                if (count == 2)
                {
                    count = 0;
                    sb.Append("</tr>");
                    sb.Append("<tr>");
                }
            }
        }
Beispiel #4
0
        private async Task ProcessMovies(ICollection <IMediaServerContent> plexContentToSend, string defaultLanguageCode)
        {
            int count   = 0;
            var ordered = plexContentToSend;

            foreach (var content in ordered)
            {
                int.TryParse(content.TheMovieDbId, out var movieDbId);
                if (movieDbId <= 0)
                {
                    _log.LogWarning($"{content.Title} does not have a TMDB ID, it won't be published.");
                    continue;
                }
                var info = await _movieApi.GetMovieInformationWithExtraInfo(movieDbId, defaultLanguageCode);

                var mediaurl = content.Url;
                if (info == null)
                {
                    _log.LogWarning($"TMDB does not know movie {content.Title}, it won't be published.");
                    continue;
                }
                try
                {
                    CreateMovieHtmlContent(info, mediaurl);
                    count += 1;
                }
                catch (Exception e)
                {
                    _log.LogError(e, "Error when Processing Movies {0}", info.Title);
                }
                finally
                {
                    EndLoopHtml();
                }

                if (count == 2)
                {
                    count = 0;
                    sb.Append("</tr>");
                    sb.Append("<tr>");
                }
            }
        }
Beispiel #5
0
        private async Task <string> GetImdbId(bool hasTheMovieDb, bool hasTvDbId, string title, string theMovieDbId, string tvDbId, RequestType type)
        {
            _log.LogInformation("The media item {0} does not have a ImdbId, searching for ImdbId", title);
            // Looks like TV Maze does not provide the moviedb id, neither does the TV endpoint on TheMovieDb
            if (hasTheMovieDb)
            {
                _log.LogInformation("The show {0} has TheMovieDbId but not ImdbId, searching for ImdbId", title);
                if (int.TryParse(theMovieDbId, out var id))
                {
                    switch (type)
                    {
                    case RequestType.TvShow:
                        var result = await _movieApi.GetTvExternals(id);

                        return(result.imdb_id);

                    case RequestType.Movie:
                        var r = await _movieApi.GetMovieInformationWithExtraInfo(id);

                        return(r.ImdbId);

                    default:
                        break;
                    }
                }
            }

            if (hasTvDbId && type == RequestType.TvShow)
            {
                _log.LogInformation("The show {0} has tvdbid but not ImdbId, searching for ImdbId", title);

                var result = await _movieApi.Find(tvDbId.ToString(), ExternalSource.tvdb_id);

                var movieDbId = result.tv_results.FirstOrDefault()?.id ?? 0;
                if (movieDbId != 0)
                {
                    var externalsResult = await _movieApi.GetTvExternals(movieDbId);

                    return(externalsResult.imdb_id);
                }
            }
            return(string.Empty);
        }