Ejemplo n.º 1
0
        private void OnReadyToScrobble (object source, ScrobblingBatchEventArgs args)
        {
            var scrobble_job = new UserJob (Catalog.GetString ("Scrobbling from device"),
                                            Catalog.GetString ("Scrobbling from device..."));

            scrobble_job.PriorityHints = PriorityHints.DataLossIfStopped;
            scrobble_job.Register ();

            try {
                if (!connection.Started) {
                    connection.Start ();
                }
    
                int added_track_count = 0, processed_track_count = 0;
                string message = Catalog.GetString ("Processing track {0} of {1} ...");
                var batchCount = args.ScrobblingBatch.Count;
    
                foreach (var track_entry in args.ScrobblingBatch) {
                    TrackInfo track = track_entry.Key;
    
                    if (IsValidForSubmission (track)) {
                        IList<DateTime> playtimes = track_entry.Value;
    
                        foreach (DateTime playtime in playtimes) {
                            queue.Add (track, playtime);
                            added_track_count++;
                        }
                        Log.DebugFormat ("Added to Last.fm queue: {0} - Number of plays: {1}", track, playtimes.Count);
                    } else {
                        Log.DebugFormat ("Track {0} failed validation check for Last.fm submission, skipping...",
                                         track);
                    }
    
                    scrobble_job.Status = String.Format (message, ++processed_track_count, batchCount);
                    scrobble_job.Progress = processed_track_count / (double) batchCount;
                }
    
                Log.InformationFormat ("Number of played tracks from device added to Last.fm queue: {0}", added_track_count);

            } finally {
                scrobble_job.Finish ();
            }
        }
Ejemplo n.º 2
0
        private void RaiseReadyToScrobble ()
        {
            var handler = ReadyToScrobble;
            if (handler != null) {
                var recent_plays = new ScrobblingBatchEventArgs {
                    ScrobblingBatch = GatherRecentPlayInfo ()
                };
                if (recent_plays.ScrobblingBatch.Count != 0) {
                    handler (this, recent_plays);

                    // We must perform a write to clear out the recent playcount information so we do not
                    // submit duplicate plays on subsequent invocations.
                    lock (write_mutex) {
                        MediaDatabase.Write ();
                    }
                }
            }
        }
Ejemplo n.º 3
0
        private void OnReadyToScrobble(object source, ScrobblingBatchEventArgs args)
        {
            if (!connection.Started) {
                connection.Start ();
            }

            int added_track_count = 0;

            foreach (var track_entry in args.ScrobblingBatch) {
                TrackInfo track = track_entry.Key;

                if (IsValidForSubmission (track)) {
                    IList<DateTime> playtimes = track_entry.Value;

                    foreach (DateTime playtime in playtimes) {
                        queue.Add (track, playtime);
                        added_track_count++;
                    }
                    Log.DebugFormat ("Added to Last.fm queue: {0} - Number of plays: {1}", track, playtimes.Count);
                } else {
                    Log.DebugFormat ("Track {0} failed validation check for Last.fm submission, skipping...",
                                     track);
                }
            }

            Log.InformationFormat ("Number of played tracks from device added to Last.fm queue: {0}", added_track_count);
        }