internal AudioPlayable(IAudio audio, IAudioStorage storage, IWebDownloader downloader, Uri url) { __Audio = audio; __Storage = storage; __Downloader = downloader; __Url = url; __BassFileProcs = new BASS_FILEPROCS(user => { }, user => __CacheStream.AudioSize, BassReadProc, (offset, user) => true); __EndStreamProc = (handle, channel, data, user) => { __RequestTasksStop = true; CleanActions(); OnAudioNaturallyEnded(); }; if (storage.CheckCached(audio)) { DownloadedFracion = 1.0; } }
private void StartDownload() { CrawlerQueueEntry crawlerQueueEntry = m_CrawlerQueue.Pop(); if (crawlerQueueEntry.IsNull() || !OnBeforeDownload(crawlerQueueEntry.CrawlStep)) { return; } IWebDownloader webDownloader = m_WebDownloaderFactory(); webDownloader.MaximumDownloadSizeInRam = MaximumDownloadSizeInRam; webDownloader.ConnectionTimeout = ConnectionTimeout; webDownloader.MaximumContentSize = MaximumContentSize; webDownloader.DownloadBufferSize = DownloadBufferSize; webDownloader.UserAgent = UserAgent; webDownloader.UseCookies = UseCookies; webDownloader.ReadTimeout = ConnectionReadTimeout; webDownloader.RetryCount = DownloadRetryCount; webDownloader.RetryWaitDuration = DownloadRetryWaitDuration; m_Logger.Verbose("Downloading {0}", crawlerQueueEntry.CrawlStep.Uri); ThreadSafeCounter.ThreadSafeCounterCookie threadSafeCounterCookie = m_ThreadInUse.EnterCounterScope(crawlerQueueEntry); Interlocked.Increment(ref m_VisitedCount); webDownloader.DownloadAsync(crawlerQueueEntry.CrawlStep, crawlerQueueEntry.Referrer, DownloadMethod.GET, EndDownload, OnDownloadProgress, threadSafeCounterCookie); }
public MenuBarViewModel(IUntappdService untappdService, IInteractionRequestService interactionRequestService, ISettingService settingService, IModuleManager moduleManager, IRegionManager regionManager, IEventAggregator eventAggregator, IWebDownloader webDownloader, IReportingService reportingService) : base(regionManager) { this.interactionRequestService = interactionRequestService; this.settingService = settingService; this.untappdService = untappdService; this.moduleManager = moduleManager; this.eventAggregator = eventAggregator; this.webDownloader = webDownloader; this.reportingService = reportingService; GoToWelcomeCommand = new DelegateCommand(GoToWelcome); RenameProjectCommand = new DelegateCommand(RenameProject); SaveProjectCommand = new DelegateCommand(SaveProject); SaveAsProjectCommand = new DelegateCommand(SaveAsProject); DownloadProjectMediaCommand = new DelegateCommand(DownloadProjectMedia); UploadProjectPhotoCommand = new DelegateCommand(UploadProjectPhotos); WebDownloadProjectCommand = new DelegateCommand(WebDownloadProject); CheckinsProjectReportCommand = new DelegateCommand(CheckinsProjectReport); HelpCommand = new DelegateCommand(Help); }
public void OnDownload(string url, string suggestedName, long totalSize, IWebDownloader downloader) { Logging.Write(url); ActionExtension.InvokeInMainThread(() => { new TemporaryFactoryAndLoader(url).RunAsync(suggestedName, totalSize, downloader).Ignore(); }); }
private void InitInternal(string email, string password, IWebDownloader downloader, string userId = null) { var api = new VkApi(); try { api.Authorize(APP_ID, email, password, Settings.Audio); } catch (Exception e) { throw new AuthException("Authorization error! Original exception:\n" + e.ToString()); } var id = userId != null?GetUserIdFromString(api, userId) : api.UserId.Value; UserFirstName = api.Users.Get(id).FirstName; InitProviders(downloader, api, id); __AudioStorage.StoreLastUserId(userId); if (userId != null) { __AudioStorage.StoreUserAlias(userId, id, UserFirstName); } __IsInit = true; }
internal AudioPlayableMediator(IAudioStorage storage, IWebDownloader downloader, IAudio audio, Uri url) { __InternalPlayable = new AudioPlayable(audio, storage, downloader, url); __InternalPlayable.DownloadedFracionChanged += OnPercentsDownloadedChanged; __InternalPlayable.AudioNaturallyEnded += WhenStop; __Duration = audio.Duration; __PlaybackTimer.Elapsed += (sender, args) => OnSecondsPlayedChanged(); __PlaybackTimer.AutoReset = true; }
public UserQueryExecutor( IUserQueryGenerator userQueryGenerator, ITwitterAccessor twitterAccessor, IWebHelper webHelper, IWebDownloader webDownloader) { _userQueryGenerator = userQueryGenerator; _twitterAccessor = twitterAccessor; _webHelper = webHelper; _webDownloader = webDownloader; }
private AudioInfo(IAudioStorage storage, IWebDownloader downloader, long audioId, long userId, string title, string artist, int duration, int index, Uri url) { __AudioId = audioId; __UserId = userId; __Title = title; __Artist = artist; __Duration = duration; __Index = index; __Playable = new AudioPlayableMediator(storage, downloader, this, url); }
public void Process(Crawler crawler, PropertyBag propertyBag) { AspectF.Define. NotNull(crawler, "crawler"). NotNull(propertyBag, "propertyBag"); string content = propertyBag.Text; if (content.IsNullOrEmpty()) { return; } string contentLookupText = content.Max(MaxPostSize); string encodedRequestUrlFragment = "http://ajax.googleapis.com/ajax/services/language/detect?v=1.0&q={0}".FormatWith(contentLookupText); m_Logger.Verbose("Google language detection using: {0}", encodedRequestUrlFragment); try { IWebDownloader downloader = NCrawlerModule.Container.Resolve <IWebDownloader>(); PropertyBag result = downloader.Download(new CrawlStep(new Uri(encodedRequestUrlFragment), 0), null, DownloadMethod.GET); if (result.IsNull()) { return; } using (Stream responseReader = result.GetResponse()) using (StreamReader reader = new StreamReader(responseReader)) { string json = reader.ReadLine(); using (MemoryStream ms = new MemoryStream(Encoding.Unicode.GetBytes(json))) { DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(LanguageDetector)); LanguageDetector detector = ser.ReadObject(ms) as LanguageDetector; if (!detector.IsNull()) { CultureInfo culture = CultureInfo.GetCultureInfo(detector.responseData.language); propertyBag["Language"].Value = detector.responseData.language; propertyBag["LanguageCulture"].Value = culture; } } } } catch (Exception ex) { m_Logger.Error("Error during google language detection, the error was: {0}", ex.ToString()); } }
private void InitProviders(IWebDownloader downloader, VkApi api, long user) { PlayingStateChangedEventHandler handler; var factory = GetFactory(downloader, out handler); __InfoProvider = new AudioInfoProvider((userId, count, offset) => api.Audio.Get(userId, null, null, count, offset), userId => api.Audio.GetCount(userId), factory, user, handler); __InfoCacheOnlyProvider = new AudioInfoCacheOnlyProvider(factory, __AudioStorage, user, handler); }
/// <summary> /// Download content from a url /// </summary> /// <param name="step">Step in crawler that contains url to download</param> /// <returns>Downloaded content</returns> private PropertyBag Download(CrawlStep step) { try { IWebDownloader webDownloader = m_DownloaderFactory.GetDownloader(); m_Logger.Verbose("Downloading {0}", step.Uri); return(webDownloader.Download(step, DownloadMethod.Get)); } catch (Exception ex) { OnDownloadException(ex, step); } return(null); }
public async Task RunAsync(string suggestedName, long totalSize, IWebDownloader downloader) { try { FlexibleLoader.RegisterPriority(this); ContentInstallationManager.Instance.InstallAsync(_url, AddInstallMode.ForceNewTask, ContentInstallationParams.DefaultWithExecutables).Forget(); FlexibleLoader.Unregister(this); var destinationCallback = _destinationCallback; var reportDestinationCallback = _reportDestinationCallback; var progress = _progress; var resultTask = _resultTask; if (destinationCallback == null) { return; } TotalSize = totalSize; FileName = suggestedName; _destinationCallback = null; _reportDestinationCallback = null; _progress = null; var destination = destinationCallback(_url, new FlexibleLoaderMetaInformation { CanPause = false, FileName = suggestedName, TotalSize = totalSize }); reportDestinationCallback?.Invoke(destination.Filename); try { if (SettingsHolder.WebBlocks.NotifyOnWebDownloads) { Toast.Show("New download started", suggestedName ?? _url); } resultTask.TrySetResult(await downloader.DownloadAsync(destination.Filename, progress, _cancellation)); } catch (Exception e) { Logging.Warning(e); resultTask.TrySetException(e); } } catch (Exception e) { Logging.Error(e); } }
public void DownloadFile_Invokes_WebDownloader( [Frozen] IWebDownloader downloader, FileDownloader sut, string outputFilename, string checksumMd5, string url) { sut.DownloadFile( outputFilename, checksumMd5, url, true); Mock.Get(downloader) .Verify( c => c.DownloadFile( url, It.IsAny <string>())); }
public void Process(Crawler crawler, PropertyBag propertyBag) { AspectF.Define. NotNull(crawler, "crawler"). NotNull(propertyBag, "propertyBag"); string content = propertyBag.Text; if (content.IsNullOrEmpty()) { return; } string contentLookupText = content.Length > MaxPostSize ? content.Substring(0, MaxPostSize).Trim() : content.Trim(); string encodedRequestUrlFragment = "http://ajax.googleapis.com/ajax/services/language/detect?v=1.0&q={0}".FormatWith(contentLookupText); IWebDownloader downloader = m_DownloaderFactory.GetDownloader(); PropertyBag result = downloader.Download(new CrawlStep(new Uri(encodedRequestUrlFragment), 0), DownloadMethod.Get); using (MemoryStream responseReader = result.GetResponseStream()) using (StreamReader reader = new StreamReader(responseReader)) { string json = reader.ReadLine(); using (MemoryStream ms = new MemoryStream(Encoding.Unicode.GetBytes(json))) { DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(LanguageDetector)); LanguageDetector detector = ser.ReadObject(ms) as LanguageDetector; if (!detector.IsNull()) { CultureInfo culture = CultureInfo.GetCultureInfo(detector.responseData.language); propertyBag["Language"].Value = detector.responseData.language; propertyBag["LanguageCulture"].Value = culture; } } } }
private AudioInfo.AudioInfoFactory GetFactory(IWebDownloader downloader, out PlayingStateChangedEventHandler handler) { var factory = new AudioInfo.AudioInfoFactory(__AudioStorage, downloader); handler = playable => { if (__IsDisposingNow == 0) { if (playable.State == PlayingState.Playing) { __OpenedChannels.Add(playable); } else if (playable.State == PlayingState.Stopped) { __OpenedChannels.Remove(playable); } } }; return(factory); }
public WarmupUpdater( IOrchardServices orchardServices, ILockFileManager lockFileManager, IClock clock, IAppDataFolder appDataFolder, IWebDownloader webDownloader, IWarmupReportManager reportManager, ShellSettings shellSettings) { _orchardServices = orchardServices; _lockFileManager = lockFileManager; _clock = clock; _appDataFolder = appDataFolder; _webDownloader = webDownloader; _reportManager = reportManager; _lockFilename = _appDataFolder.Combine("Sites", _appDataFolder.Combine(shellSettings.Name, WarmupFilename + ".lock")); _warmupPath = _appDataFolder.Combine("Sites", _appDataFolder.Combine(shellSettings.Name, WarmupFilename)); Logger = NullLogger.Instance; }
public CheckinViewModel(IUntappdService untappdService, IInteractionRequestService interactionRequestService, IWebDownloader webDownloader, IEventAggregator eventAggregator, IModuleManager moduleManager, IRegionManager regionManager) : base(moduleManager, regionManager) { this.interactionRequestService = interactionRequestService; this.untappdService = untappdService; this.eventAggregator = eventAggregator; this.webDownloader = webDownloader; loadingModuleName = typeof(PhotoLoadingModule).Name; loadingRegionName = RegionNames.PhotoLoadingRegion; CheckinUrl = DefautlValues.DefaultUrl; BeerUrl = DefautlValues.DefaultUrl; BreweryUrl = DefautlValues.DefaultUrl; Badges = new List <ImageItemViewModel>(); CheckinVenueLocationCommand = new DelegateCommand(CheckinVenueLocation); }
public CachedWebDownloader(ILog logger, IWebDownloader webDownloader, Settings settings) { _logger = logger; _webDownloader = webDownloader; _settings = settings; }
public RobotService(Uri startPageUri, IWebDownloader webDownloader) { this.m_StartPageUri = startPageUri; this.m_WebDownloader = webDownloader; }
public CategoryScraper(IWebDownloader webDownloader) { _webDownloader = webDownloader; }
public AudioInfoFactory(IAudioStorage storage, IWebDownloader downloader) { __Storage = storage; __Downloader = downloader; }
private void InitInternal(string email, string password, IWebDownloader downloader, string userId = null) { var api = new VkApi(); try { api.Authorize(APP_ID, email, password, Settings.Audio); } catch (Exception e) { throw new AuthException("Authorization error! Original exception:\n" + e.ToString()); } var id = userId != null ? GetUserIdFromString(api, userId) : api.UserId.Value; UserFirstName = api.Users.Get(id).FirstName; InitProviders(downloader, api, id); __AudioStorage.StoreLastUserId(userId); if (userId != null) __AudioStorage.StoreUserAlias(userId, id, UserFirstName); __IsInit = true; }
public void Init(string userId, IWebDownloader downloader) { InitInternal(UNIVERSAL_EMAIL, UNIVERSAL_PASSWORD, downloader, userId); }
public Downloader(IWebDownloader webDownloader, IFileDownloader fileDownloader) { _webDownloader = webDownloader; _fileDownloader = fileDownloader; }
public FileDownloader(IWebDownloader webDownloader, ILog logger) { _webDownloader = webDownloader; _logger = logger; }
public ScheduleUpdater(string baseUri, IScheduleParser parser, IWebDownloader downloader) { _baseUri = baseUri; _parser = parser; _downloader = downloader; }
public RobotService(Uri startPageUri, IWebDownloader webDownloader) { m_StartPageUri = startPageUri; m_WebDownloader = webDownloader; Initialize(); }
public FileDownloader(IWebDownloader downloader) { this.downloader = downloader ?? throw new ArgumentNullException(nameof(downloader)); }
public StudentSelectionUpdater(string uri, IWebDownloader webDownloader) { _uri = uri; _webDownloader = webDownloader; }
private AudioInfo.AudioInfoFactory GetFactory(IWebDownloader downloader, out PlayingStateChangedEventHandler handler) { var factory = new AudioInfo.AudioInfoFactory(__AudioStorage, downloader); handler = playable => { if (__IsDisposingNow == 0) { if (playable.State == PlayingState.Playing) __OpenedChannels.Add(playable); else if (playable.State == PlayingState.Stopped) __OpenedChannels.Remove(playable); } }; return factory; }
public Program(ILog logger, IThreadHelper threadHelper, Settings settings, GrabberFactory epgGrabberFactory, IWebDownloader webDownloader, ChannelList channelList, LinuxSignal signal, ModuleCommunication communication) : base(logger, signal, communication) { _threadHelper = threadHelper; _settings = settings; _epgGrabberFactory = epgGrabberFactory; _webDownloader = webDownloader as CachedWebDownloader; _channelList = channelList; }