コード例 #1
0
ファイル: AudioPlayable.cs プロジェクト: Se11eR/Puckevich
        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;
            }
        }
コード例 #2
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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
 public void OnDownload(string url, string suggestedName, long totalSize, IWebDownloader downloader)
 {
     Logging.Write(url);
     ActionExtension.InvokeInMainThread(() => {
         new TemporaryFactoryAndLoader(url).RunAsync(suggestedName, totalSize, downloader).Ignore();
     });
 }
コード例 #5
0
        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;
        }
コード例 #6
0
        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;
            }
        }
コード例 #7
0
        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;
        }
コード例 #8
0
        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;
        }
コード例 #9
0
 public UserQueryExecutor(
     IUserQueryGenerator userQueryGenerator,
     ITwitterAccessor twitterAccessor,
     IWebHelper webHelper,
     IWebDownloader webDownloader)
 {
     _userQueryGenerator = userQueryGenerator;
     _twitterAccessor    = twitterAccessor;
     _webHelper          = webHelper;
     _webDownloader      = webDownloader;
 }
コード例 #10
0
        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);
        }
コード例 #11
0
ファイル: AudioInfo.cs プロジェクト: Se11eR/Puckevich
        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);
        }
コード例 #12
0
        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());
            }
        }
コード例 #13
0
        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);
        }
コード例 #14
0
ファイル: Crawler.cs プロジェクト: bormaxi/NCrawler
        /// <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);
        }
コード例 #15
0
            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);
                }
            }
コード例 #16
0
        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>()));
        }
コード例 #17
0
        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;
                        }
                    }
                }
        }
コード例 #18
0
        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);
        }
コード例 #19
0
ファイル: WarmupUpdater.cs プロジェクト: anycall/Orchard
        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;
        }
コード例 #20
0
        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);
        }
コード例 #21
0
        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;
        }
コード例 #22
0
 public CachedWebDownloader(ILog logger, IWebDownloader webDownloader, Settings settings)
 {
     _logger        = logger;
     _webDownloader = webDownloader;
     _settings      = settings;
 }
コード例 #23
0
 public RobotService(Uri startPageUri, IWebDownloader webDownloader)
 {
     this.m_StartPageUri  = startPageUri;
     this.m_WebDownloader = webDownloader;
 }
コード例 #24
0
 public CategoryScraper(IWebDownloader webDownloader)
 {
     _webDownloader = webDownloader;
 }
コード例 #25
0
 public AudioInfoFactory(IAudioStorage storage, IWebDownloader downloader)
 {
     __Storage    = storage;
     __Downloader = downloader;
 }
コード例 #26
0
ファイル: Account.cs プロジェクト: Se11eR/Puckevich
        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;
        }
コード例 #27
0
ファイル: Account.cs プロジェクト: Se11eR/Puckevich
 public void Init(string userId, IWebDownloader downloader)
 {
     InitInternal(UNIVERSAL_EMAIL, UNIVERSAL_PASSWORD, downloader, userId);
 }
コード例 #28
0
ファイル: Downloader.cs プロジェクト: jansaris/SettopBox
 public Downloader(IWebDownloader webDownloader, IFileDownloader fileDownloader)
 {
     _webDownloader  = webDownloader;
     _fileDownloader = fileDownloader;
 }
コード例 #29
0
ファイル: FileDownloader.cs プロジェクト: jansaris/SettopBox
 public FileDownloader(IWebDownloader webDownloader, ILog logger)
 {
     _webDownloader = webDownloader;
     _logger        = logger;
 }
コード例 #30
0
 public ScheduleUpdater(string baseUri, IScheduleParser parser, IWebDownloader downloader)
 {
     _baseUri    = baseUri;
     _parser     = parser;
     _downloader = downloader;
 }
コード例 #31
0
ファイル: AudioInfo.cs プロジェクト: Se11eR/Puckevich
 public AudioInfoFactory(IAudioStorage storage, IWebDownloader downloader)
 {
     __Storage = storage;
     __Downloader = downloader;
 }
コード例 #32
0
 public RobotService(Uri startPageUri, IWebDownloader webDownloader)
 {
     m_StartPageUri  = startPageUri;
     m_WebDownloader = webDownloader;
     Initialize();
 }
コード例 #33
0
 public FileDownloader(IWebDownloader downloader)
 {
     this.downloader = downloader ?? throw new ArgumentNullException(nameof(downloader));
 }
コード例 #34
0
 public StudentSelectionUpdater(string uri, IWebDownloader webDownloader)
 {
     _uri           = uri;
     _webDownloader = webDownloader;
 }
コード例 #35
0
ファイル: RobotService.cs プロジェクト: bormaxi/NCrawler
 public RobotService(Uri startPageUri, IWebDownloader webDownloader)
 {
     m_StartPageUri = startPageUri;
     m_WebDownloader = webDownloader;
     Initialize();
 }
コード例 #36
0
ファイル: Account.cs プロジェクト: Se11eR/Puckevich
        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);
        }
コード例 #37
0
ファイル: Account.cs プロジェクト: Se11eR/Puckevich
 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;
 }
コード例 #38
0
ファイル: Program.cs プロジェクト: jansaris/SettopBox
 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;
 }
コード例 #39
0
 public void Init(string userId, IWebDownloader downloader)
 {
     InitInternal(UNIVERSAL_EMAIL, UNIVERSAL_PASSWORD, downloader, userId);
 }