Ejemplo n.º 1
0
        private static Movie OldRename(DirectoryInfo dir, OmdbResult result)
        {
            string newFolderName =
                $"{result.Title} ({result.Year}) [{result.Runtime}] IMDB-{result.imdbRating} RT-{result.tomatoMeter}% ({result.tomatoRating})";

            Log($"For {dir.Name}, new name = {newFolderName}");
            try
            {
                string newPath = Path.Combine(dir.Parent.FullName, newFolderName);
                var    newDir  = new DirectoryInfo(newPath);
                var    movie   = newDir.GetMovie();
                string metaStr = Math.Abs(movie.MetaCritic) < Double.Epsilon
                    ? string.Empty
                    : $" Meta-{movie.MetaCritic}";
                string finalName = $"{movie.Score}, {newFolderName}{metaStr}";
                string finalPath = Path.Combine(dir.Parent.FullName, finalName);
                dir.MoveTo(finalPath);
                result.WritePlotToFile(new DirectoryInfo(finalPath));
                return(movie);
            }
            catch (Exception e)
            {
                Error(e);
                return(null);
            }
        }
Ejemplo n.º 2
0
        public void FromOmdb(OmdbResult omdb)
        {
            Title = omdb.Title;
            Year  = omdb.Year;
            double tmpRtMeter;

            if (double.TryParse(omdb.tomatoMeter, out tmpRtMeter))
            {
                RtFresh = tmpRtMeter;
            }
            double tmpRtRating;

            if (double.TryParse(omdb.tomatoRating, out tmpRtRating))
            {
                RtRating = tmpRtMeter;
            }
            double tmpMeta;

            if (Title.TryGetMeta(Year, out tmpMeta))
            {
                MetaCritic = tmpMeta;
            }
            int tmpEbert;

            if (EbertQuery.TryGetRating(Title, Year, out tmpEbert))
            {
                EbertRating = tmpEbert;
            }
        }
Ejemplo n.º 3
0
 private static bool GetOmdbResult(DirectoryInfo dir, out OmdbResult result)
 {
     result = default(OmdbResult);
     if (!dir.Search(out result))
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 4
0
        public static bool Search(this DirectoryInfo dir, out OmdbResult result)
        {
            result = default(OmdbResult);
            string name;
            string year;

            if (!dir.GetMovieName(out name))
            {
                Error($"Could not get movie name for {dir.Name}");
                return(false);
            }
            bool gotYear = dir.TryGetYear(out year);

            result = gotYear ? OmdbSearch.Query(name, year) : OmdbSearch.Query(name);
            if (result == default(OmdbResult) || Math.Abs(result.Score) < double.Epsilon)
            {
                Error($"Unable to get omdb result for {dir.Name}");
                return(false);
            }
            Log($"For dir {dir.Name} OMDB result = {result} ");
            return(true);
        }
Ejemplo n.º 5
0
 public Movie(OmdbResult omdb)
 {
     FromOmdb(omdb);
 }