//Methods public async void RunDownloads() { Console.WriteLine("RunDownloads Started"); while (true) { MainWindow.SaveDownloads(); cts = new CancellationTokenSource(); List <Download> incompleteDownloads = new List <Download>(); foreach (Download download in downloads) { if (download.Status == "Queued") { incompleteDownloads.Add(download); } } Console.WriteLine("Checking for Downloads..."); if (incompleteDownloads.Count >= 1) { Download currentDownload = incompleteDownloads[0]; currentDownload.IsAlive = true; if ((currentDownload.YoutubeID != "") && (currentDownload.YoutubeID != null)) { string itemUrl = "https://www.youtube.com/watch?v=" + currentDownload.YoutubeID; try { if (Properties.Settings.Default.enableLocalYouTubeDownload) { await CustomLevelService.CreateWithLocalMP3Download(itemUrl, currentDownload, httpClient, cts); } else { await DownloadManager.RetrieveMetaData(itemUrl, currentDownload); } } catch { currentDownload.Status = "Unable To Retrieve Metadata"; } currentDownload.IsAlive = false; cts.Dispose(); } else if ((currentDownload.FilePath != "") && (currentDownload.FilePath != null)) { try { await CustomLevelService.CreateFromFile(currentDownload, httpClient, cts); } catch { currentDownload.Status = "Unable To Create Level"; } currentDownload.IsAlive = false; cts.Dispose(); } } cts.Dispose(); System.Threading.Thread.Sleep(1000); } }
public static async Task CreateCustomLevelWithLocalMP3Download(string url, Download download) { await CustomLevelService.CreateWithLocalMP3Download(url, download, httpClient, cts); }