コード例 #1
0
 public static void AddDistinctPoster(this List<Poster> list, Poster newPoster)
 {
     if (list == null) return;
     bool add = true;
     foreach (Poster p in list)
     {
         if (p.Image.ToLower() == newPoster.Image.ToLower()) { add = false; continue; }
         string path;
         if (ImageUtil.LocalFileExists(p.Image, out path) && FileUtil.Compare(p.Image, newPoster.Image))
             add = false;
     }
     if (add) list.Add(newPoster);
 }
コード例 #2
0
        void imgBox_MouseMove(object sender, MouseEventArgs e)
        {
            if (drag)
            {
                ImageBox img = sender as ImageBox;
                img.BringToFront();
                int index = (int)((img.Left - picsPanel.AutoScrollPosition.X )/ 230);

                img.Location = new Point(e.X + img.Left - xLoc, 0);
                if (img.index != index)
                {
                    ImageBox ib = FindImgBoxByIndex(index);
                    if (ib != null)
                    {
                        Poster tmp = new Poster(SelectedItem.BackdropImagePaths[img.index]);
                        SelectedItem.BackdropImagePaths[img.index] = new Poster(SelectedItem.BackdropImagePaths[index]);
                        SelectedItem.BackdropImagePaths[index] = tmp;
                        ib.index = img.index;
                        ib.Location = new Point((230 * ib.index) + picsPanel.AutoScrollPosition.X, 0);
                        img.index = index;
                        HasChanged();
                    }
                }
            }
        }
コード例 #3
0
ファイル: Plugin.cs プロジェクト: arthurwayne/metavideoeditor
        public Item GetSeriesDetails(Item item)
        {
            DataProviderId dp = item.ProvidersId.Find(p => p.Name == this.Name);
            if (dp == null) return null;
            if (!LoadSeriesDetails(dp.Id))
                return null;
            Item series = new Item();
            series.ProvidersId = new List<DataProviderId> { dp };

            XmlDocument doc = new XmlDocument();
            doc.Load(Path.Combine(Path.Combine(XmlPath, dp.Id), lang + ".xml"));
            if (doc == null) return null;

            series.Title = series.SeriesName = doc.SafeGetString("//SeriesName");
            series.Overview = doc.SafeGetString("//Overview");
            series.Rating = doc.SafeGetSingle("//Rating", 0, 10);
            series.RunningTime = doc.SafeGetInt32("//Runtime");
            series.MPAARating = doc.SafeGetString("//ContentRating");

            string g = doc.SafeGetString("//Genre");
            if (g != null)
            {
                string[] genres = g.Trim('|').Split('|');
                if (g.Length > 0)
                {
                    series.Genres = new List<string>();
                    series.Genres.AddRange(genres);
                }
            }

            XmlDocument actorsDoc = new XmlDocument();
            actorsDoc.Load(Path.Combine(Path.Combine(XmlPath, dp.Id), "actors.xml"));
            if (actorsDoc != null)
            {
                series.Actors = new List<Actor>();
                foreach (XmlNode actorNode in actorsDoc.SelectNodes("//Actor"))
                {
                    string name = actorNode.SafeGetString("Name");
                    if (!string.IsNullOrEmpty(name))
                    {
                        Actor actor = new Actor();
                        actor.Name = name;
                        actor.Role = actorNode.SafeGetString("Role");
                        actor.ImagePath = BannerUrl + actorNode.SafeGetString("Image");
                        if (series.Actors == null) series.Actors = new List<Actor>();
                        series.Actors.Add(actor);
                    }
                }
            }
            else
            {
                string actors = doc.SafeGetString("//Actors");
                if (actors != null)
                {
                    string[] a = actors.Trim('|').Split('|');
                    if (a.Length > 0)
                    {
                        series.Actors = new List<Actor>();
                        series.Actors.AddRange(
                            a.Select(actor => new Actor { Name = actor }));
                    }
                }
            }

            XmlDocument banners = new XmlDocument();
            banners.Load(Path.Combine(Path.Combine(XmlPath, dp.Id), "banners.xml"));
            if (banners != null)
            {
                series.BackdropImagePaths = new List<Poster>();
                series.ImagesPaths = new List<Poster>();
                series.BannersPaths = new List<Poster>();
                foreach (XmlNode node in banners.SelectNodes("//Banner"))
                {
                    if (node.SafeGetString("BannerType") == "poster")
                    {
                        Poster poster = new Poster();
                        string path = node.SafeGetString("BannerPath");
                        string thumb = node.SafeGetString("ThumbnailPath");
                        if (!string.IsNullOrEmpty(thumb))
                            poster.Thumb = BannerUrl + thumb;
                        poster.Image = BannerUrl + path;

                        if (!string.IsNullOrEmpty(path))
                            series.ImagesPaths.Add(poster);
                    }
                    else if (node.SafeGetString("BannerType") == "fanart")
                    {
                        Poster poster = new Poster();
                        poster.Checked = false;
                        string path = node.SafeGetString("BannerPath");
                        string thumb = node.SafeGetString("ThumbnailPath");
                        string size = node.SafeGetString("BannerType2");
                        if (size.Contains("x"))
                        {
                            poster.width = size.Substring(0, size.IndexOf("x"));
                            poster.height = size.Substring(size.IndexOf("x") + 1);
                        }
                        if (!string.IsNullOrEmpty(thumb))
                            poster.Thumb = BannerUrl + thumb;
                        poster.Image = BannerUrl + path;
                        if (!string.IsNullOrEmpty(path))
                            series.BackdropImagePaths.Add(poster);
                    }
                    else if (node.SafeGetString("BannerType") == "series")
                    {
                        Poster poster = new Poster();
                        string path = node.SafeGetString("BannerPath");
                        poster.Image = BannerUrl + path;
                        if (!string.IsNullOrEmpty(path))
                            series.BannersPaths.Add(poster);
                    }
                }

            }

            return series;
        }
