Esempio n. 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();
        }
Esempio n. 2
0
 public void OnJobFinished(DownloadJob job)
 {
     if (job.Result == DownloadJob.JobResult.SUCCESS)
     {
         SuccessfulDownloads.Enqueue(job);
     }
     else
     {
         FailedDownloads.Enqueue(job);
     }
 }
Esempio n. 3
0
 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
 }
Esempio n. 4
0
 private void ExportIdsToFile()
 {
     try
     {
         lock (_commandLockObject)
         {
             _exportService.ExportToFile(FailedDownloads.ToList(), "failedDownloads", "https://www.twitch.tv/videos/{0}");
         }
     }
     catch (Exception ex)
     {
         _dialogService.ShowAndLogException(ex);
     }
 }
Esempio n. 5
0
 private void PurgeFailedDownloads()
 {
     try
     {
         lock (_commandLockObject)
         {
             _persistenceService.PurgeFailedDownloads();
             FailedDownloads.Clear();
         }
     }
     catch (Exception ex)
     {
         _dialogService.ShowAndLogException(ex);
     }
 }
Esempio n. 6
0
        private void ShowLog(string id)
        {
            try
            {
                lock (_commandLockObject)
                {
                    if (!string.IsNullOrWhiteSpace(id))
                    {
                        TwitchVideoDownload download = FailedDownloads.Where(q => q.Id == id).FirstOrDefault();

                        if (download != null)
                        {
                            _navigationService.ShowLog(download);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                _dialogService.ShowAndLogException(ex);
            }
        }
Esempio n. 7
0
        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();
        }
Esempio n. 8
0
        private void RemoveDownload(string id)
        {
            try
            {
                lock (_commandLockObject)
                {
                    if (!string.IsNullOrWhiteSpace(id))
                    {
                        var download = FailedDownloads.Where(q => q.Id == id).FirstOrDefault();

                        if (download != null)
                        {
                            _persistenceService.DeleteFailedRecord(download.Id);
                            _persistenceService.FailedDownloads.Remove(download);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                _dialogService.ShowAndLogException(ex);
            }
        }
Esempio n. 9
0
 public void ClearResultQueues()
 {
     SuccessfulDownloads.Clear();
     FailedDownloads.Clear();
 }