Beispiel #1
0
        private void ProcessDownloads(List <Playlist> playlists = null)
        {
            if (playlists == null)
            {
                playlists = new List <Playlist> {
                    _syncSaberSongs
                };
            }
            Logger.Debug("Processing downloads...");
            DownloadJob job;

            while (SuccessfulDownloads.TryDequeue(out job))
            {
                if (!_songDownloadHistory.Contains(job.Song.key))
                {
                    _songDownloadHistory.Add(job.Song.key);
                }

                RemoveOldVersions(job.Song.key);
            }
            while (FailedDownloads.TryDequeue(out job))
            {
                if (!_songDownloadHistory.Contains(job.Song.key) && job.Result != DownloadJob.JobResult.TIMEOUT)
                {
                    _songDownloadHistory.Add(job.Song.key);
                }
                // TODO: Be more specific/user friendly when outputting the reason.
                Logger.Error($"Failed to download {job.Song.key} by {job.Song.authorName}: {job.Result.ToString()}");
            }

            Utilities.WriteStringListSafe(_historyPath, _songDownloadHistory.Distinct().ToList(), true);
            //foreach (Playlist playlist in playlists)
            //playlist.WritePlaylist();
        }
Beispiel #2
0
 public void OnJobFinished(DownloadJob job)
 {
     if (job.Result == DownloadJob.JobResult.SUCCESS)
     {
         SuccessfulDownloads.Enqueue(job);
     }
     else
     {
         FailedDownloads.Enqueue(job);
     }
 }
 public void OnJobFinished(DownloadJob job)
 {
     if (job.Result == DownloadJob.JobResult.SUCCESS)
     {
         SuccessfulDownloads.Enqueue(job);
     }
     else
     {
         FailedDownloads.Enqueue(job);
     }
     // TODO: Add fail reason to FailedDownloads items
 }
        private void ProcessDownloads(List <Playlist> playlists = null)
        {
            if (playlists == null)
            {
                playlists = new List <Playlist>();
            }
            playlists.Add(_syncSaberSongs);
            Logger.Debug("Processing downloads...");
            DownloadJob job;

            while (SuccessfulDownloads.TryDequeue(out job))
            {
                if (!_songDownloadHistory.Contains(job.Song.key))
                {
                    _songDownloadHistory.Add(job.Song.key);
                }

                //UpdatePlaylist(_syncSaberSongs, job.Song.key, job.Song.name);
                foreach (var playlist in playlists)
                {
                    // TODO: fix this maybe
                    //UpdatePlaylist(playlist, job.Song.key, job.Song.name);
                }
                RemoveOldVersions(job.Song.key);
            }
            while (FailedDownloads.TryDequeue(out job))
            {
                if (!_songDownloadHistory.Contains(job.Song.key) && job.Result != DownloadJob.JobResult.TIMEOUT)
                {
                    _songDownloadHistory.Add(job.Song.key);
                }
                Logger.Error($"Failed to download {job.Song.key} by {job.Song.authorName}");
            }

            Utilities.WriteStringListSafe(_historyPath, _songDownloadHistory.Distinct().ToList(), true);
            //foreach (Playlist playlist in playlists)
            //playlist.WritePlaylist();
        }
Beispiel #5
0
 public void ClearResultQueues()
 {
     SuccessfulDownloads.Clear();
     FailedDownloads.Clear();
 }