コード例 #4
0
ファイル: Plugin.cs プロジェクト: arthurwayne/metavideoeditor
        public Item GetSeasonDetails(Item item)
        {
            DataProviderId dp = item.ProvidersId.Find(p => p.Name == this.Name);
            if (dp == null) return null;
            if (!LoadSeriesDetails(dp.Id))
                return null;
            Item season = new Item();
            season.ProvidersId = new List<DataProviderId> { dp };

            if (string.IsNullOrEmpty(item.SeasonNumber)) return null;
            season.SeasonNumber = item.SeasonNumber;
            season.Title = "Saison " + season.SeasonNumber;
            season.SeriesName = item.SeriesName;

            XmlDocument banners = new XmlDocument();
            banners.Load(Path.Combine(Path.Combine(XmlPath, dp.Id), "banners.xml"));
            if (banners == null) return null;

            season.ImagesPaths = new List<Poster>();
            season.BannersPaths = new List<Poster>();
            foreach (XmlNode node in banners.SelectNodes("//Banner[BannerType='season'][Season='" + season.SeasonNumber + "']"))
            {
                if (node.SafeGetString("BannerType2") == "season")
                {
                    Poster poster = new Poster();
                    string path = node.SafeGetString("BannerPath");
                    poster.Image = BannerUrl + path;
                    if (!string.IsNullOrEmpty(path))
                        season.ImagesPaths.Add(poster);
                }
                else if (node.SafeGetString("BannerType2") == "seasonwide")
                {
                    Poster poster = new Poster();
                    string path = node.SafeGetString("BannerPath");
                    poster.Image = BannerUrl + path;
                    if (!string.IsNullOrEmpty(path))
                        season.BannersPaths.Add(poster);
                }
            }

            return season;
        }
