Beispiel #1
0
 public async static void SaveDB()
 {
     try
     {
         var str = JsonConvert.SerializeObject(downloadDatas);
         await LocalStorageFunc.SaveVideoFile(DownloadFileDB, str);
     }
     catch
     {
     }
 }
Beispiel #2
0
        private async void DoBackgroundDownload(VideoDetail vd, VideosSource vs)
        {
            var downloadData = new DownloadData();

            downloadData.content = vd;
            int i = 0;

            foreach (var item in vs.RealUrl)
            {
                var filename = vd.ACTitle + "_" + vd.Title + "_" + i + ".flv";

                filename = filename.Replace("\\", "").Replace("/", "").Replace(":", "").Replace("*", "").Replace("?", "").
                           Replace("\"", "").Replace("<", "").Replace(">", "").Replace("|", "");
                var uri = new Uri(item);
                downloadData.VideoFiles.Add(filename);
                i++;
                //  List<Task> task = new List<Task>();
                try
                {
                    //task.Add(StartOneDownload(filename, uri, downloadData));
                    StartOneDownload(filename, uri, downloadData);
                }
                catch (Exception ex)
                {
                    LocalStorageFunc.DeleteVideoFile(filename);

                    foreach (var dd in downloadDatas)
                    {
                        if (dd.content.DanmakuId == vd.DanmakuId)
                        {
                            downloadDatas.Remove(dd);
                            break;
                        }
                    }
                    MSGSHOW("下载错误:\r\n     " + ex.Message);
                    return;
                }
                finally
                {
                }
            }

            downloadDatas.Add(downloadData);
        }
Beispiel #3
0
        public static async Task <List <DownloadData> > GetDownloadData()
        {
            var stream = await LocalStorageFunc.OpenVideoFile(DownloadFileDB);

            if (stream == null)
            {
                downloadDatas = new List <DownloadData>();
                return(downloadDatas);
            }

            try
            {
                var sr = new StreamReader(stream).ReadToEnd();
                downloadDatas = JsonConvert.DeserializeObject <List <DownloadData> >(sr);
            }
            catch
            {
                downloadDatas = new List <DownloadData>();
            }

            return(downloadDatas);
        }