Esempio n. 1
0
 public async void GetDownOk()
 {
     try
     {
         DownloadManage.Downloaded.Clear();
         await Task.Run(async() =>
         {
             StorageFolder DownFolder = await KnownFolders.VideosLibrary.CreateFolderAsync("Bili-Down", CreationCollisionOption.OpenIfExists);
             //List<DownloadManage.FolderModel> list = new List<DownloadManage.FolderModel>();
             foreach (var item in await DownFolder.GetFoldersAsync())
             {
                 //DownloadManage.FolderModel model = new DownloadManage.FolderModel()
                 //{
                 //    title = item.Name,
                 //    count = 0,
                 //    downedCount = 0,
                 //};
                 //List<DownloadManage.DownModel> list_file = new List<DownloadManage.DownModel>();
                 foreach (var item1 in await item.GetFoldersAsync())
                 {
                     foreach (var item2 in await item1.GetFilesAsync())
                     {
                         if (item2.FileType == ".json")
                         {
                             StorageFile files = item2;
                             string json       = await FileIO.ReadTextAsync(item2);
                             DownloadManage.DownModel model123 = JsonConvert.DeserializeObject <DownloadManage.DownModel>(json);
                             if (model123.downloaded == true)
                             {
                                 ///list_file.Add(model123);
                                 //model.downedCount++;
                                 DownloadManage.Downloaded.Add(model123.mid);
                             }
                             //model.aid = model123.aid;
                         }
                     }
                     //model.count++;
                 }
                 //model.path = item.Path;
                 //model.downModel = list_file;
                 //list.Add(model);
             }
         });
     }
     catch (Exception)
     {
     }
 }
Esempio n. 2
0
 private async void btn_OK_Click(object sender, RoutedEventArgs e)
 {
     using (DownloadManage wc = new DownloadManage())
     {
         if (list_E.SelectedItems.Count != 0)
         {
             //循环读取全部选中的项目
             foreach (BangumiInfoModel item in list_E.SelectedItems)
             {
                 int quality = cb_Qu.SelectedIndex + 1;//清晰度1-3
                 string Downurl = await wc.GetVideoUri(item.danmaku.ToString(), quality);//取得视频URL
                 if (Downurl != null)
                 {
                     DownloadManage.DownModel model = new DownloadManage.DownModel()
                     {
                         mid = item.danmaku.ToString(),
                         title = "【番剧】"+txt_Name.Text,
                         part = item.index,
                         url = Downurl,
                         aid = banID,
                         danmuUrl = "http://comment.bilibili.com/" + item.danmaku + ".xml",
                         quality = quality,
                         downloaded = false,
                         partTitle = item.index_title??"",
                         isBangumi = true
                     };
                     wc.StartDownload(model);
                     //StartDownload(model);
                 }
                 else
                 {
                     MessageDialog md = new MessageDialog(item.title + "\t视频地址获取失败");
                     await md.ShowAsync();
                 }
             }
             messShow.Show("任务已加入下载队列", 3000);
             list_E.SelectionMode = ListViewSelectionMode.None;
             list_E.IsItemClickEnabled = true;
             com_bar_Down.Visibility = Visibility.Collapsed;
             com_bar.Visibility = Visibility.Visible;
         }
         else
         {
             list_E.SelectionMode = ListViewSelectionMode.None;
             list_E.IsItemClickEnabled = true;
             com_bar_Down.Visibility = Visibility.Collapsed;
             com_bar.Visibility = Visibility.Visible;
         }
     }
 }