コード例 #1
0
        internal static string[] MatchXpathExpressionReturnAllMatches
            (string html, string xPathExpression)
        {


            var doc = new HtmlDocument();

            doc.LoadHtml(html);

            HtmlAgilityPack.HtmlNodeCollection htmlNodesCollection
                = doc.DocumentNode.SelectNodes
                    (xPathExpression);

            var matches = new List<string>();

            foreach (var htmlNode in htmlNodesCollection)
            {
                matches.Add(htmlNode.InnerText);

            }





            return matches.ToArray();

        }
コード例 #2
0
ファイル: TMDB.cs プロジェクト: hoeness2/mcebuddy2
        static public bool DownloadMovieDetails(VideoTags videoTags)
        {
            // The new v3 database is accessed via the TMDbLib API's
            try
            {
                TMDbClient client = new TMDbClient(MCEBUDDY_TMDB_APIKey);
                List<SearchMovie> movieSearch = new List<SearchMovie>();
                Movie movieMatch = null;

                // TODO: Add support for multiple language searches
                if (String.IsNullOrWhiteSpace(videoTags.imdbId)) // If dont' have a specific movieId specified, look up the movie details
                {
                    if (videoTags.OriginalBroadcastDateTime > GlobalDefs.NO_BROADCAST_TIME) // Release date narrow down
                    {
                        // The information is stored on the server using the network timezone
                        // So we assume that the show being converted was recorded locally and is converted locally so the timezones match
                        DateTime dt = videoTags.OriginalBroadcastDateTime.ToLocalTime();
                        movieSearch = client.SearchMovie(videoTags.Title.Trim().ToLower(), 0, true, dt.Year).Results;
                    }
                    else // Title Check
                        movieSearch = client.SearchMovie(videoTags.Title.Trim().ToLower(), 0, true, 0).Results;
                }
                else // Specific ID
                {
                    movieMatch = client.GetMovie(videoTags.imdbId); // We have a specific movie to work with
                }

                if (movieMatch == null) // If we haven't forced a movie match
                {
                    foreach (SearchMovie movieResult in movieSearch) // Cycle through all possible combinations
                    {
                        Movie movie = client.GetMovie(movieResult.Id);
                        List<AlternativeTitle> akaValues = null;
                        if (movie.AlternativeTitles != null)
                            akaValues = movie.AlternativeTitles.Titles;
                        bool akaMatch = false;
                        string title = videoTags.Title;
                        if (akaValues != null) // Check if there are any AKA names to match
                            akaMatch = akaValues.Any(s => (String.Compare(s.Title.Trim(), title.Trim(), CultureInfo.InvariantCulture, (CompareOptions.IgnoreSymbols | CompareOptions.IgnoreCase)) == 0 ? true : false));

                        // Get and match Movie name (check both titles and aka values)
                        if (String.Compare(movie.Title.Trim(), videoTags.Title.Trim(), CultureInfo.InvariantCulture, (CompareOptions.IgnoreSymbols | CompareOptions.IgnoreCase)) != 0) // ignore white space and special characters
                            if (String.Compare(movie.OriginalTitle.Trim(), videoTags.Title.Trim(), CultureInfo.InvariantCulture, (CompareOptions.IgnoreSymbols | CompareOptions.IgnoreCase)) != 0) // ignore white space and special characters
                                if (!akaMatch) // check for aka value matches
                                    continue; // No match in name

                        // If we got here, then we found a match
                        movieMatch = movie;
                        break; // We are done here
                    }
                }

                if (movieMatch != null) // We have a match
                {
                    if (!String.IsNullOrWhiteSpace(videoTags.imdbId)) // Match names only if the movie imdb id is not forced, else take what is returned by moviedb
                        videoTags.Title = movieMatch.Title; // Take what is forced for the imdb movie id

                    // Get Movie Id
                    videoTags.tmdbId = movieMatch.Id.ToString();

                    videoTags.IsMovie = true; // this is a movie

                    // Get Overview
                    string overview = movieMatch.Overview;
                    if (!String.IsNullOrWhiteSpace(overview) && String.IsNullOrWhiteSpace(videoTags.Description))
                        videoTags.Description = overview;

                    // Get original release date
                    if (movieMatch.ReleaseDate != null)
                    {
                        DateTime releaseDate = (DateTime)movieMatch.ReleaseDate;
                        if (releaseDate > GlobalDefs.NO_BROADCAST_TIME)
                            if ((videoTags.OriginalBroadcastDateTime <= GlobalDefs.NO_BROADCAST_TIME) || (videoTags.OriginalBroadcastDateTime.Date > releaseDate.Date)) // Sometimes the metadata from the video recordings are incorrect and report the recorded date (which is more recent than the release date) then use MovieDB dates, MovieDB Dates are more reliable than video metadata usually
                                videoTags.OriginalBroadcastDateTime = releaseDate; // MovieDB stores time in network (local) timezone
                    }

                    // Get Genres
                    List<string> genres = new List<string>();
                    foreach (Genre genre in movieMatch.Genres)
                    {
                        genres.Add(genre.Name);
                    }
                    if (genres.Count > 0)
                    {
                        if (videoTags.Genres != null)
                        {
                            if (videoTags.Genres.Length == 0)
                                videoTags.Genres = genres.ToArray();
                        }
                        else
                            videoTags.Genres = genres.ToArray();
                    }

                    // Download the banner file
                    client.GetConfig(); // First we need to get the config
                    VideoMetaData.DownloadBannerFile(videoTags, client.GetImageUrl("original", movieMatch.PosterPath).OriginalString); // Get bannerfile

                    return true; // home free, we're good
                }

                return false;
            }
            catch
            {
                return false;
            }
        }
