Пример #1
0
        /// <summary>
        /// Gets images from the image block
        /// </summary>
        /// <param name="type">The ImageUsageType type.</param>
        /// <param name="threadID">The thread MovieUniqueId.</param>
        /// <param name="id">The tmDB id</param>
        /// <returns>An image collection</returns>
        public BindingList <ImageDetailsModel> GetImages(ImageUsageType type, int threadID, string id)
        {
            var xml = this.GetHtml("getInfo", threadID, id);

            var output = new BindingList <ImageDetailsModel>();

            var xmlDoc = XDocument.Parse(xml);

            var tmdbType = string.Empty;

            switch (type)
            {
            case ImageUsageType.Poster:
                tmdbType = "poster";
                break;

            case ImageUsageType.Fanart:
                tmdbType = "backdrop";
                break;
            }

            var images = from m in xmlDoc.Descendants("image") where m.Attribute("type").Value == tmdbType select m;

            foreach (var image in images)
            {
                if (image.Attribute("size").Value == "mid" || image.Attribute("size").Value == "poster")
                {
                    var origional = new Uri(image.Attribute("url").Value);
                    var thumb     = new Uri(origional.ToString().Replace("-poster", "-thumb"));
                    var width     = image.Attribute("width").Value.ToInt();
                    var height    = image.Attribute("height").Value.ToInt();

                    var downloadItem = new DownloadItem
                    {
                        Type    = DownloadType.Binary,
                        Url     = thumb.ToString(),
                        Section = Section.Movies
                    };

                    Downloader.AddToBackgroundQue(downloadItem);

                    output.Add(
                        new ImageDetailsModel
                    {
                        Height   = height,
                        Width    = width,
                        UriFull  = origional,
                        UriThumb = thumb
                    });
                }
            }

            return(output);
        }
Пример #2
0
        /// <summary>
        /// Gets images from the image block
        /// </summary>
        /// <param name="type">The ImageUsageType type.</param>
        /// <param name="threadID">The thread MovieUniqueId.</param>
        /// <param name="id">The tmDB id</param>
        /// <returns>An image collection</returns>
        public BindingList <ImageDetailsModel> GetImages(ImageUsageType type, int threadID, string id)
        {
            var xml = this.GetHtml("getInfo", threadID, id);

            var output = new BindingList <ImageDetailsModel>();

            var xmlDoc = XDocument.Parse(xml);

            var tmdbType = string.Empty;

            var posterSize = string.Empty;
            var fanartSize = string.Empty;

            switch (type)
            {
            case ImageUsageType.Poster:
                tmdbType = "poster";

                switch (Settings.Get.Scraper.TmDBDownloadPosterSize)
                {
                case 0:
                    posterSize = "original";
                    break;

                case 1:
                    posterSize = "mid";
                    break;

                case 2:
                    posterSize = "cover";
                    break;

                case 3:
                    posterSize = "thumb";
                    break;
                }

                break;

            case ImageUsageType.Fanart:
                tmdbType = "backdrop";

                switch (Settings.Get.Scraper.TmDBDownloadFanartSize)
                {
                case 0:
                    fanartSize = "original";
                    break;

                case 1:
                    fanartSize = "poster";
                    break;

                case 2:
                    fanartSize = "w1280";
                    break;

                case 3:
                    fanartSize = "thumb";
                    break;
                }

                break;
            }

            var images = from m in xmlDoc.Descendants("image") where m.Attribute("type").Value == tmdbType select m;

            foreach (var image in images)
            {
                if (image.Attribute("size").Value == fanartSize || image.Attribute("size").Value == posterSize)
                {
                    var Original = new Uri(image.Attribute("url").Value);
                    var thumb    = Original.ToString();

                    if (thumb.Contains("-original"))
                    {
                        thumb = thumb.Replace("-original", "-thumb");
                    }
                    else if (thumb.Contains("-mid.jpg"))
                    {
                        thumb = thumb.Replace("-mid", "-thumb");
                    }
                    else if (thumb.Contains("-poster.jpg"))
                    {
                        thumb = thumb.Replace("-poster", "-thumb");
                    }

                    var width  = image.Attribute("width").Value.ToInt();
                    var height = image.Attribute("height").Value.ToInt();

                    var downloadItem = new DownloadItem
                    {
                        Type = DownloadType.Binary, Url = thumb.ToString(), Section = Section.Movies
                    };

                    Downloader.AddToBackgroundQue(downloadItem);

                    output.Add(
                        new ImageDetailsModel
                    {
                        Height = height, Width = width, UriFull = Original, UriThumb = new Uri(thumb)
                    });
                }
            }

            return(output);
        }
Пример #3
0
        /// <summary>
        /// Gets images from the image block
        /// </summary>
        /// <param name="type">The ImageUsageType type.</param>
        /// <param name="threadID">The thread MovieUniqueId.</param>
        /// <param name="id">The tmDB id</param>
        /// <returns>An image collection</returns>
        public BindingList<ImageDetailsModel> GetImages(ImageUsageType type, int threadID, string id)
        {
            var xml = this.GetHtml("getInfo", threadID, id);

            var output = new BindingList<ImageDetailsModel>();

            var xmlDoc = XDocument.Parse(xml);

            var tmdbType = string.Empty;

            switch (type)
            {
                case ImageUsageType.Poster:
                    tmdbType = "poster";
                    break;
                case ImageUsageType.Fanart:
                    tmdbType = "backdrop";
                    break;
            }

            var images = from m in xmlDoc.Descendants("image") where m.Attribute("type").Value == tmdbType select m;

            foreach (var image in images)
            {
                if (image.Attribute("size").Value == "mid" || image.Attribute("size").Value == "poster")
                {
                    var origional = new Uri(image.Attribute("url").Value);
                    var thumb = new Uri(origional.ToString().Replace("-poster", "-thumb"));
                    var width = image.Attribute("width").Value.ToInt();
                    var height = image.Attribute("height").Value.ToInt();

                    var downloadItem = new DownloadItem
                        {
                            Type = DownloadType.Binary, 
                            Url = thumb.ToString(), 
                            Section = Section.Movies
                        };

                    Downloader.AddToBackgroundQue(downloadItem);

                    output.Add(
                        new ImageDetailsModel
                            {
                                Height = height, 
                                Width = width, 
                                UriFull = origional, 
                                UriThumb = thumb
                            });
                }
            }

            return output;
        }