Exemple #1
0
        public async Task ProcessScrobble(TrackScrobble scrobble, IScrobbler scrobbler, CancellationToken cancellationToken)
        {
            await EnsureLoaded(cancellationToken);

            scrobblesQueue.Enqueue(scrobble);
            await SaveScrobblesQueue(cancellationToken);

            while (scrobblesQueue.Any())
            {
                var currentScrobble = scrobblesQueue.Peek();

                try
                {
                    await scrobbler.Scrobble(currentScrobble, cancellationToken);
                }
#pragma warning disable CA1031 // Do not catch general exception types
                catch (Exception e)
#pragma warning restore CA1031 // Do not catch general exception types
                {
                    logger.LogWarning($"Scrobble failed: {currentScrobble}. Error: {e.Message}. Scrobbles queue size: {scrobblesQueue.Count}");
                    break;
                }

                scrobblesQueue.Dequeue();
            }

            await SaveScrobblesQueue(cancellationToken);
        }
 public WebScrobblingPlayer(ICurrentDateTime currentDateTime, IScrobblingRules scrobblingRules, IScrobbler scrobbler, IPlayProgress playProgress)
 {
     _currentDateTime = currentDateTime;
     _playProgress    = playProgress;
     _scrobblingRules = scrobblingRules;
     _scrobbler       = scrobbler;
 }
 public ScrobblingPlayer(IPlayer player, IScrobblingRules scrobblingRules, IScrobbler scrobbler, ICurrentDateTime currentDateTime,
                         IPlayProgressTracker playProgressTracker)
 {
     _currentDateTime     = currentDateTime;
     _player              = player;
     _scrobblingRules     = scrobblingRules;
     _scrobbler           = scrobbler;
     _playProgressTracker = playProgressTracker;
 }
Exemple #4
0
        public ErrorHandlingScrobbler(IScrobbler scrobbler, IUserSettings userSettings, IAsyncMethodInterceptor asyncMethodInterceptor,
                                      IScrobbleCacher scrobbleCacher)
        {
            _asyncMethodInterceptor = asyncMethodInterceptor;
            _scrobbleCacher         = scrobbleCacher;
            _scrobbler    = scrobbler;
            _userSettings = userSettings;

            _userSettings.ScrobblingStatusChanged += OnScrobblingStatusChanged;
        }
 public PersistentScrobbler(IScrobbler scrobbler, IScrobblesProcessor scrobblesProcessor, ILogger <PersistentScrobbler> logger)
 {
     this.scrobbler          = scrobbler ?? throw new ArgumentNullException(nameof(scrobbler));
     this.scrobblesProcessor = scrobblesProcessor ?? throw new ArgumentNullException(nameof(scrobblesProcessor));
     this.logger             = logger ?? throw new ArgumentNullException(nameof(logger));
 }
 public SongPlaybacksRegistrar(ISongsService songsService, IScrobbler scrobbler, IClock clock)
 {
     this.songsService = songsService ?? throw new ArgumentNullException(nameof(songsService));
     this.scrobbler    = scrobbler ?? throw new ArgumentNullException(nameof(scrobbler));
     this.clock        = clock ?? throw new ArgumentNullException(nameof(clock));
 }
		public ScrobblingMonitor (IScrobbler scrobbler)
		{
			Scrobbler = scrobbler;
			ProgressChanged += ScrobblingMonitor_ProgressChanged;
		}