private bool ProcessPage(string input, string id, bool skipImages, string link, string title, string originalTitle) { bool _result = false; if (!string.IsNullOrEmpty(input)) { MovieInfo _movieInfo = GetMovieInfo(input); if (skipImages) { if (!string.IsNullOrEmpty(_movieInfo.Name)) { ResultMovieItem _movieItem = new ResultMovieItem(id, _movieInfo.Name, null, this.CollectorName); _movieItem.MovieInfo = _movieInfo; _movieItem.CollectorMovieUrl = link; ResultsList.Add(_movieItem); _result = true; } } else { // process the VisualSection bool _res = ProcessVisualSection(_movieInfo, id); if (_res) { _result = true; } } } return(_result); }
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); }
private void AddResultItem(string id, MovieInfo movie, string imageUrl) { var movieItem = new ResultMovieItem(id, movie.Name, imageUrl, CollectorName); movieItem.CollectorMovieUrl = string.Format("http://www.themoviedb.org/movie/{0}", id); movieItem.MovieInfo = movie; ResultsList.Add(movieItem); }
public ThreadParams(ResultMovieItem movie, DispatcherObject dispatcher, SetImageDataHandler handler) : this(string.Empty, dispatcher, handler) { Movie = movie; if (Movie != null) { ImageUrl = Movie.ImageUrl; } }
private void AddToResults(WorkItem workItem) { if (workItem != null) { ResultMovieItem _movieItem = new ResultMovieItem(workItem.GetHashCode().ToString(), workItem.Title, workItem.Cover, this.CollectorName); _movieItem.MovieInfo = GetMovieInfo(workItem.Node); this.ResultsList.Add(_movieItem); if (!string.IsNullOrEmpty(workItem.Background)) { this.BackdropsList.Add(new BackdropItem(workItem.GetHashCode().ToString(), workItem.IMDBId, this.CollectorName, workItem.Background, workItem.Background)); } } }
public override bool GetResults(string keywords, string imdbID, bool skipImages) { bool _result = false; m_IMDbId = imdbID; try { m_EpisodeData = EpisodeData.GetEpisodeData(this.CurrentMovie.Filename); } catch { } try { // don't start querying if there's no episode number detected if (!string.IsNullOrEmpty(m_EpisodeData.Episode) && GetMirrors()) { if (GetSeries(keywords)) { foreach (KeyValuePair <int, TheTVDBSerieItem> _item in m_Series) { if (FileManager.CancellationPending) { return(ResultsList.Count != 0); } if (skipImages) { string _id = _item.Value.ID.ToString(); ResultMovieItem _movieItem = new ResultMovieItem(_id, _item.Value.Title, null, CollectorName); _movieItem.MovieInfo = _item.Value.MovieInfo; SetCurrentEpisodeRelatedInfo(Convert.ToInt32(_id), _movieItem.MovieInfo); _movieItem.CollectorMovieUrl = !string.IsNullOrEmpty(_id) ? string.Format("http://thetvdb.com/index.php?tab=series&id={0}", _id) : null; ResultsList.Add(_movieItem); } else { GetEpisodes(_item.Value); GetPosters(_item.Value); } _result = true; } } } } catch { } return(_result); }
void browser_LoadCompleted(object sender, System.Windows.Navigation.NavigationEventArgs e) { WebBrowser _browser = sender as WebBrowser; if (_browser != null) { ResultMovieItem _movie = _browser.Tag as ResultMovieItem; // trigger dataready event if (_movie != null && _movie.DataReadyEvent != null) { _movie.DataReadyEvent.Set(); } } }
public static void PopulateMyGalleryResults() { ResultsListBox.MyGalleryResults = new ObservableCollection <ResultItemBase>(); List <FileInfo> _temp = new FilesCollector().CollectFiles(FileManager.GetGalleryFolder(), false, ResultsListBox.GalleryImagesSupported).ToList <FileInfo>(); if (_temp != null && _temp.Count != 0) { foreach (FileInfo _info in _temp) { ResultMovieItem _titem = new ResultMovieItem(null, Path.GetFileNameWithoutExtension(_info.Name), _info.FullName, BaseCollector.GALLERY); ResultsListBox.MyGalleryResults.Add(_titem); } } }
private bool ProcessPage(string input, string id, bool skipImages, string link, string title, string originalTitle) { bool _result = false; if (!string.IsNullOrEmpty(input)) { MovieInfo _movieInfo = GetMovieInfo(input); if (!string.IsNullOrEmpty(this.IMDBID) && !string.IsNullOrEmpty(_movieInfo.IMDBID) && this.IMDBID != _movieInfo.IMDBID) { return(false); } if (string.IsNullOrEmpty(id)) { Match _match = Regex.Match(input, IDRegex, RegexOptions.Singleline | RegexOptions.IgnoreCase); if (_match.Success) { id = _match.Groups["ID"].Value; } } // port.hu has NO POSTER //string _imageUrl = string.Format("http://www.sratim.co.il/movies/images/{0}", GetItem(input, CoverRegex, 1)); _movieInfo.Name = string.IsNullOrEmpty(_movieInfo.Name) ? title : _movieInfo.Name; _movieInfo.OriginalTitle = string.IsNullOrEmpty(_movieInfo.OriginalTitle) ? _movieInfo.Name : _movieInfo.OriginalTitle; if (!string.IsNullOrEmpty(_movieInfo.Name)) { ResultMovieItem _movieItem = new ResultMovieItem(id, _movieInfo.Name, null, this.CollectorName); _movieItem.MovieInfo = _movieInfo; _movieItem.CollectorMovieUrl = link; ResultsList.Add(_movieItem); _result = true; } if (!skipImages && !string.IsNullOrEmpty(VisualSectionRegex)) { // process the VisualSection if any bool _res = ProcessVisualSection(GetItem(input, VisualSectionRegex, 1), _movieInfo, id); if (_res) { _result = true; } } } return(_result); }
void CacheImage(object sender, EventArgs e) { ResultMovieItem _movie = sender as ResultMovieItem; if (_movie != null) { //// start caching results... this.MainWindow.Dispatcher.BeginInvoke((Action) delegate { WebBrowser _browser = (this.MainWindow as ThumbGenMainWindow).TheWebBrowser; _browser.Tag = _movie; _browser.LoadCompleted += new System.Windows.Navigation.LoadCompletedEventHandler(browser_LoadCompleted); _browser.Navigate(new Uri(string.Format("{0}/filmplakat.php?id={1}", Host, _movie.ImageId), UriKind.RelativeOrAbsolute)); }, DispatcherPriority.Send); } }
private bool ProcessPage(string input, string id, bool skipImages, string link, string title, string originalTitle) { bool _result = false; if (!string.IsNullOrEmpty(input)) { MovieInfo _movieInfo = GetMovieInfo(input); if (!string.IsNullOrEmpty(this.IMDBID) && !string.IsNullOrEmpty(_movieInfo.IMDBID) && this.IMDBID != _movieInfo.IMDBID) { return(false); } string _imageUrl = string.Format("http://sratim.co.il/{0}", GetCoverLink(input)); if (string.IsNullOrEmpty(_movieInfo.Name)) { _movieInfo.Name = title; } if (string.IsNullOrEmpty(_movieInfo.OriginalTitle)) { _movieInfo.OriginalTitle = originalTitle; } if (!string.IsNullOrEmpty(_movieInfo.Name)) { ResultMovieItem _movieItem = new ResultMovieItem(id, _movieInfo.Name, _imageUrl, this.CollectorName); _movieItem.MovieInfo = _movieInfo; _movieItem.CollectorMovieUrl = link; ResultsList.Add(_movieItem); _result = true; } if (!skipImages && !string.IsNullOrEmpty(VisualSectionRegex)) { // process the VisualSection if any bool _res = ProcessVisualSection(GetItem(input, VisualSectionRegex, 1), _movieInfo, id); if (_res) { _result = true; } } } return(_result); }
private bool ProcessPage(string input, string id, bool skipImages, string link, string title, string originalTitle) { bool _result = false; if (!string.IsNullOrEmpty(input)) { MovieInfo _movieInfo = GetMovieInfo(input); if (!string.IsNullOrEmpty(this.IMDBID) && !string.IsNullOrEmpty(_movieInfo.IMDBID) && this.IMDBID != _movieInfo.IMDBID) { return(false); } string _imageUrl = string.Format("http://www.outnow.ch{0}", GetItem(input, CoverRegex, "Cover", RegexOptions.Singleline | RegexOptions.IgnoreCase)); _imageUrl = Regex.Replace(_imageUrl, "_[^\\.]+.", ".", RegexOptions.Singleline | RegexOptions.IgnoreCase); if (!string.IsNullOrEmpty(_movieInfo.Name)) { ResultMovieItem _movieItem = new ResultMovieItem(id, _movieInfo.Name, _imageUrl, this.CollectorName); _movieItem.MovieInfo = _movieInfo; _movieItem.CollectorMovieUrl = link; ResultsList.Add(_movieItem); _result = true; } if (!skipImages) { // process the VisualSection if any bool _res = ProcessVisualSection(link + "Bilder/", _movieInfo, id); if (_res) { _result = true; } //_res = ProcessWallpaper(link + "Wallpapers/", _movieInfo, id); //if (_res || _result) //{ // _result = true; //} } } return(_result); }
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); }
private bool ProcessPage(string input, string id, bool skipImages, string link, string title, string imageId) { bool _result = false; if (!string.IsNullOrEmpty(input)) { string _imageUrl = string.Format("{0}/{1}", Host, GetItem(input, CoverRegex, "Cover", RegexOptions.Singleline | RegexOptions.IgnoreCase)); string _s = Helpers.GetPage(_imageUrl, null, Encoding.Default, "", true, false); ResultMovieItem _movieItem = new ResultMovieItem(id, title, _imageUrl, this.CollectorName); _movieItem.CollectorMovieUrl = link; _movieItem.ImageId = imageId; _movieItem.DataQuerying = new EventHandler(CacheImage); _movieItem.DataReadyEvent = new ManualResetEvent(false); ResultsList.Add(_movieItem); _result = true; } return(_result); }
private bool ProcessPage(string input, string id, bool skipImages, string link, string title, string originalTitle) { bool _result = false; if (!string.IsNullOrEmpty(input)) { MovieInfo _movieInfo = GetMovieInfo(input); if (!string.IsNullOrEmpty(this.IMDBID) && !string.IsNullOrEmpty(_movieInfo.IMDBID) && this.IMDBID != _movieInfo.IMDBID) { return(false); } string _imageUrl = GetItem(input, CoverRegex, "Cover"); _imageUrl = Regex.Replace(_imageUrl, "cache/[^/]+/", ""); _movieInfo.Name = string.IsNullOrEmpty(_movieInfo.Name) ? title : _movieInfo.Name; _movieInfo.OriginalTitle = string.IsNullOrEmpty(_movieInfo.OriginalTitle) ? originalTitle : _movieInfo.OriginalTitle; if (!string.IsNullOrEmpty(_movieInfo.Name)) { ResultMovieItem _movieItem = new ResultMovieItem(id, _movieInfo.Name, _imageUrl, this.CollectorName); _movieItem.MovieInfo = _movieInfo; _movieItem.CollectorMovieUrl = link; ResultsList.Add(_movieItem); _result = true; } if (!skipImages && !string.IsNullOrEmpty(VisualSectionRegex)) { // process the VisualSection if any bool _res = ProcessVisualSection(GetItem(input, VisualSectionRegex, 1), _movieInfo, id); if (_res) { _result = true; } } } return(_result); }
private bool GetMovie(string mmid) { bool _result = false; try { int _filmId = Int32.Parse(mmid); if (!string.IsNullOrEmpty(mmid)) { FilmDetail _details = m_apiProxy.RetrieveDetails(getSessionKey(), _filmId); if (_details != null) { MovieInfo _movieInfo = GetMovieInfo(mmid); if (!IsValidYear(_movieInfo.Year)) { return(false); } string _imageUrl = string.IsNullOrEmpty(_details.thumbnail) ? null : _details.thumbnail.Replace("/thumbs/", "/"); if (_imageUrl != null) { var matches = Regex.Matches(_imageUrl, "(?<A>http://www.moviemeter.nl/images/cover/\\d+/\\d+.)([^\\.]*\\.)(?<B>\\w+)"); if (matches.Count != 0) { _imageUrl = matches[0].Groups["A"].Value + matches[0].Groups["B"].Value; } } ResultMovieItem _movieItem = new ResultMovieItem(mmid, _details.title, _imageUrl, this.CollectorName); _movieItem.CollectorMovieUrl = _details.url; _movieItem.MovieInfo = _movieInfo; ResultsList.Add(_movieItem); _result = true; } } } catch { } return(_result); }
protected virtual bool ProcessPage(string input, string id, bool skipImages) { bool _result = false; if (!string.IsNullOrEmpty(input)) { MovieInfo _movieInfo = GetMovieInfo(input); if (!IsValidYear(_movieInfo.Year)) { return(false); } string _title = string.IsNullOrEmpty(_movieInfo.Name) ? GetItem(input, TitleRegex, 1) : _movieInfo.Name; string _imageUrl = GetItem(input, CoverRegex, 1); string _id = string.IsNullOrEmpty(id) ? GetItem(input, IDRegex, 1) : id; if (!string.IsNullOrEmpty(_title)) { ResultMovieItem _movieItem = new ResultMovieItem(_id, _title, _imageUrl, this.CollectorName); _movieItem.MovieInfo = _movieInfo; ResultsList.Add(_movieItem); _result = true; } if (!skipImages) { // process the VisualSection if any bool _res = ProcessVisualSection(GetItem(input, VisualSectionRegex, 1), _movieInfo, _id); if (_res) { _result = true; } } } return(_result); }
private bool ProcessPage(string input, string id, bool skipImages, string link) { bool _result = false; if (!string.IsNullOrEmpty(input)) { MovieInfo _movieInfo = GetMovieInfo(input); if (!string.IsNullOrEmpty(_movieInfo.Year) && !string.IsNullOrEmpty(this.Year) && (_movieInfo.Year != this.Year)) { return(false); } string _title = _movieInfo.Name; string _imageUrl = GetItem(input, CoverRegex, "Cover"); if (!string.IsNullOrEmpty(_title)) { ResultMovieItem _movieItem = new ResultMovieItem(id, _title, _imageUrl, this.CollectorName); _movieItem.MovieInfo = _movieInfo; _movieItem.CollectorMovieUrl = link; ResultsList.Add(_movieItem); _result = true; } if (!skipImages && !string.IsNullOrEmpty(VisualSectionRegex)) { // process the VisualSection if any bool _res = ProcessVisualSection(GetItem(input, VisualSectionRegex, 1), _movieInfo, id); if (_res) { _result = true; } } } return(_result); }
private bool ProcessPage(string input, string id, bool skipImages, string link, string title) { bool _result = false; if (!string.IsNullOrEmpty(input)) { MovieInfo _movieInfo = GetMovieInfo(input); if (!IsValidYear(_movieInfo.Year)) { return(false); } string _imageUrl = string.Format("http://images.blu-ray.com/movies/covers/{0}_front.jpg", id); if (!string.IsNullOrEmpty(_movieInfo.Name)) { ResultMovieItem _movieItem = new ResultMovieItem(id, _movieInfo.Name, _imageUrl, this.CollectorName); _movieItem.MovieInfo = _movieInfo; _movieItem.CollectorMovieUrl = link; ResultsList.Add(_movieItem); _result = true; } if (!skipImages && !string.IsNullOrEmpty(VisualSectionRegex)) { // process the VisualSection if any bool _res = ProcessVisualSection(link, _movieInfo, id); if (_res) { _result = true; } } } return(_result); }
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); }
public override bool GetResults(string keywords, string imdbID, bool skipImages) { bool _result = false; // create a WCF Amazon ECS client BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport); binding.MaxReceivedMessageSize = int.MaxValue; AWSECommerceServicePortTypeClient client = new AWSECommerceServicePortTypeClient( binding, new EndpointAddress(TargetUrl)); // add authentication to the ECS client client.ChannelFactory.Endpoint.Behaviors.Add(new AmazonSigningEndpointBehavior(accessKeyId, secretKey)); // prepare an ItemSearch request ItemSearchRequest request = new ItemSearchRequest(); //request.Count = "1"; request.Condition = ThumbGen.Amazon.ECS.Condition.All; request.SearchIndex = this.SearchIndex; //request.Title = title; request.Keywords = keywords;//title.Replace(" ", "%20"); request.ResponseGroup = new string[] { "Small", "Images" }; ItemSearch itemSearch = new ItemSearch(); itemSearch.Request = new ItemSearchRequest[] { request }; itemSearch.AWSAccessKeyId = accessKeyId; itemSearch.AssociateTag = associatedTag; // issue the ItemSearch request ItemSearchResponse response = null; try { response = client.ItemSearch(itemSearch); } catch { return(_result); } if (response == null) { response = client.ItemSearch(itemSearch); } if (response != null) { // prepare the ResultsList if (response.Items[0] != null && response.Items[0].Item != null) { foreach (Item item in response.Items[0].Item) { if (FileManager.CancellationPending) { return(ResultsList.Count != 0); } string _imageUrl = item.LargeImage == null ? string.Empty : item.LargeImage.URL; if (!string.IsNullOrEmpty(_imageUrl)) { ResultMovieItem _movieItem = new ResultMovieItem(null, item.ItemAttributes.Title, _imageUrl, CollectorName); _movieItem.MovieInfo = GetMovieInfo(item); ResultsList.Add(_movieItem); } } _result = true; } } return(_result); }
private bool ProcessPage(string input, string inputIMDBID, bool skipImages) { bool _result = false; if (!string.IsNullOrEmpty(input)) { string _imdbid = nfoHelper.ExtractIMDBId(input); if (!string.IsNullOrEmpty(inputIMDBID) && !string.IsNullOrEmpty(_imdbid) && string.Compare(_imdbid, inputIMDBID) != 0) { return(_result); } if (!string.IsNullOrEmpty(inputIMDBID) && string.IsNullOrEmpty(_imdbid)) { return(_result); } if (!string.IsNullOrEmpty(inputIMDBID) && !string.IsNullOrEmpty(_imdbid) && string.Compare(_imdbid, inputIMDBID) == 0) { m_MatchedByIMDBId = true; } MovieInfo _info = new MovieInfo(); Match _match = null; string _regex = @"<title>(?<Title>[^/^\(]*)/? (?<OriginalTitle>[^\(]*)"; _info.Name = GetItem(input, _regex, "Title"); if (!string.IsNullOrEmpty(_info.Name)) { _info.OriginalTitle = GetItem(input, _regex, "OriginalTitle"); if (string.IsNullOrEmpty(_info.OriginalTitle)) { _match = Regex.Match(input, @"/flag_[^>]+>.*?<h3>(?<1>[^<]+)", RegexOptions.IgnoreCase | RegexOptions.Singleline); if (_match.Success) { _info.OriginalTitle = _match.Groups[1].Value; } } _info.Year = GetItem(input, ", (?<Year>\\d{4}),", "Year"); if (string.IsNullOrEmpty(_info.Year)) { _match = Regex.Match(input, @",\s(?<1>\d{4}),", RegexOptions.IgnoreCase | RegexOptions.Multiline); if (_match.Success) { _info.Year = _match.Groups[1].Value; } } _match = Regex.Match(input, "<h2 class=\"average\">(?<Rating>[0-9]+)%</h2>", RegexOptions.Multiline | RegexOptions.IgnoreCase); if (_match.Success) { string _r = _match.Groups["Rating"].Value.Replace(",", ".").Trim(); double _dr = 0d; if (!string.IsNullOrEmpty(_r) && Double.TryParse(_r, out _dr)) { _info.Rating = (_dr / 10).ToString("F2"); } } _match = Regex.Match(input, @",\s\d{4},\s(?<1>\d*?)\smin", RegexOptions.Multiline | RegexOptions.IgnoreCase); if (_match.Success) { _info.Runtime = _match.Groups[1].Value; } _match = Regex.Match(input, "alt=\"Odrážka\"\\s+class=\"[^\"]+\"/>(?<1>.*?)<", RegexOptions.IgnoreCase | RegexOptions.Singleline); if (_match.Success) { _info.Overview = _match.Groups[1].Value.Replace("<p>", "").Replace("<strong>", "").Replace("</strong>", "").Replace("<br />", ""). Replace("</p>", "").Replace("<span class=\"source\">", "").Replace("</span>", "").Replace(" ", "").Trim('\n').Trim('\t'); } string[] _genres = null; _match = Regex.Match(input, "<p class=\"genre\">(?<Genre>[^<]+)</p", RegexOptions.IgnoreCase | RegexOptions.Multiline); if (_match.Success) { _genres = _match.Groups[1].Value.Split('/'); if (_genres != null && _genres.Count() != 0) { _info.Genre = _genres.ToTrimmedList(); } } string _imageUrl = null; _match = Regex.Match(input, "(?<Cover>http://img\\.csfd\\.cz/posters/\\d+/\\d+[^\\.]+.jpg)", RegexOptions.IgnoreCase | RegexOptions.Multiline); if (_match.Success) { _imageUrl = _match.Groups[1].Value; } _info.IMDBID = _imdbid; string _id = null; _match = Regex.Match(input, "href=\"/film/(?<1>[0-9]*)-", RegexOptions.IgnoreCase | RegexOptions.Multiline); if (_match.Success) { _id = _match.Groups[0].Value; } if (string.IsNullOrEmpty(_id)) { _id = Helpers.GetUniqueFilename(""); } if (!IsValidYear(_info.Year)) { return(false); } if (!string.IsNullOrEmpty(_info.Name)) { ResultMovieItem _movieItem = new ResultMovieItem(_id, _info.Name, _imageUrl, this.CollectorName); _movieItem.MovieInfo = _info; _movieItem.MovieInfo.Name = _info.Name; if (string.IsNullOrEmpty(_movieItem.MovieInfo.IMDBID)) { _movieItem.MovieInfo.IMDBID = inputIMDBID; } ResultsList.Add(_movieItem); _result = true; } } } return(_result); }
private bool DoProcessing(string _link, string _id, string _title, string _year) { bool _result = false; if (!string.IsNullOrEmpty(_link)) { string _gallery = Helpers.GetPage(_link); // process the groups Regex _groupReg = new Regex("<a href=\"(/poster/[^\"]*)\">", RegexOptions.IgnoreCase); if (!string.IsNullOrEmpty(_gallery)) { if (string.IsNullOrEmpty(_title)) // when methid is called having the imdbid, so it goes directly to the Gallery page { _title = Regex.Match(_gallery, "<span itemprop=\"name\">(?<Title>[^<]+)</span>").Groups["Title"].Value; _year = Regex.Match(_gallery, "<span itemprop=\"copyrightYear\">(?<Year>[^<]+)</span>").Groups["Year"].Value; } if (string.IsNullOrEmpty(_title)) { return(_result); } foreach (Match gmatch in _groupReg.Matches(_gallery)) { string _glink = this.Host + gmatch.Groups[1].Value; string _groupGallery = Helpers.GetPage(_glink); if (!string.IsNullOrEmpty(_groupGallery)) { var posterLink = Regex.Match(_groupGallery, "Poster\" src=\"(?<Cover>[^\"]+)\"").Groups["Cover"].Value; var lang = Regex.Match(_groupGallery, "class=\"icon\" src=\"(?<Lang>/images/flags/[^\\.]+\\.png)").Groups["Lang"].Value; if (!string.IsNullOrEmpty(posterLink)) { var _movieItem = new ResultMovieItem(_id, _title, posterLink, CollectorName); _movieItem.CollectorMovieUrl = _link; _movieItem.MovieInfo = new MovieInfo(); _movieItem.MovieInfo.IMDBID = "tt" + _id; _movieItem.MovieInfo.Name = _title; _movieItem.MovieInfo.Year = _year; _movieItem.LanguageImageUrl = !string.IsNullOrEmpty(lang) ? Host + lang : string.Empty; ResultsList.Add(_movieItem); _result = true; } } } Regex _galReg = new Regex("<a href=\"/poster/[^\\\"]*\">[^\"]*<img src=\"(http://www.movieposterdb.com/posters[^\"]*)\"(?:[\\w\\W])*?<img src=\"([^\\\"]*)", RegexOptions.Multiline | RegexOptions.IgnoreCase); // now extract all posters that have no group, so we can build directly the link to the target poster foreach (Match match2 in _galReg.Matches(_gallery)) { // group 1 = small poster link // group 2 = link to language flag string _imageUrl = match2.Groups[1].Value.Replace("/t_", "/l_").Replace("/s_", "/l_"); string langUrl = match2.Groups[2].Value; // if the lang url is not .png then it's not language, wrong capture, skip it if (!langUrl.EndsWith(".png")) { continue; } ResultMovieItem _movieItem = new ResultMovieItem(_id, _title, _imageUrl, CollectorName); _movieItem.MovieInfo = new MovieInfo(); _movieItem.MovieInfo.IMDBID = "tt" + _id; _movieItem.MovieInfo.Name = _title; _movieItem.MovieInfo.Year = _year; _movieItem.CollectorMovieUrl = _link; _movieItem.LanguageImageUrl = langUrl; ResultsList.Add(_movieItem); _result = true; } } } return(_result); }
private bool GetMovieDetails(string movieId, bool onlyInfo, out MovieInfo movieInfo) { bool _result = false; movieInfo = null; if (!string.IsNullOrEmpty(movieId)) { XmlDocument _docDetails = new XmlDocument(); try { _docDetails.Load(this.GetInfoUrl(movieId)); } catch { } XmlNode _movie = _docDetails.SelectSingleNode("//movie"); if (_movie != null) { MovieInfo _movieInfo = GetMovieInfo(_movie); movieInfo = _movieInfo; if (!onlyInfo) { // get posters if (_movie != null) { XmlNodeList _images = _movie.SelectNodes("//image[@type='Poster' and @size='original']"); if (_images.Count != 0) { foreach (XmlNode _image in _images) { string _imageUrl = Helpers.GetAttributeFromXmlNode(_image, "url"); ResultMovieItem _movieItem = new ResultMovieItem(movieId, _movieInfo.Name, _imageUrl, this.CollectorName); _movieItem.CollectorMovieUrl = Helpers.GetValueFromXmlNode(_movie, "url"); _movieItem.MovieInfo = _movieInfo; ResultsList.Add(_movieItem); _result = true; } } else { ResultMovieItem _movieItem = new ResultMovieItem(movieId, _movieInfo.Name, null, this.CollectorName); _movieItem.CollectorMovieUrl = Helpers.GetValueFromXmlNode(_movie, "url"); _movieItem.MovieInfo = _movieInfo; ResultsList.Add(_movieItem); _result = true; } // get fanart/backdrops XmlNodeList _fanarts = _movie.SelectNodes("//image[@type='Fanart' and @size='preview']"); if (_fanarts.Count != 0) { foreach (XmlNode _fanart in _fanarts) { string _fanartId = Helpers.GetAttributeFromXmlNode(_fanart, "id"); if (!string.IsNullOrEmpty(_fanartId)) { string _thumbUrl = Helpers.GetAttributeFromXmlNode(_movie.SelectSingleNode(string.Format("//image[@id='{0}' and @size='preview']", _fanartId)), "url"); XmlNode _originalNode = _movie.SelectSingleNode(string.Format("//image[@id='{0}' and @size='original']", _fanartId)); string _originalUrl = Helpers.GetAttributeFromXmlNode(_originalNode, "url"); string _width = _originalNode != null ? _originalNode.Attributes["width"].Value : null; string _height = _originalNode != null ? _originalNode.Attributes["height"].Value : null; if (!string.IsNullOrEmpty(_thumbUrl) && !string.IsNullOrEmpty(_originalUrl)) { BackdropItem _bi = new BackdropItem(movieId, _movieInfo.IMDBID, this.CollectorName, _thumbUrl, _originalUrl); _bi.SetSize(_width, _height); this.BackdropsList.Add(_bi); } } } } } } } } return(_result); }
public override bool GetResults(string keywords, string imdbID, bool skipImages) { bool _result = false; keywords = keywords.Replace(" ", "+"); string input = Helpers.GetPage(string.Format("http://alpacine.com/buscar/?buscar={0}", keywords)); if (!string.IsNullOrEmpty(input)) { string _reg = "href=\"(?<Link>/pelicula/[^\"]*?)\">(?<Title>.*?)</"; Regex regex = new Regex(_reg); if (regex.IsMatch(input)) { int count = regex.Matches(input).Count; foreach (Match match in regex.Matches(input)) { if (FileManager.CancellationPending) { return(ResultsList.Count != 0); } string sUrl = match.Groups["Link"].Value; if (sUrl != "") { string _id = sUrl.Substring(10, sUrl.Length - 10 - 1); string _title = match.Groups["Title"].Value; _title = Helpers.StripHTML(_title); if (!string.IsNullOrEmpty(_title)) { // get movie info MovieInfo _movieInfo = GetMovieInfo(_id); if (!IsValidYear(_movieInfo.Year)) { continue; } if (skipImages) { if (!string.IsNullOrEmpty(_title)) { ResultMovieItem _movieItem = new ResultMovieItem(_id, _title, null, CollectorName); _movieItem.CollectorMovieUrl = string.Format("{0}{1}", Host, sUrl); _movieItem.MovieInfo = _movieInfo; ResultsList.Add(_movieItem); _result = true; } } else { string _gallery = Helpers.GetPage(string.Format("{0}{1}carteles/", Host, sUrl)); if (!string.IsNullOrEmpty(_gallery)) { string _reg2 = "<a\\shref=\"(?<1>/cartel/.*?)\"\\starget"; Regex _regex2 = new Regex(_reg2); if (_regex2.IsMatch(_gallery)) { foreach (Match _galleryMatch in _regex2.Matches(_gallery)) { string _cartel = _galleryMatch.Groups["1"].Value; string _coverPage = Helpers.GetPage(string.Format("{0}{1}", Host, _cartel)); if (!string.IsNullOrEmpty(_coverPage)) { string _reg3 = "imagen\"\\ssrc=\"(?<1>.*?)\""; Regex _regex3 = new Regex(_reg3); if (_regex3.IsMatch(_coverPage)) { string _imageUrl = _regex3.Match(_coverPage).Groups["1"].Value; if (!string.IsNullOrEmpty(_title) && !string.IsNullOrEmpty(_imageUrl)) { ResultMovieItem _movieItem = new ResultMovieItem(_id, _title, _imageUrl, CollectorName); _movieItem.CollectorMovieUrl = string.Format("{0}{1}", Host, sUrl); _movieItem.MovieInfo = _movieInfo; ResultsList.Add(_movieItem); _result = true; } } } } } } } } } } } } return(_result); }
public override bool GetResults(string keywords, string imdbID, bool skipImages) { bool _result = false; HttpWebRequest _req = (HttpWebRequest)WebRequest.Create(string.Format("{0}/ricerca/", Host)); // Set values for the request back //_req.Method = "GET"; _req.ContentType = "application/x-www-form-urlencoded"; _req.UserAgent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E)"; // Do the request to get the response string _strResponse = null; _strResponse = Helpers.GetPage(string.Format("{0}/ricerca/film/{1}", Host, string.Format("?q={0}&submit.x=21&submit.y=11", keywords))); if (!string.IsNullOrEmpty(_strResponse)) { // get the request id (eg. http://www.movieplayer.it/ricerca/dGhlIHlvdW5nIHZpY3Rvcmlh/1/ ) string _reqId = _req.Address.OriginalString; if (!string.IsNullOrEmpty(_reqId)) { _reqId = _reqId.Replace("http://www.movieplayer.it/ricerca/", "").Replace("/1/", ""); //if (!string.IsNullOrEmpty(_reqId)) { // requery just for the movies page _strResponse = string.IsNullOrEmpty(_reqId) ? _strResponse : Helpers.GetPage(string.Format("{0}/ricerca/film/{1}/", Host, _reqId)); if (!string.IsNullOrEmpty(_strResponse)) { Regex _reg = new Regex("<a href=\"(?<RelLink>/film/(?<Id>[^/]*)/[^\"]*)\">(?<Title>[^\"]+)</a>[^\"]*<em>trama:</em>(?<Plot>.*?)(<|\\[)", RegexOptions.IgnoreCase); if (_reg.IsMatch(_strResponse)) { List <string> _IDs = new List <string>(); foreach (Match _match in _reg.Matches(_strResponse)) { if (FileManager.CancellationPending) { return(ResultsList.Count != 0); } try { string _id = _match.Groups["Id"].Value; if (_IDs.Contains(_id)) { continue; // avoid duplicates } _IDs.Add(_id); string _relLink = _match.Groups["RelLink"].Value; string _title = HttpUtility.HtmlDecode(_match.Groups["Title"].Value).Replace("\n\t", "").Replace("</strong>", "").Replace("<strong>", "").Trim(); string _year = string.Empty; Regex _yearEx = new Regex("\\(([0-9]*)\\)", RegexOptions.IgnoreCase); if (_yearEx.IsMatch(_title)) { _year = _yearEx.Matches(_title)[0].Groups[1].Value; } if (!IsValidYear(_year)) { continue; } _title = _yearEx.Replace(_title, "").Trim(new char[] { '\r', '\n', ' ' }); _title = _title.Replace("<strong>", "").Replace("</strong>", ""); string _plot = HttpUtility.HtmlDecode(_match.Groups["Plot"].Value).Trim().Replace("<strong>", "").Replace("</strong>", ""); string _moviePageLink = string.Format("{0}{1}", Host, _relLink); // load the gallery and check if u can find some posters string _moviePage = Helpers.GetPage(_moviePageLink); if (!string.IsNullOrEmpty(_moviePage)) { MovieInfo _movieInfo = GetMovieInfo(_moviePage); _movieInfo.Name = _title; if (string.IsNullOrEmpty(_movieInfo.Year)) { _movieInfo.Year = _year; } _movieInfo.Overview = _plot; if (skipImages) { if (!string.IsNullOrEmpty(_title)) { ResultMovieItem _movieItem = new ResultMovieItem(_id, _title, null, this.CollectorName); _movieItem.CollectorMovieUrl = _moviePageLink; _movieItem.MovieInfo = _movieInfo; ResultsList.Add(_movieItem); _result = true; } } else { string _imageUrl = GetCoverLink(_moviePage); if (!string.IsNullOrEmpty(_imageUrl)) { _imageUrl = _imageUrl.Replace("_medium", ""); } if (!string.IsNullOrEmpty(_title)) { ResultMovieItem _movieItem = new ResultMovieItem(_id, _title, _imageUrl, this.CollectorName); _movieItem.CollectorMovieUrl = _moviePageLink; _movieItem.MovieInfo = _movieInfo; ResultsList.Add(_movieItem); _result = true; } } } } catch { } } } } } } } return(_result); }
public override bool GetResults(string keywords, string imdbID, bool skipImages) { bool _result = false; string _strResponse = Search(keywords, imdbID); if (!string.IsNullOrEmpty(_strResponse)) { _strResponse = Helpers.GetSubstringBetweenStrings(_strResponse, string.IsNullOrEmpty(imdbID) ? "Titel:" : "Filme:", "google_ad_client"); if (!string.IsNullOrEmpty(_strResponse)) { // Group 1 = relative link to moviepage, Group 2 = ID, Group 3 = relative link to full thumbnail Regex _reg = new Regex(SearchPageRegex, RegexOptions.IgnoreCase); if (_reg.IsMatch(_strResponse)) { foreach (Match _match in _reg.Matches(_strResponse)) { if (FileManager.CancellationPending) { return(ResultsList.Count != 0); } string _relLink = _match.Groups[1].Value; string _id = _match.Groups[2].Value; string _moviePageLink = string.Format("{0}/{1}", Host, _relLink); string _imageUrl = string.Format("{0}/{1}", Host, _match.Groups[3].Value); string _title = null; string _year = null; string _imdbId = null; // go to moviepage string _moviePage = Helpers.GetPage(_moviePageLink); if (!string.IsNullOrEmpty(_moviePage)) { // get IMDb Id _imdbId = nfoHelper.ExtractIMDBId(_moviePage); // get title and year always and MovieInfo in a separate method // Group 1 = Title, Group 2 = year Regex _regTitle = new Regex(@"<title>OFDb - (.*) \(([0-9]{4})\)</title>", RegexOptions.IgnoreCase); if (_regTitle.IsMatch(_moviePage)) { _title = HttpUtility.HtmlDecode(_regTitle.Matches(_moviePage)[0].Groups[1].Value.Trim()); _year = _regTitle.Matches(_moviePage)[0].Groups[2].Value.Trim(); } if (!IsValidYear(_year)) { continue; } if (!string.IsNullOrEmpty(_imageUrl) && !string.IsNullOrEmpty(_title)) { ResultMovieItem _movieItem = new ResultMovieItem(_id, _title, _imageUrl, this.CollectorName); _movieItem.CollectorMovieUrl = _moviePageLink; _movieItem.MovieInfo = GetMovieInfo(_moviePage); _movieItem.MovieInfo.Name = _title; _movieItem.MovieInfo.Year = _year; ResultsList.Add(_movieItem); _result = true; } } } } } } return(_result); }
private void GetPosters(TheTVDBSerieItem serieItem) { XmlDocument _doc = new XmlDocument(); MemoryStream _stream = null; SetCurrentEpisodeRelatedInfo(serieItem.ID, serieItem.MovieInfo); // check if cache has the current series XML if (CurrentSeriesHelper.GetPostersData.ContainsKey(serieItem.ID)) { _doc.LoadXml(CurrentSeriesHelper.GetPostersData[serieItem.ID]); } else { string _postersUrl = string.Format("{0}{1}/banners.xml", BaseUrl, serieItem.ID); _stream = SendRequest(_postersUrl); if (_stream != null && _stream.Length > 0) { //SetCurrentEpisodeRelatedInfo(serieItem.ID, serieItem.MovieInfo); _stream.Position = 0; try { _doc.Load(_stream); _stream.Dispose(); _stream = null; // update cache if (!CurrentSeriesHelper.GetPostersData.ContainsKey(serieItem.ID)) { CurrentSeriesHelper.GetPostersData.Add(serieItem.ID, _doc.OuterXml.ToString()); } else { CurrentSeriesHelper.GetPostersData[serieItem.ID] = _doc.OuterXml.ToString(); } } catch { } } } // take just poster and season that is not seasonwide //XmlNodeList _images = _doc.SelectNodes("//Banner[BannerType='poster' or (BannerType='season' and BannerType2='season')]"); //XmlNodeList _images = _doc.SelectNodes("//Banner[BannerType='poster' or (BannerType='season' ) or BannerType='fanart' or BannerType='series']"); XmlNodeList _images = null; if (FileManager.Configuration.Options.RetrieveBannersAsBackdrops) { _images = _doc.SelectNodes("//Banner"); } else { _images = _doc.SelectNodes("//Banner[BannerType='poster' or (BannerType='season' and BannerType2='season') or BannerType='fanart']"); } if (_images.Count != 0) { foreach (XmlNode _item in _images) { // process posters string _type = Helpers.GetValueFromXmlNode(_item, "BannerType"); string _type2 = Helpers.GetValueFromXmlNode(_item, "BannerType2"); if ((string.Compare(_type, "poster") == 0) || ((string.Compare(_type, "season") == 0) && (string.Compare(_type2, "seasonwide") != 0))) { string _relPath = Helpers.GetValueFromXmlNode(_item.SelectSingleNode("BannerPath")); string _imageUrl = string.Format("{0}/banners/{1}", m_MirrorPath, _relPath); string _seasonNumber = Helpers.GetValueFromXmlNode(_item.SelectSingleNode("Season")); if (!IsSameSeason(_seasonNumber, m_EpisodeData.Season)) { continue; } string _id = serieItem.ID.ToString(); string _title = serieItem.Title; string _extraText = !string.IsNullOrEmpty(_seasonNumber) ? string.Format(" [Season {0}]", _seasonNumber) : string.Empty; int _seasonNr = 0; try { _seasonNr = !string.IsNullOrEmpty(_seasonNumber) ? Int32.Parse(_seasonNumber) : 0; } catch { } if (!string.IsNullOrEmpty(_title) && !string.IsNullOrEmpty(_relPath)) { ResultMovieItem _movieItem = new ResultMovieItem(_id, _title, _imageUrl, CollectorName); _movieItem.ExtraText = _extraText; _movieItem.IsSeasonCover = !string.IsNullOrEmpty(_movieItem.ExtraText); _movieItem.Season = _seasonNr; _movieItem.MovieInfo = serieItem.MovieInfo; _movieItem.CollectorMovieUrl = _id != null?string.Format("http://thetvdb.com/index.php?tab=series&id={0}", _id) : null; ResultsList.Insert(Math.Max(0, ResultsList.Count - 1), _movieItem); } } else // must be a fanart { string _relPath = Helpers.GetValueFromXmlNode(_item.SelectSingleNode("ThumbnailPath")); string _thumbUrl = string.Format("{0}/banners/{1}", m_MirrorPath, _relPath); string _relPath2 = Helpers.GetValueFromXmlNode(_item.SelectSingleNode("BannerPath")); string _originalUrl = string.Format("{0}/banners/{1}", m_MirrorPath, _relPath2); bool _isWideBanner = Helpers.GetValueFromXmlNode(_item, "BannerType2") == "graphical" || Helpers.GetValueFromXmlNode(_item, "BannerType2") == "blank"; if (string.IsNullOrEmpty(_relPath)) { _relPath = _relPath2; _thumbUrl = _originalUrl; } string _width = null; string _height = null; string _s = Helpers.GetValueFromXmlNode(_item, "BannerType2"); if (!string.IsNullOrEmpty(_s)) { Match _m = Regex.Match(_s, "(?<Width>[0-9]+?)x(?<Height>([0-9]*)?)", RegexOptions.Singleline | RegexOptions.IgnoreCase); _width = _m.Success ? _m.Groups["Width"].Value : null; _height = _m.Success ? _m.Groups["Height"].Value : null; } if (!string.IsNullOrEmpty(_relPath) && !string.IsNullOrEmpty(_relPath2)) { BackdropItem _bi = new BackdropItem(serieItem.ID.ToString(), (serieItem != null ? serieItem.IMDBId : string.Empty), this.CollectorName, _thumbUrl, _originalUrl); _bi.Season = m_EpisodeData.Season; _bi.Episode = m_EpisodeData.Episode; _bi.IsBanner = _isWideBanner; _bi.SetSize(_width, _height); this.BackdropsList.Add(_bi); } } } } }
private void GetEpisodes(TheTVDBSerieItem serieItem) { XmlDocument _doc = new XmlDocument(); MemoryStream _stream = null; // check if cache has the current series XML if (CurrentSeriesHelper.GetEpisodesData.ContainsKey(serieItem.ID)) { _doc.LoadXml(CurrentSeriesHelper.GetEpisodesData[serieItem.ID]); } else { string _episodesUrl = string.Format("{0}{1}/all/{2}.xml", BaseUrl, serieItem.ID, FileManager.Configuration.Options.MovieSheetsOptions.TVShowsLanguage); _stream = SendRequest(_episodesUrl); if (_stream == null || _stream.Length == 0) { _episodesUrl = string.Format("{0}{1}/all/", BaseUrl, serieItem.ID); _stream = SendRequest(_episodesUrl); } if (_stream != null && _stream.Length > 0) { try { _doc.Load(_stream); _stream.Dispose(); _stream = null; // update cache if (!CurrentSeriesHelper.GetEpisodesData.ContainsKey(serieItem.ID)) { CurrentSeriesHelper.GetEpisodesData.Add(serieItem.ID, _doc.OuterXml.ToString()); } else { CurrentSeriesHelper.GetEpisodesData[serieItem.ID] = _doc.OuterXml.ToString(); } } catch { } } } // take just poster and season that is not seasonwide XmlNodeList _episodes = _doc.SelectNodes("//Episode"); if (_episodes.Count != 0) { string _episodeField = null; string _seasonField = null; switch (m_EpisodeData.Type) { default: case EpisodeType.AiredOrder: _episodeField = "EpisodeNumber"; _seasonField = "SeasonNumber"; break; case EpisodeType.DVDOrder: _episodeField = "DVD_episodenumber"; _seasonField = "DVD_season"; break; case EpisodeType.Absolute: _episodeField = "absolute_number"; _seasonField = string.Empty; break; } foreach (XmlNode _item in _episodes) { string _relPath = Helpers.GetValueFromXmlNode(_item.SelectSingleNode("filename")); string _imageUrl = string.Format("{0}/banners/{1}", m_MirrorPath, _relPath); string _seasonNumber = string.IsNullOrEmpty(_seasonField) ? string.Empty : Helpers.GetValueFromXmlNode(_item.SelectSingleNode(_seasonField)); string _episodeNumber = Helpers.GetValueFromXmlNode(_item.SelectSingleNode(_episodeField)); // remove trailing numbers like 2.0 -> 2 _seasonNumber = TrimValue(_seasonNumber); _episodeNumber = TrimValue(_episodeNumber); // if same episode and (if defined) same season if ((_episodeNumber == m_EpisodeData.Episode) && ((!string.IsNullOrEmpty(_seasonNumber) && (_seasonNumber == m_EpisodeData.Season)) || string.IsNullOrEmpty(_seasonNumber)) ) { string _episodeName = Helpers.GetValueFromXmlNode(_item.SelectSingleNode("EpisodeName")); _episodeName = string.IsNullOrEmpty(_episodeName) ? string.Empty : string.Format(" - {0}", _episodeName); string _id = serieItem.ID.ToString(); string _title = serieItem.Title; string _extraText = _seasonNumber != null?string.Format(" [Season {0}]", _seasonNumber) : string.Empty; //_extraText = _episodeNumber != null && _episodeNumber != "0" ? string.Format("{0} [Episode {1}{2}] (screenshot)", _extraText, _episodeNumber, _episodeName) : _extraText; _extraText = _episodeNumber != null && _episodeNumber != "0" ? string.Format("{0} [Episode {1}]", _extraText, _episodeNumber) : _extraText; if (!string.IsNullOrEmpty(_title) /*&& !string.IsNullOrEmpty(_relPath)*/) { ResultMovieItem _movieItem = new ResultMovieItem(_id, _title, _imageUrl, CollectorName); _movieItem.ExtraText = _extraText; _movieItem.MovieInfo = serieItem.MovieInfo; _movieItem.CollectorMovieUrl = _id != null?string.Format("http://thetvdb.com/index.php?tab=series&id={0}", _id) : null; ResultsList.Add(_movieItem); if (!string.IsNullOrEmpty(_relPath)) { BackdropItem _bi = new BackdropItem(serieItem.ID.ToString(), (serieItem != null ? serieItem.IMDBId : string.Empty), this.CollectorName, _imageUrl, _imageUrl); _bi.Episode = m_EpisodeData.Episode; _bi.Season = m_EpisodeData.Season; _bi.IsScreenshot = true; this.BackdropsList.Insert(0, _bi); } } } } } }
public static void GetImageAsync(DispatcherObject dispatcher, ResultMovieItem movie, SetImageDataHandler handler) { ThreadPool.QueueUserWorkItem(new WaitCallback(DoWork), new ThreadParams(movie, dispatcher, handler)); }