static void Main(string[] args) { // This is the query - or you could get it from args. string query = "human form abstract"; var count = 100; var debug = true; List <ImageQueryResult> imageList = new List <ImageQueryResult>(); if (GlobalConfig._global_useSearchApiSource) { if (debug) { Console.WriteLine("Getting ImageQueryResults from BING SEARCH API"); } // get the image list from actual source var grabber = new ImageUrlGrabber(); imageList = grabber.GetImageUrlList( ImageQueryConfig.Get( query, count, ImageSearchOptions.Build(QueryAdultValues.OFF, imageFilterColor: ImageFilterColorValues.MONOCHROME, imageFilterAspectValue: ImageFilterAspectValues.SQUARE)), debug); // serialize it for temporary storage for any usage // mostly to prevent extra queries when debugging. ImageResultXmlProcessor.Serialize(imageList); } else { Console.WriteLine("Getting ImageQueryResults from XML"); imageList = ImageResultXmlProcessor.Desirialize(); } if (GlobalConfig._download_run_download) { Console.WriteLine("Redownloading images"); // Try and download images var imageDownloader = new ImageDownloader(); imageDownloader.DownloadImages(imageList, DownloadOptions.Build(true, "thumb_"), debug); } else { Console.WriteLine("Using Predownloaded images"); // do not download image and run the composer from what is // already in the folder } var imageComposer = new ImageComposer(); var composedImage = imageComposer.CombineImagesInFolder(GlobalConfig._download_imageDownloadPath, debug); composedImage.Save(GlobalConfig.ComposedImagePath); composedImage.Dispose(); Console.WriteLine("DONE!"); Console.ReadLine(); }
private static string GetCategoryThumbPath(string id, WebOnlineVideosMediaType mediaType) { string siteName; string categoryRecrusiveName; OnlineVideosIdGenerator.DecodeCategoryId(id, out siteName, out categoryRecrusiveName); Category category; if (mediaType == WebOnlineVideosMediaType.Category) { category = MP2Extended.OnlineVideosManager.GetSiteCategories(siteName).Single(x => x.RecursiveName() == categoryRecrusiveName); } else { category = MP2Extended.OnlineVideosManager.GetSubCategories(siteName, categoryRecrusiveName).Single(x => x.RecursiveName() == categoryRecrusiveName); } // Download the thumb in case it doesn't exist if (category.ThumbnailImage == null) { ImageDownloader.DownloadImages(new List <Category> { category }); } return(category.ThumbnailImage); }
private UIButton searchButton(UIActivityIndicatorView loading, UITextField name) { var sb = UIButton.FromType(UIButtonType.RoundedRect); sb.Frame = new CGRect(StartX, StartY + 2 * Height, this.View.Bounds.Width - 2 * StartX, Height); sb.SetTitle("Search", UIControlState.Normal); sb.TouchUpInside += async(sender, args) => { loading.StartAnimating(); loading.Hidden = false; name.ResignFirstResponder(); _movies = await _api.GetMoviesByTitle(name.Text); await _imgDl.DownloadImages(_movies); await _imgDl.DownloadBackdrops(_movies); loading.StopAnimating(); loading.Hidden = true; this.NavigationController.PushViewController(new MovieListController(this._movies), true); }; return(sb); }
private async void loadData() { this.TableView.Source = new MovieDataSource(new List <Movie>(), onSelectedMovie); this.TableView.ReloadData(); this.TableView.ScrollEnabled = false; _loading.StartAnimating(); _loading.Hidden = false; // Fetch images this._movies = await this._api.GetTopRatedMovies(); await _imgDl.DownloadImages(_movies); await _imgDl.DownloadBackdrops(_movies); _loading.StopAnimating(); _loading.Hidden = true; this.TableView.ScrollEnabled = true; this.TableView.Source = new MovieDataSource(this._movies, onSelectedMovie); this.TableView.ReloadData(); }
private void Run() { StopGame = IsOutOfBoard() || IsLost(); UpdateSnake(); UpdatePoints(); if (IsSnakeScore()) { ImageDownloader.DownloadImages(UpdateImage); } RefreshRectangle(); }
/// <summary> /// Defines the entry point of the application. /// </summary> /// <param name="args">The arguments.</param> public static void Main(string[] args) { // Update the path in the Constants file var dates = DateParser.ParseDates(Constants.DatesPath); // Downloads the images to a local folder as per the dates ImageDownloader.DownloadImages(dates); // Launches the application CreateHostBuilder(args).Build().Run(); }
private static string GetVideoThumbPath(string id) { string siteName; string categoryRecrusiveName; string videoUrl; OnlineVideosIdGenerator.DecodeVideoId(id, out siteName, out categoryRecrusiveName, out videoUrl); VideoInfo video = MP2Extended.OnlineVideosManager.GetCategoryVideos(siteName, categoryRecrusiveName).Single(x => x.VideoUrl == videoUrl); // Download the thumb in case it doesn't exist if (video.ThumbnailImage == null) { ImageDownloader.DownloadImages(new List <VideoInfo> { video }); } return(video.ThumbnailImage); }
void Worker() { bool setOnce = false; uint currentRotationIndex = 0; DateTime lastDiscovery = DateTime.MinValue; List <KeyValuePair <string, VideoInfo> > latestVideos = new List <KeyValuePair <string, VideoInfo> >(); try { while (true) { if ((DateTime.Now - lastDiscovery).TotalMinutes > PluginConfiguration.Instance.LatestVideosOnlineDataRefresh) { Dictionary <string, List <VideoInfo> > latestVideosPerSite = DiscoverAllLatestVideos(); lastDiscovery = DateTime.Now; currentRotationIndex = 0; setOnce = false; int previousLatetsVideosCount = latestVideos.Count; latestVideos.Clear(); foreach (var l in latestVideosPerSite) { latestVideos.AddRange(l.Value.Select(v => new KeyValuePair <string, VideoInfo>(l.Key, v))); } Log.Instance.Info("LatestVideosManager found {0} videos from {1} SiteUtils.", latestVideos.Count, latestVideosPerSite.Count); int less = Math.Min(previousLatetsVideosCount, (int)PluginConfiguration.Instance.LatestVideosMaxItems) - Math.Min(latestVideos.Count, (int)PluginConfiguration.Instance.LatestVideosMaxItems); while (less > 0) { // reset the GuiProperties in case we found less latest videos than before and than should be shown in rotation ResetLatestVideoGuiProperties((int)PluginConfiguration.Instance.LatestVideosMaxItems - less + 1); less--; } GUIPropertyManager.SetProperty("#OnlineVideos.LatestVideosEnabled", (Math.Min(latestVideos.Count, PluginConfiguration.Instance.LatestVideosMaxItems) > 0).ToString().ToLower()); if (latestVideos.Count > 0) { if (PluginConfiguration.Instance.LatestVideosRandomize) { latestVideos.Randomize(); } ImageDownloader.DownloadImages <VideoInfo>(latestVideos.Select(v => v.Value).ToList()); } } if (latestVideos.Count > 0 && (!setOnce || latestVideos.Count > PluginConfiguration.Instance.LatestVideosMaxItems)) // only needed ONCE if there are no more latestVideos than amount to be shown { for (int i = 1; i <= Math.Min(latestVideos.Count, PluginConfiguration.Instance.LatestVideosMaxItems); i++) { int num = (int)currentRotationIndex + i - 1; if (num >= latestVideos.Count) { num = i - 1; } SetLatestVideoGuiProperties(latestVideos[num], i); } setOnce = true; currentRotationIndex++; if (currentRotationIndex >= latestVideos.Count) { currentRotationIndex = 0; } } Thread.Sleep(1000 * (int)PluginConfiguration.Instance.LatestVideosGuiDataRefresh); // don't do anything while Fullscreen Playback while (g_Player.FullScreen || pause) { Thread.Sleep(1000); } } } catch (ThreadAbortException) { Thread.ResetAbort(); // finish gracefully when thread was forcibly aborted } catch (Exception ex) { Log.Instance.Warn("LatestVideos thread ended unexpected: {0}", ex.Message); } workerThread = null; }