コード例 #5
0
ファイル: plugin.cs プロジェクト: arthurwayne/metavideoeditor
        public override Item Fetch(Item item)
        {
            Item movie = new Item();
            movie.ProvidersId = item.ProvidersId;
            DataProviderId dp = movie.ProvidersId.Find(p => p.Name == this.Name);
            if (dp == null) return null;
            movie.ProvidersId = new List<DataProviderId> { dp };
            XmlDocument InfosDoc = Helper.Fetch(string.Format(GetInfo, lang, APIKey, dp.Id));
            if (InfosDoc == null)
                return null;

            //Titre
            movie.Title = InfosDoc.SafeGetString("//name");

            //Url
            dp.Url = InfosDoc.SafeGetString("//url");

            //Année
            string release = InfosDoc.SafeGetString("//released");
            if (release != null && release.Length >= 4)
                movie.Year = Int32.Parse(release.Substring(0, 4));

            //Equipe
            movie.Crew = new List<CrewMember>();
            foreach (XmlNode n in InfosDoc.SelectNodes("//cast/person[@job!='Actor']"))
            {
                movie.Crew.Add(new CrewMember { Name = n.Attributes["name"].InnerText, Activity = n.Attributes["job"].InnerText });
            }

            //Résumé
            movie.Overview = InfosDoc.SafeGetString("//overview");

            //TagLine
            string tagline = InfosDoc.SafeGetString("//tagline");
            if (!string.IsNullOrEmpty(tagline))
                movie.TagLines = new List<string> { tagline };

            //Durée
            try { movie.RunningTime = Int32.Parse(InfosDoc.SafeGetString("//runtime")); }
            catch { }

            //Trailer
            string trailer = InfosDoc.SafeGetString("trailer");
            if (!string.IsNullOrEmpty(trailer))
                movie.TrailerFiles = new List<string> { trailer };

            //Pays
            foreach (XmlNode n in InfosDoc.SelectNodes("//countries/country"))
            {
                if (movie.Countries == null) movie.Countries = new List<string>();
                movie.Countries.Add(n.Attributes["name"].InnerText);
            }

            //Genre
            movie.Genres = new List<string>();
            foreach (XmlNode n in InfosDoc.SelectNodes("//categories/category[@type='genre']"))
            {
                    movie.Genres.Add(n.Attributes["name"].InnerText);
            }

            //Vignettes
            movie.ImagesPaths = new List<Poster>();
            foreach (XmlNode n in InfosDoc.SelectNodes("//images/image[@type='poster']"))
            {
                string id = n.Attributes["id"].InnerText;
                if (!movie.ImagesPaths.Exists(ip => ip.Id == id))
                    movie.ImagesPaths.Add(new Poster { Id = id });
                if (n.Attributes["size"].InnerText == "original")
                {
                    movie.ImagesPaths[movie.ImagesPaths.FindIndex(ip => ip.Id == id)].Image = n.Attributes["url"].InnerText;
                }
                else if (n.Attributes["size"].InnerText == "thumb")
                {
                    movie.ImagesPaths[movie.ImagesPaths.FindIndex(ip => ip.Id == id)].Thumb = n.Attributes["url"].InnerText;
                }
            }

            //Backdrop
            movie.BackdropImagePaths = new List<Poster>();
            foreach (XmlNode n in InfosDoc.SelectNodes("//images/image[@type='backdrop']"))
            {
                string id = n.Attributes["id"].InnerText;
                if (n.Attributes["size"].InnerText == "original")
                {
                    int size = 0;
                    Int32.TryParse(n.Attributes["width"].InnerText, out size);
                    if (size >= Config.Instance.MinBackdropWidth)
                    {
                        Poster poster = new Poster();
                        poster.Id = id;
                        poster.Checked = false;
                        poster.Image = n.Attributes["url"].InnerText;
                        movie.BackdropImagePaths.Add(poster);
                    }
                }
                else if (n.Attributes["size"].InnerText == "thumb" && movie.BackdropImagePaths.Exists(p => p.Id == id))
                {
                    movie.BackdropImagePaths[movie.BackdropImagePaths.FindIndex(ip => ip.Id == id)].Thumb = n.Attributes["url"].InnerText;
                }

            }
            if (movie.BackdropImagePaths.Count > 0)
            {
                for (int i = 0; i < Math.Min(movie.BackdropImagePaths.Count, Config.Instance.MaxBdSaved); i++)
                {
                    movie.BackdropImagePaths[i].Checked = true;
                }
            }

            //Note
            movie.Rating = InfosDoc.SafeGetSingle("//rating", -1, 10);

            //MPAA
            movie.MPAARating = InfosDoc.SafeGetString("//certification");

            // Studios
            movie.Studios = new List<string>();
            foreach (XmlNode n in InfosDoc.SelectNodes("//studios/studio"))
            {
                movie.Studios.Add(n.Attributes["name"].InnerText);
            }

            //Acteurs
            movie.Actors = null;
            foreach (XmlNode n in InfosDoc.SelectNodes("//cast/person[@job='Actor']"))
            {
                if (movie.Actors == null)
                    movie.Actors = new List<Actor>();
                string name = n.Attributes["name"].InnerText;
                string role = n.Attributes["character"].InnerText;
                if (!string.IsNullOrEmpty(name))
                {
                    Actor actor = new Actor();
                    actor.Name = name;
                    actor.Role = role;
                    string ActorImg = n.Attributes["thumb"].InnerText;
                    if (!string.IsNullOrEmpty(ActorImg) && !ActorImg.EndsWith("Actor_Unknow.png"))
                        actor.ImagePath = ActorImg;
                    movie.Actors.Add(actor);
                }
            }

            return movie;
        }