コード例 #3
0
ファイル: TMDB.cs プロジェクト: hoeness2/mcebuddy2
        static public bool DownloadSeriesDetails(VideoTags videoTags, bool prioritizeMatchDate = false)
        {
            // The new v3 database is accessed via the TMDbLib API's
            try
            {
                TMDbClient client = new TMDbClient(MCEBUDDY_TMDB_APIKey);
                List<TvShowBase> showSearch = new List<TvShowBase>();

                // TODO: Add support for multiple language searches
                if (String.IsNullOrWhiteSpace(videoTags.tmdbId)) // If dont' have a specific movieId specified, look up the show details
                {
                    if (videoTags.OriginalBroadcastDateTime > GlobalDefs.NO_BROADCAST_TIME) // Release date narrow down
                    {
                        // The information is stored on the server using the network timezone
                        // So we assume that the show being converted was recorded locally and is converted locally so the timezones match
                        DateTime dt = videoTags.OriginalBroadcastDateTime.ToLocalTime();
                        showSearch = client.SearchTvShow(videoTags.Title.Trim().ToLower(), 0).Results;
                    }
                    else // Title Check
                        showSearch = client.SearchTvShow(videoTags.Title.Trim().ToLower(), 0).Results;
                }
                else // Specific ID
                {
                    TvShow showMatch = client.GetTvShow(int.Parse(videoTags.tmdbId)); // We have a specific show to work with

                    // First match by Episode name and then by Original broadcast date (by default prioritize match date is false)
                    if (!MatchSeriesInformation(client, videoTags, showMatch, prioritizeMatchDate))
                        return MatchSeriesInformation(client, videoTags, showMatch, !prioritizeMatchDate);
                    else
                        return true;
                }

                foreach (TvShowBase showResult in showSearch) // Cycle through all possible combinations
                {
                    TvShow show = client.GetTvShow(showResult.Id);
                    string title = videoTags.Title;

                    // Get and match Show name (check both titles and aka values)
                    if (String.Compare(show.Name.Trim(), videoTags.Title.Trim(), CultureInfo.InvariantCulture, (CompareOptions.IgnoreSymbols | CompareOptions.IgnoreCase)) != 0) // ignore white space and special characters
                        if (String.Compare(show.OriginalName.Trim(), videoTags.Title.Trim(), CultureInfo.InvariantCulture, (CompareOptions.IgnoreSymbols | CompareOptions.IgnoreCase)) != 0) // ignore white space and special characters
                            continue; // No match in name

                    // If we got here, then we found a match
                    // First match by Episode name and then by Original broadcast date (by default prioritize match date is false)
                    if (!MatchSeriesInformation(client, videoTags, show, prioritizeMatchDate))
                    {
                        if (MatchSeriesInformation(client, videoTags, show, !prioritizeMatchDate))
                            return true;

                        // Else we continue looping through the returned series looking for a match if nothing matches
                    }
                    else
                        return true;
                }

                return false;
            }
            catch
            {
                return false;
            }
        }