Пример #1
0
        private bool ProcessWallpaper(string Link, MovieInfo movieInfo, string id)
        {
            bool _result = false;

            string _page = Helpers.GetPage(Link);

            if (!string.IsNullOrEmpty(_page))
            {
                Regex _reg = new Regex(WallpapersRegex, RegexOptions.IgnoreCase | RegexOptions.Singleline);
                if (_reg.IsMatch(_page))
                {
                    foreach (Match _m2 in _reg.Matches(_page))
                    {
                        string _thumbUrl    = string.Format("http://www.outnow.ch{0}", _m2.Groups["Backdrop"].Value);
                        string _originalUrl = null;

                        if (!string.IsNullOrEmpty(movieInfo.Name) && !string.IsNullOrEmpty(_thumbUrl))
                        {
                            BackdropItem _bi = new BackdropItem(id, movieInfo.IMDBID, this.CollectorName, _thumbUrl, _originalUrl);
                            _bi.GetOriginalUrl = new BackdropBase.GetOriginalUrlHandler(GetWallpaperLink);
                            BackdropsList.Add(_bi);
                        }
                    }
                }
            }

            return(_result);
        }
Пример #2
0
        protected override bool ProcessVisualSection(string Link, MovieInfo movieInfo, string id)
        {
            bool _result = false;

            string _page = Helpers.GetPage(Link);

            if (!string.IsNullOrEmpty(_page))
            {
                Regex _reg = new Regex(BackdropsRegex, RegexOptions.IgnoreCase | RegexOptions.Singleline);
                if (_reg.IsMatch(_page))
                {
                    foreach (Match _m2 in _reg.Matches(_page))
                    {
                        string _thumbUrl    = string.Format("http://www.outnow.ch{0}", _m2.Groups["Backdrop"].Value);
                        string _originalUrl = _thumbUrl.Replace("_small.", ".");

                        if (!string.IsNullOrEmpty(movieInfo.Name) && !string.IsNullOrEmpty(_thumbUrl) && !string.IsNullOrEmpty(_originalUrl))
                        {
                            BackdropsList.Add(new BackdropItem(id, movieInfo.IMDBID, this.CollectorName, _thumbUrl, _originalUrl));
                        }
                    }
                }
            }

            return(_result);
        }
Пример #3
0
        private bool ProcessVisualSection(MovieInfo movieInfo, string id)
        {
            bool _result = false;

            // first posters
            string _page = Helpers.GetPage(string.Format("http://www.kinopoisk.ru/level/17/film/{0}", id), null, Encoding.GetEncoding("Windows-1251"), "", true, true);

            if (!string.IsNullOrEmpty(_page))
            {
                if (_page.Contains("<title>Архив постеров на КиноПоиск.ru</title>"))
                {
                    // movie has no posters
                    return(_result);
                }
                Regex _reg = new Regex(PostersRegex, RegexOptions.IgnoreCase | RegexOptions.Multiline);
                if (_reg.IsMatch(_page))
                {
                    for (int _i = 0; _i <= (_reg.Matches(_page).Count - 1); _i++)
                    {
                        string _imageUrl = string.Format("{0}", _reg.Matches(_page)[_i].Groups["Cover"].Value.Replace("sm_", ""));

                        ResultMovieItem _movieItem = new ResultMovieItem(id, movieInfo.Name, _imageUrl, this.CollectorName);
                        _movieItem.CollectorMovieUrl = string.Format("http://www.kinopoisk.ru/level/1/film/{0}/sr/1/", id);
                        _movieItem.MovieInfo         = movieInfo;

                        ResultsList.Add(_movieItem);
                        _result = true;
                    }
                }
            }

            //then backdrops
            _page = Helpers.GetPage(string.Format("http://www.kinopoisk.ru/level/13/film/{0}", id), null, Encoding.GetEncoding("Windows-1251"), "", true, true);

            if (!string.IsNullOrEmpty(_page))
            {
                Regex _reg = new Regex(BackdropsRegex, RegexOptions.IgnoreCase | RegexOptions.Singleline);
                if (_reg.IsMatch(_page))
                {
                    foreach (Match _m2 in _reg.Matches(_page))
                    {
                        string _thumbUrl    = string.Format("http://www.kinopoisk.ru/{0}", _m2.Groups["Backdrop"].Value);
                        string _originalUrl = _thumbUrl.Replace("sm_", "");

                        if (!string.IsNullOrEmpty(movieInfo.Name) && !string.IsNullOrEmpty(_thumbUrl) && !string.IsNullOrEmpty(_originalUrl))
                        {
                            string _width  = _m2.Groups["Width"].Value;
                            string _height = _m2.Groups["Height"].Value;

                            BackdropItem _bi = new BackdropItem(id, movieInfo.IMDBID, this.CollectorName, _thumbUrl, _originalUrl);
                            _bi.SetSize(_width, _height);
                            BackdropsList.Add(_bi);
                        }
                    }
                }
            }

            return(_result);
        }