コード例 #6
0
 //Constructor
 public Poster(Poster p)
 {
     this.Checked = p.Checked;
     this.height = p.height;
     this.Id = p.Id;
     this.Image = p.Image;
     this.Thumb = p.Thumb;
     this.width = p.width;
 }
コード例 #7
0
ファイル: Plugin.cs プロジェクト: arthurwayne/metavideoeditor
 public override Item Read(Item item)
 {
     Item i = new Item();
     string poster = FindImage("folder", item.MetadataLocation);
     if (!string.IsNullOrEmpty(poster))
     {
         if (i.ImagesPaths == null) i.ImagesPaths = new List<Poster>();
         Poster p = new Poster();
         p.Image = poster;
         p.Checked = true;
         try
         {
             Image img = Image.FromFile(poster);
             p.width = ((int)img.Width).ToString();
             p.height = ((int)img.Height).ToString();
         }
         catch { }
         i.ImagesPaths.AddDistinctPoster(p);
     }
     return i;
 }
コード例 #8
0
ファイル: Plugin.cs プロジェクト: arthurwayne/metavideoeditor
        public override Item Fetch(Item item)
        {
            Item movie = new Item();
            movie.ProvidersId = item.ProvidersId;
            DataProviderId dp = movie.ProvidersId.Find(p => p.Name == this.Name || p.Name == "AlloCine");
            if (dp == null) return null;
            movie.ProvidersId = new List<DataProviderId>{dp};
            XmlDocument InfosDoc = Helper.Fetch(string.Format(GetInfo, UsernameEnc(), PasswordEnc(), PluginOptions.Instance.Language, XbmcKey, dp.Id));
            if (InfosDoc == null)
                return null;

            //Id
            string allocine = InfosDoc.SafeGetString("//id_allocine");
            if (!string.IsNullOrEmpty(allocine)) movie.ProvidersId.Add(new DataProviderId
            {
                Name = "AlloCine",
                Id = allocine,
                Url = "http://www.allocine.fr/film/fichefilm_gen_cfilm=" + allocine + ".html"
            });
            string imdb = InfosDoc.SafeGetString("//id_imdb");
            if (!string.IsNullOrEmpty(imdb)) movie.ProvidersId.Add(new DataProviderId
            {
                Name = "Imdb",
                Id = "tt0" + imdb,
                Url = "http://www.imdb.com/title/tt0" + imdb
            });

            //Titre
            movie.Title = CleanAllocineTitle(InfosDoc.SafeGetString("//title"));

            //Titre original
            movie.OriginalTitle = CleanAllocineTitle(InfosDoc.SafeGetString("//originaltitle"));

            //Url
            dp.Url = InfosDoc.SafeGetString("//url");

            //Année
            string release = InfosDoc.SafeGetString("//year");
            if (release != null && release.Length == 4)
                movie.Year = Int32.Parse(release);

            //Producteur
            movie.Crew = new List<CrewMember>();
            foreach (XmlNode n in InfosDoc.SelectNodes("//directors/director"))
            {
                movie.Crew.Add(new CrewMember { Name = n.InnerText, Activity = "Producteur" });
            }

            //Résumé
            movie.Overview = InfosDoc.SafeGetString("//plot");

            //TagLine
            movie.TagLines = new List<string>{ InfosDoc.SafeGetString("//tagline")};

            //Durée
            try { movie.RunningTime = Int32.Parse(InfosDoc.SafeGetString("//runtime")); }
            catch { }

            //Trailer
            foreach (XmlNode n in InfosDoc.SelectNodes("//trailers/trailer"))
            {
                if (movie.TrailerFiles == null) movie.TrailerFiles = new List<string>();
                if (!string.IsNullOrEmpty(n.InnerText))
                    movie.TrailerFiles.Add(n.InnerText);
            }

            //Pays
            foreach (XmlNode n in InfosDoc.SelectNodes("//countries/country"))
            {
                if (movie.Countries == null) movie.Countries = new List<string>();
                if (!string.IsNullOrEmpty(n.InnerText))
                    movie.Countries.Add(n.InnerText);
            }

            //Genre
            movie.Genres = new List<string>();
            foreach (XmlNode n in InfosDoc.SelectNodes("//genres/genre"))
            {
                if (!string.IsNullOrEmpty(n.InnerText))
                    movie.Genres.Add(n.InnerText);
            }

            //Vignettes
            movie.ImagesPaths = new List<Poster>();
            foreach (XmlNode n in InfosDoc.SelectNodes("//images/image[@type='Poster']"))
            {
                string id = n.Attributes["id"].InnerText;
                if (!movie.ImagesPaths.Exists(ip => ip.Id == id))
                    movie.ImagesPaths.Add(new Poster { Id = id });
                if (n.Attributes["size"].InnerText == "original")
                {
                    movie.ImagesPaths[movie.ImagesPaths.FindIndex(ip => ip.Id == id)].Image = n.Attributes["url"].InnerText;
                    movie.ImagesPaths[movie.ImagesPaths.FindIndex(ip => ip.Id == id)].width = n.Attributes["width"].InnerText;
                    movie.ImagesPaths[movie.ImagesPaths.FindIndex(ip => ip.Id == id)].height = n.Attributes["height"].InnerText;
                }
                else if (n.Attributes["size"].InnerText == "preview")
                {
                    movie.ImagesPaths[movie.ImagesPaths.FindIndex(ip => ip.Id == id)].Thumb = n.Attributes["url"].InnerText;
                }
            }

            //Backdrop
            movie.BackdropImagePaths = new List<Poster>();
            foreach (XmlNode n in InfosDoc.SelectNodes("//images/image[@type='Fanart']"))
            {
                string id = n.Attributes["id"].InnerText;
                if (n.Attributes["size"].InnerText == "original")
                {
                    int size = 0;
                    Int32.TryParse(n.Attributes["width"].InnerText, out size);
                    if (size >= Config.Instance.MinBackdropWidth)
                    {
                        Poster poster = new Poster();
                        poster.Id = id;
                        poster.Checked = false;
                        poster.Image = n.Attributes["url"].InnerText;
                        poster.width = n.Attributes["width"].InnerText;
                        poster.height = n.Attributes["height"].InnerText;
                        movie.BackdropImagePaths.Add(poster);
                    }
                }
                else if (n.Attributes["size"].InnerText == "thumb" && movie.BackdropImagePaths.Exists(p => p.Id == id))
                {
                    movie.BackdropImagePaths[movie.BackdropImagePaths.FindIndex(ip => ip.Id == id)].Thumb = n.Attributes["url"].InnerText;
                }

            }
            if (movie.BackdropImagePaths.Count > 0)
            {
                for (int i = 0; i < Math.Min(movie.BackdropImagePaths.Count, Config.Instance.MaxBdSaved); i++)
                {
                    movie.BackdropImagePaths[i].Checked = true;
                }
            }

            //Note
            float? rating = null;
            if (PluginOptions.Instance.Rating != "moyenne des trois")
            {
                try
                {
                    rating = (float)double.Parse(InfosDoc.SelectSingleNode("//ratings/rating[@type='" + PluginOptions.Instance.Rating + "']").InnerText);
                }
                catch { }
            }
            else
            {
                double vote = 0; double note = 0;
                foreach (XmlNode n in InfosDoc.SelectNodes("//ratings/rating"))
                {
                    double V; double N;
                    try
                    {
                        N = double.Parse(n.InnerText, new CultureInfo("fr-FR"));
                        V = Int32.Parse(n.Attributes["votes"].InnerText);
                    }
                    catch { continue; }
                    vote = vote + V;
                    note = note + (N * V);
                }
                if (vote > 0)
                    rating = (float)Math.Round((double)(note / vote), 1);
            }
            movie.Rating = rating;

            // Studios
            movie.Studios = new List<string>();
            foreach (XmlNode n in InfosDoc.SelectNodes("//studios/studio"))
            {
                if (!string.IsNullOrEmpty(n.InnerText))
                    movie.Studios.Add(n.InnerText);
            }

            //Acteurs
            movie.Actors = null;
            foreach (XmlNode n in InfosDoc.SelectNodes("//casting/person"))
            {
                if (movie.Actors == null)
                    movie.Actors = new List<Actor>();
                string name = n.Attributes["name"].InnerText;
                string role = n.Attributes["character"].InnerText;
                if (!string.IsNullOrEmpty(name))
                {
                    Actor actor = new Actor();
                    actor.Name = name;
                    actor.Role = role;
                    string ActorImg = n.Attributes["thumb"].InnerText;
                    if (!string.IsNullOrEmpty(ActorImg) && !ActorImg.EndsWith("Actor_Unknow.png"))
                        actor.ImagePath = ActorImg;
                    movie.Actors.Add(actor);
                }
            }

            return movie;
        }