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); }
async Task ExecuteLoadResultsCommand() { if (IsBusy) { return; } IsBusy = true; try { ResultsList.Clear(); var items = await App.ResultDB.GetResultsByAssessmentSession(App.AssessmentSession.SessionId); foreach (var item in items) { ResultsList.Add(item); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
private async void BrowseForImages() { StatusText = "Running..."; FileOpenPicker openPicker = new FileOpenPicker(); openPicker.CommitButtonText = "Open"; openPicker.FileTypeFilter.Add(".jpg"); openPicker.FileTypeFilter.Add(".jpe"); openPicker.FileTypeFilter.Add(".bmp"); openPicker.FileTypeFilter.Add(".png"); openPicker.FileTypeFilter.Add(".gif"); openPicker.ViewMode = PickerViewMode.Thumbnail; openPicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary; IReadOnlyList <StorageFile> files = await openPicker.PickMultipleFilesAsync(); if (files.Count > 0) { ResultsList.Clear(); } foreach (StorageFile file in files) { try { var result = await ProcessImage(file); ResultsList.Add(result); } catch (Exception ex) { Debug.WriteLine(ex); } } StatusText = "Ready"; }
private void AddResultItemOrAddToItemResultListLog(IDebugItemResult itemToAdd, bool isDeserialize) { if (!string.IsNullOrWhiteSpace(itemToAdd.GroupName) && itemToAdd.GroupIndex > MaxItemDispatchCount && !isDeserialize) { _fileName = string.Format("{0}.txt", _itemId); var shouldCreateMoreLink = itemToAdd.GroupIndex == MaxItemDispatchCount + 1 && !_isMoreLinkCreated; if (shouldCreateMoreLink) { ClearFile(_fileName); _stringBuilder.AppendLine(itemToAdd.GetMoreLinkItem()); var clonedItem = itemToAdd.Clone(); var moreLink = SaveFile(_stringBuilder.ToString(), _fileName); _stringBuilder.Clear(); clonedItem.MoreLink = moreLink; ResultsList.Add(clonedItem); _isMoreLinkCreated = true; return; } _stringBuilder.AppendLine(itemToAdd.GetMoreLinkItem()); FlushResultListLogIfNeeded(itemToAdd); return; } TruncateItemResultIfNeeded(itemToAdd); ResultsList.Add(itemToAdd); }
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); }
public static ResultsList ParseSearchResultsPage(String pageContent, ResultsList list) { HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(pageContent); HtmlNode docNode = doc.DocumentNode; HtmlNode currentNode; // Get total number of search results currentNode = docNode.SelectSingleNode("//span[contains(@id,'searchTermDisplay')]"); var match = Regex.Match(currentNode.InnerText, "(([\\d]+))"); list.TotalResults = Int32.Parse(match.Value); list.NumPages = 1 + (list.TotalResults / 100); if (list.TotalResults == 0) return list; // Get the link to the next page currentNode = docNode.SelectSingleNode("//div[contains(@id, 'topPagingControls')]//a[last()]"); if (currentNode != null) { if (currentNode.InnerText.Contains(">")) list.NextPageUrl = "http://gatherer.wizards.com" + HttpUtility.HtmlDecode(currentNode.Attributes["href"].Value); else list.NextPageUrl = String.Empty; } // Process results on page. var nodeList = docNode.SelectNodes("//tr[contains(@class, 'cardItem')]"); foreach (var node in nodeList) { CardPreview cPrev = new CardPreview(); var nameNode = node.SelectSingleNode(".//td[1]/a"); // Parse name and id cPrev.Name = nameNode.InnerText.Trim(); cPrev.MultiverseId = UInt32.Parse(Regex.Match(nameNode.Attributes["href"].Value, "multiverseid=([\\d]+)").Groups[1].Value); // Parse mana cost cPrev.Cost = ParseImgsToManaCost(node.SelectNodes(".//td[2]/img")); // Parse types and subtypes var typeStr = node.SelectSingleNode(".//td[3]").InnerText.Trim(); var tuple = _ParseTypes(typeStr); cPrev.Types = tuple.Item1; cPrev.SubTypes = tuple.Item2; // Parse power and toughness cPrev.Power = node.SelectSingleNode(".//td[4]").InnerText.Trim(); cPrev.Toughness = node.SelectSingleNode(".//td[5]").InnerText.Trim(); // Parse printings cPrev.Printings = _ParsePrintings(node.SelectNodes(".//div[contains(@id,'cardPrintings')]/a")); list.Add(cPrev); list.ProcessedResults++; } return list; }
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); }
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); } // extra for torec... eliminate duplicates var _items = from c in ResultsList where c.MovieInfo.IMDBID == _movieInfo.IMDBID select c; if (_items != null && _items.Count() != 0) { return(false); } string _imageUrl = string.Format("{0}{1}", Host, 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 void _processTimer_Tick(object sender, EventArgs e) { if (SourceMediaElement.Position.Seconds < 1) { return; } var w = SourceMediaElement.ActualWidth; var h = SourceMediaElement.ActualHeight; System.Drawing.Size dpi = new System.Drawing.Size(96, 96); RenderTargetBitmap bmp = new RenderTargetBitmap((int)w, (int)h, dpi.Width, dpi.Height, PixelFormats.Pbgra32); bmp.Render(SourceMediaElement); MemoryStream stream = new MemoryStream(); BitmapEncoder encoder = new BmpBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(bmp)); encoder.Save(stream); Bitmap bitmap = new Bitmap(stream); // try to recognize image AlprResultsNet result = _process.Recognize(bitmap); foreach (var plate in result.Plates) { if (plate.BestPlate.Characters.Length >= 7) { if (plate.BestPlate.OverallConfidence > Confidence) { ResultsList.Add(new ResultViewModel(plate.BestPlate.Characters, SourceMediaElement.Position, plate.BestPlate.OverallConfidence, true)); LastRecognizedPlate = plate.BestPlate.Characters; } else { ResultsList.Add(new ResultViewModel(plate.BestPlate.Characters, SourceMediaElement.Position, plate.BestPlate.OverallConfidence)); } _lineTimer.Start(); } SetFirstLines(plate); SetSecondLines(plate); SetThirdLines(plate); SetFourthLines(plate); } }
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); }
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); }
public override bool GetResults(string keywords, string imdbID, bool skipImages) { bool result = false; try { var api = new AlloCineApi(); var feed = api.Search(keywords); if (feed.Error == null) { foreach (var movie in feed.MovieList) { if (FileManager.CancellationPending) { return(ResultsList.Count != 0); } try { string id = movie.Code; string originalTitle = movie.OriginalTitle; string title = movie.Title; title = string.IsNullOrEmpty(title) ? originalTitle : title; MovieInfo movieInfo = GetMovieInfo(id); string posterPath = movie.Poster.Href; string imageUrl = string.IsNullOrEmpty(posterPath) ? null : posterPath; var movieItem = new ResultMovieItem(id, title, imageUrl, CollectorName); movieItem.CollectorMovieUrl = id != null?GetMovieUrl(id) : null; movieItem.MovieInfo = movieInfo; ResultsList.Add(movieItem); result = true; } catch (Exception ex) { Loggy.Logger.DebugException("Allocine iteration: ", ex); } } } } catch (Exception ex) { Loggy.Logger.DebugException("Allocine results: ", ex); } 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://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); }
public void ResultsCallback(CrackResults results) { lock (ResultsLocker) { Hashestried += results.Hashes; ClientsWorkTimeSpan = ClientsWorkTimeSpan.Add(results.TimeElapsed); if (results.Results.Count < 1) { return; } foreach (var user in results.Results) { if (!ResultsList.ContainsKey(user.Username)) { ResultsList.Add(user.Username, user); } if (Workload.ContainsKey(user.Username)) { Workload.Remove(user.Username); } } } }
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; // 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); }
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 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); }
void RegExpSearchButtonClick(object sender, EventArgs e) { //SearchResults res1 = new SearchResults(ResultsBrowser); int results = 0; int LineInSession = 0; string CurSession = ""; if (!More) { RowsDone = 0; GlobalResults = 0; } SearchOption = 2; string filePath = path; Regex regex; if (RegExpSearchBox.Text == "" || RegExpSearchBox.Text == "*" || RegExpSearchBox.Text == ".*" || RegExpSearchBox.Text == ".*$") { MessageBox.Show("Be more specific!"); } else { regex = new Regex(RegExpSearchBox.Text); StreamReader sr = new StreamReader(filePath); if (More) { while (results < RowsDone) { sr.ReadLine(); results++; } results = 0; } if (More && !sr.EndOfStream || !More) { ResultsList.Clear(); ListPanel.Dispose(); this.ListPanel = new System.Windows.Forms.Panel(); this.ListPanel.AutoScroll = true; this.ListPanel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; this.ListPanel.Location = new System.Drawing.Point(264, 36); this.ListPanel.Name = "ListPanel"; this.ListPanel.Size = new System.Drawing.Size(328, 669); this.ListPanel.TabIndex = 2; this.Controls.Add(this.ListPanel); } while (!sr.EndOfStream && results <= results_limit) { string[] Line = sr.ReadLine().Split('|'); if (CurSession != Line[2] && Line.Length == 12) { CurSession = Line[2]; LineInSession = 1; } else if (Line.Length == 12) { LineInSession++; } Match m = regex.Match(Line[11]); while (m.Success) { ResultsList.Add(new Message_Entry(Line[0], Line[6], Line[1], Line[2], Line[5], Line[7], Line[8], Line[9], Line[10], Line[11], m.Value, m.Index, LineInSession)); m = m.NextMatch(); results++; GlobalResults++; } RowsDone++; ResultsCount.Text = results.ToString() + "(" + GlobalResults + ")"; } PrintResults(); sr.Close(); More = false; } }
void SearchButtonClick(object sender, EventArgs e) { string filePath = path; string[] Line = { "1", "2" }; int startIndex; StreamReader sr = new StreamReader(filePath); int results = 0; int LineInSession = 0; string CurSession = ""; if (!More) { RowsDone = 0; GlobalResults = 0; } SearchOption = 1; int resultIndex = 0; bool lineDone = false; if (More) { while (results < RowsDone) { sr.ReadLine(); results++; } results = 0; } if (More && !sr.EndOfStream || !More) { ResultsList.Clear(); ListPanel.Dispose(); this.ListPanel = new System.Windows.Forms.Panel(); this.ListPanel.AutoScroll = true; this.ListPanel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; this.ListPanel.Location = new System.Drawing.Point(264, 36); this.ListPanel.Name = "ListPanel"; this.ListPanel.Size = new System.Drawing.Size(328, 669); this.ListPanel.TabIndex = 2; this.Controls.Add(this.ListPanel); } while (!sr.EndOfStream && results <= results_limit) { Line = sr.ReadLine().Split('|'); /* * [0] id [6] msg time * [1] conn [7] sender id * [2] session [8] sender name * [3] ses start [9] receiver id * [4] ses end [10] receiver name * [5] contact [11] msg */ if (CurSession != Line[2] && Line.Length == 12) { CurSession = Line[2]; LineInSession = 1; } else if (Line.Length == 12) { LineInSession++; } while (!lineDone && Line.Length == 12) { startIndex = Line[11].IndexOf(SearchBox.Text, resultIndex, StringComparison.OrdinalIgnoreCase); if (SearchBox.Text != "" && startIndex >= 0) { //resultEntry=CutLongString(Line[10],SearchBox.Text,resultIndex); ResultsList.Add(new Message_Entry(Line[0], Line[6], Line[1], Line[2], Line[5], Line[7], Line[8], Line[9], Line[10], Line[11], SearchBox.Text, startIndex, LineInSession)); resultIndex = startIndex + 1; results++; GlobalResults++; } else { lineDone = true; } } lineDone = false; resultIndex = 0; RowsDone++; ResultsCount.Text = results.ToString() + "(" + GlobalResults + ")"; } PrintResults(); sr.Close(); More = false; }
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 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 void AddResult(Result result) { ResultsList.Add(result); }
/// <summary> /// 把查询出的差异转换成UI呈现对象 /// </summary> public void ConvertToCompareResult() { ResultsList.Clear(); RepairedNum = 0; UIShow = ""; foreach (var re in _service.DifTableList) { if (re.ErrorType == 1) { //丢失的列 foreach (var col in re.LostCol) { var tmp = new UICompareResult { ObjectName = re.SourceInfo.name, ObjectType = re.SourceInfo.type, ErrorItem = col.Name, ErrorItemType = "col", ErrorType = DicError[2] }; ResultsList.Add(tmp); UIShow = UIShow + tmp; } //冗余的列 foreach (var col in re.MoreCol) { var tmp = new UICompareResult { ObjectName = re.SourceInfo.name, ObjectType = re.SourceInfo.type, ErrorItem = col.Name, ErrorItemType = "col", ErrorType = DicError[3] }; ResultsList.Add(tmp); UIShow = UIShow + tmp; } } if (re.ErrorType == 2) { var tmp = new UICompareResult { ObjectName = re.SourceInfo.name, ObjectType = re.SourceInfo.type, ErrorItem = re.SourceInfo.name, ErrorItemType = re.SourceInfo.type, ErrorType = DicError[re.ErrorType] }; ResultsList.Add(tmp); UIShow = UIShow + tmp; } if (re.ErrorType == 3) { var tmp = new UICompareResult { ObjectName = re.TargetInfo.name, ObjectType = re.TargetInfo.type, ErrorItem = re.TargetInfo.name, ErrorItemType = re.TargetInfo.type, ErrorType = DicError[re.ErrorType] }; ResultsList.Add(tmp); UIShow = UIShow + tmp; } } if (new AppInfo().NeedCompareIndex) { foreach (var re in _service.DifIndexList) { //如果是丢失 对象信息从源对象取 if (re.ErrorType == 2) { var tmp = new UICompareResult { ObjectName = re.SourceInfo.name, ObjectType = re.SourceInfo.type, ErrorItem = re.SourceInfo.name, ErrorItemType = re.SourceInfo.type, ErrorType = DicError[re.ErrorType] }; ResultsList.Add(tmp); UIShow = UIShow + tmp; } //如果是冗余 对象信息从源对象取 if (re.ErrorType == 3) { var tmp = new UICompareResult { ObjectName = re.TargetInfo.name, ObjectType = re.TargetInfo.type, ErrorItem = re.TargetInfo.name, ErrorItemType = re.TargetInfo.type, ErrorType = DicError[re.ErrorType] }; ResultsList.Add(tmp); UIShow = UIShow + tmp; } } } UIThread.Invoke(() => { NeedRepairNum = ResultsList.Count; NotifyOfPropertyChange(() => CanRepairDB); }); }