Пример #4
0
 private bool GetResults(IEnumerable <TmdbMovie> searchResults)
 {
     foreach (var item in searchResults)
     {
         if (item == null)
         {
             continue;
         }
         if (FileManager.CancellationPending)
         {
             return(ResultsList.Count != 0);
         }
         // get movie info
         MovieInfo movieInfo = GetMovieInfo(item);
         if (string.IsNullOrEmpty(movieInfo.IMDBID) && !IsValidYear(movieInfo.Year))
         {
             continue;
         }
         // having the tmdbid, call getimages
         var imagesData = api.GetMovieImages(item.id, "ALL");
         // posters
         if (imagesData.posters.Any())
         {
             foreach (var poster in imagesData.posters.OrderByDescending(x => x.vote_average))
             {
                 var imageUrl = string.Format("{0}{1}{2}", configuration.images.base_url, "original", poster.file_path);
                 AddResultItem(item.id.ToString(CultureInfo.InvariantCulture), movieInfo, imageUrl);
             }
         }
         else
         {
             // no poster found, add anyway the movie without image
             if (!string.IsNullOrEmpty(movieInfo.Name))
             {
                 AddResultItem(item.id.ToString(CultureInfo.InvariantCulture), movieInfo, null);
             }
         }
         // backdrops
         if (imagesData.backdrops.Any())
         {
             foreach (var backdrop in imagesData.backdrops.OrderByDescending(x => x.vote_average))
             {
                 var thumbUrl    = string.Format("{0}{1}{2}", configuration.images.base_url, configuration.images.backdrop_sizes.First(), backdrop.file_path);
                 var originalUrl = string.Format("{0}{1}{2}", configuration.images.base_url, "original", backdrop.file_path);
                 var bi          = new BackdropItem(item.id.ToString(CultureInfo.InvariantCulture), item.imdb_id, CollectorName, thumbUrl, originalUrl);
                 bi.SetSize(backdrop.width.ToString(CultureInfo.InvariantCulture), backdrop.height.ToString(CultureInfo.InvariantCulture));
                 BackdropsList.Add(bi);
             }
         }
     }
     return(ResultsList.Count != 0);
 }
Пример #5
0
        protected override bool ProcessVisualSection(string relLink, MovieInfo movieInfo, string id)
        {
            bool _result = false;

            if (!string.IsNullOrEmpty(relLink))
            {
                string _page = Helpers.GetPage(string.Format("http://www.filmaffinity.com{0}", relLink), Encoding.GetEncoding("ISO-8859-1"));
                if (!string.IsNullOrEmpty(_page))
                {
                    Regex _reg = new Regex(PostersRegex, RegexOptions.IgnoreCase | RegexOptions.Multiline);
                    if (_reg.IsMatch(_page))
                    {
                        for (int _i = 0; _i <= (_reg.Matches(_page).Count - 1); _i++)
                        {
                            string          _imageUrl  = string.Format("http://pics.filmaffinity.com/{0}", _reg.Matches(_page)[_i].Groups[1].Value);
                            ResultMovieItem _movieItem = new ResultMovieItem(id, movieInfo.Name, _imageUrl, this.CollectorName);
                            _movieItem.MovieInfo = movieInfo;

                            ResultsList.Add(_movieItem);
                            _result = true;
                        }
                    }

                    _reg = new Regex(BackdropsRegex, RegexOptions.IgnoreCase | RegexOptions.Multiline);
                    if (_reg.IsMatch(_page))
                    {
                        foreach (Match _m2 in _reg.Matches(_page))
                        {
                            string _originalUrl = string.Format("http://pics.filmaffinity.com/{0}", _m2.Groups[1].Value);
                            string _thumbUrl    = _originalUrl.Replace("-large.", "-small.");

                            if (!string.IsNullOrEmpty(movieInfo.Name) && !string.IsNullOrEmpty(_thumbUrl) && !string.IsNullOrEmpty(_originalUrl))
                            {
                                BackdropsList.Add(new BackdropItem(id, movieInfo.IMDBID, this.CollectorName, _thumbUrl, _originalUrl));
                            }
                        }
                    }
                }
            }

            return(_result);
        }
Пример #6
0
        protected override bool ProcessVisualSection(string relLink, MovieInfo movieInfo, string id)
        {
            bool _result = false;

            List <string> _cache = new List <string>();

            // process backdrops here
            //string _backdropsLink = relLink.Insert(relLink.LastIndexOf('/'), "-Screenshots");
            string _backdropsLink = relLink + "#Screenshots";
            string _backdropPage  = Helpers.GetPage(_backdropsLink, Encoding.UTF8, true);

            if (!string.IsNullOrEmpty(_backdropPage))
            {
                Regex _reg = new Regex(VisualSectionRegex, RegexOptions.IgnoreCase);
                foreach (Match _m2 in _reg.Matches(_backdropPage))
                {
                    string _originalUrl = null;
                    string _thumbUrl    = _m2.Groups["Link"].Value;
                    if (!string.IsNullOrEmpty(_thumbUrl))
                    {
                        _originalUrl = _thumbUrl.Insert(_thumbUrl.LastIndexOf('.'), "_large");
                    }

                    // avoid duplicates returned by regex
                    if (!_cache.Contains(_thumbUrl))
                    {
                        if (!string.IsNullOrEmpty(movieInfo.Name) && !string.IsNullOrEmpty(_thumbUrl) && !string.IsNullOrEmpty(_originalUrl))
                        {
                            BackdropItem _bi = new BackdropItem(id, null, this.CollectorName, _thumbUrl, _originalUrl);
                            _bi.SetSize("1280", "720");
                            BackdropsList.Add(_bi);
                            _result = true;
                            _cache.Add(_thumbUrl);
                        }
                    }
                }
            }

            return(_result);
        }
Пример #7
0
        public override bool GetResults(string keywords, string imdbID, bool skipImages)
        {
            bool _result = false;

            if (!string.IsNullOrEmpty(imdbID))
            {
                keywords = imdbID;
            }
            else
            {
                keywords = keywords.Replace(" ", "+");
            }

            string input = Helpers.GetPage(string.Format("http://www.cinemagia.ro/cauta/?q={0}&new=1", keywords));

            if (!string.IsNullOrEmpty(input))
            {
                Regex regex = new Regex(SearchPageRegex);
                if (regex.IsMatch(input))
                {
                    int count = regex.Matches(input).Count;
                    foreach (Match match in regex.Matches(input))
                    {
                        if (FileManager.CancellationPending)
                        {
                            return(ResultsList.Count != 0);
                        }

                        if (!match.Value.Contains("noimg_main"))
                        {
                            string sUrl = match.Groups["Link"].Value;
                            if (sUrl != "")
                            {
                                string _id      = string.Empty;
                                Regex  _idRegex = new Regex("-(?<ID>[01023456789]*?)/");
                                if (_idRegex.IsMatch(sUrl))
                                {
                                    _id = _idRegex.Matches(sUrl)[0].Groups["ID"].Value;
                                }
                                string _title = HttpUtility.HtmlDecode(match.Groups["Title"].Value);
                                _title = Helpers.StripHTML(_title);

                                if (!string.IsNullOrEmpty(_title))
                                {
                                    // now it worths to get MovieInfo once
                                    // try to get MovieInfo
                                    MovieInfo _movieInfo = GetMovieInfo(sUrl);

                                    if (!IsValidYear(_movieInfo.Year))
                                    {
                                        continue;
                                    }

                                    // got title and base url, go to postere
                                    string _postersUrl  = string.Format("{0}postere/?toate=1", sUrl);
                                    string _galleryPage = Helpers.GetPage(_postersUrl);
                                    if (!string.IsNullOrEmpty(_galleryPage))
                                    {
                                        // extract links to individual posters
                                        Regex _galleryRegex = new Regex("src=\"(?<Link>[^\"]*?/resize/[^\"]*?l-thumbnail_gallery[^\"]*?)\"");
                                        if (_galleryRegex.IsMatch(_galleryPage))
                                        {
                                            foreach (Match _poster in _galleryRegex.Matches(_galleryPage))
                                            {
                                                string _imageUrl = _poster.Groups["Link"].Value.Replace("resize/", "");
                                                _imageUrl = _imageUrl.Replace("-thumbnail_gallery", "");
                                                if (!string.IsNullOrEmpty(_title) && !string.IsNullOrEmpty(_imageUrl))
                                                {
                                                    ResultMovieItem _movieItem = new ResultMovieItem(_id, _title, _imageUrl, CollectorName);
                                                    _movieItem.CollectorMovieUrl = sUrl;
                                                    _movieItem.MovieInfo         = _movieInfo;

                                                    ResultsList.Add(_movieItem);
                                                    _result = true;
                                                }
                                            }
                                        }
                                    } // if _galleryPage

                                    // try to get backdrops
                                    // got title and base url, go to imagini
                                    string _backdropsUrl  = string.Format("{0}imagini/?toate=1", sUrl);
                                    string _backdropsPage = Helpers.GetPage(_backdropsUrl);
                                    if (!string.IsNullOrEmpty(_backdropsPage))
                                    {
                                        // extract links to individual thumbnails
                                        Regex _galleryRegex = new Regex("src=\"(?<Link>[^\"]*?/resize/[^\"]*?l-thumbnail_gallery[^\"]*?)\"");
                                        if (_galleryRegex.IsMatch(_backdropsPage))
                                        {
                                            foreach (Match _backdrop in _galleryRegex.Matches(_backdropsPage))
                                            {
                                                string _originalUrl = _backdrop.Groups["Link"].Value.Replace("resize/", "");
                                                _originalUrl = _originalUrl.Replace("-thumbnail_gallery", "");

                                                if (!string.IsNullOrEmpty(_title) && !string.IsNullOrEmpty(_originalUrl))
                                                {
                                                    string _thumbUrl = _originalUrl.Replace("img/db/movie", "img/resize/db/movie");
                                                    if (!string.IsNullOrEmpty(_thumbUrl))
                                                    {
                                                        _thumbUrl = _thumbUrl.Insert(_thumbUrl.LastIndexOf('.'), "-imagine");
                                                    }
                                                    BackdropsList.Add(new BackdropItem(_id, _movieInfo.IMDBID, this.CollectorName, _thumbUrl, _originalUrl));
                                                }
                                            }
                                        }
                                    } // if _backdropsPage
                                }
                            }
                        }
                    }
                }
            }
            return(_result);
        }
Пример #8
0
        protected override MovieInfo GetMovieInfo(string input)
        {
            // input is the id of the movie
            var _result = new MovieInfo();

            if (string.IsNullOrEmpty(input))
            {
                return(_result);
            }
            var id = -1;

            if (!int.TryParse(input, out id))
            {
                return(_result);
            }

            var api   = new AlloCineApi();
            var movie = api.MovieGetInfo(id);

            if (movie.Error != null)
            {
                return(_result);
            }
            try
            {
                _result.OriginalTitle = movie.OriginalTitle;

                string _title = movie.Title;
                _result.Name = string.IsNullOrEmpty(_title) ? _result.OriginalTitle : _title;

                _result.Year = movie.ProductionYear;

                if (movie.Release != null)
                {
                    _result.ReleaseDate = movie.Release.ReleaseDate;
                }

                if (movie.Trailer != null)
                {
                    _result.Trailer = movie.Trailer.Href;
                }

                _result.Countries = movie.NationalityList.Select(x => x.Value).ToList();

                _result.Genre = movie.GenreList.Select(x => x.Value).ToList();

                //_result.Cast = movie.CastMemberList.Take(Math.Max(movie.CastMemberList.Count, 5)).Select(x => x.Person.Name).ToList();
                _result.Cast = movie.CastingShort.Actors.Split(',').ToTrimmedList();

                _result.Director = movie.CastingShort.Directors.Split(',').ToTrimmedList();

                int _minutes = 0;
                Int32.TryParse(movie.Runtime, out _minutes);
                _result.Runtime = Math.Abs(_minutes / 60).ToString();

                if (movie.Statistics != null)
                {
                    string _r = movie.Statistics.UserRating;
                    if (!string.IsNullOrEmpty(_r))
                    {
                        _result.Rating = _r;
                        _result.Rating = (_result.dRating * 2).ToString();
                    }
                }
                _result.Overview = movie.SynopsisShort;
                if (string.IsNullOrEmpty(_result.Overview))
                {
                    _result.Overview = movie.Synopsis;
                }
                else
                {
                    _result.Comments = movie.Synopsis;
                }

                // backdrops
                movie.MediaList
                .Where(x => x.Type != null && x.Type.Code == "31006" && x.Thumbnail != null)
                .Select(x => x.Thumbnail.Href).ToList()
                .ForEach(x =>
                {
                    var _bi = new BackdropItem(input, null, this.CollectorName, x, x);
                    BackdropsList.Add(_bi);
                });
            }
            catch (Exception ex)
            {
                Loggy.Logger.DebugException("Allocine: ", ex);
            }
            return(_result);
        }