Beispiel #1
0
        private async void DownLoad(object o)
        {
            Semaphore.WaitOne();
            Actress actress = o as Actress;

            if (Cancel | actress.id == "")
            {
                Semaphore.Release();
                return;
            }
            try
            {
                this.State = DownLoadState.DownLoading;

                //下载头像
                if (!string.IsNullOrEmpty(actress.imageurl))
                {
                    string url        = actress.imageurl;
                    byte[] imageBytes = null;
                    imageBytes = await Task.Run(() => { return(Net.DownLoadFile(url).filebytes); });

                    if (imageBytes != null)
                    {
                        ImageProcess.SaveImage(actress.name, imageBytes, ImageType.ActorImage, url);
                        actress.smallimage = ImageProcess.GetBitmapImage(actress.name, "Actresses");
                    }
                }
                //下载信息
                bool success = false;
                success = await Task.Run(() =>
                {
                    Task.Delay(300).Wait();
                    return(Net.DownActress(actress.id, actress.name, callback: (message) => { MessageCallBack?.Invoke(this, new MessageCallBackEventArgs(message)); }));
                });

                if (success)
                {
                    actress = DataBase.SelectInfoFromActress(actress);
                }
                ProgressBarUpdate.value += 1;
                InfoUpdate?.Invoke(this, new ActressUpdateEventArgs()
                {
                    Actress = actress, progressBarUpdate = ProgressBarUpdate, state = State
                });
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                Semaphore.Release();
            }
        }
Beispiel #2
0
        public void BeginDownLoad()
        {
            if (ActorList.Count == 0)
            {
                this.State = DownLoadState.Completed; return;
            }


            //先根据 BusActress.sqlite 获得 id
            List <Actress> actresslist = new List <Actress>();

            foreach (Actress item in ActorList)
            {
                if (item != null && (item.smallimage == null || string.IsNullOrEmpty(item.birthday)))
                {
                    Actress  actress = item;
                    MySqlite db      = new MySqlite("BusActress");
                    if (item.id == "")
                    {
                        actress.id = db.GetInfoBySql($"select id from censored where name='{item.name}'");
                        if (item.imageurl == null)
                        {
                            actress.imageurl = db.GetInfoBySql($"select smallpicurl from censored where id='{actress.id}'");
                        }
                    }
                    else
                    {
                        if (item.imageurl == null)
                        {
                            actress.imageurl = db.GetInfoBySql($"select smallpicurl from censored where id='{actress.id}'");
                        }
                    }
                    db.CloseDB();
                    actresslist.Add(actress);
                }
            }

            ProgressBarUpdate.maximum = actresslist.Count;
            //TODO
            for (int i = 0; i < actresslist.Count; i++)
            {
                Console.WriteLine("开始进程 " + i);
                Thread threadObject = new Thread(DownLoad);
                threadObject.Start(actresslist[i]);
            }
        }
Beispiel #3
0
        //下载
        public void StartThread()
        {
            if (Movies.Count == 0 & MoviesFC2.Count == 0)
            {
                this.State = DownLoadState.Completed; return;
            }
            for (int i = 0; i < Movies.Count; i++)
            {
                Thread threadObject = new Thread(DownLoad);
                threadObject.Start(Movies[i]);
            }

            for (int i = 0; i < MoviesFC2.Count; i++)
            {
                Thread threadObject = new Thread(DownLoad);
                threadObject.Start(MoviesFC2[i]);
            }
        }
Beispiel #4
0
        public void BeginDownLoad()
        {
            if (ActorList.Count == 0)
            {
                this.State = DownLoadState.Completed; return;
            }


            //先根据 BusActress.sqlite 获得 id
            List <Actress> actresslist = new List <Actress>();

            foreach (Actress item in ActorList)
            {
                if (item != null && (item.smallimage == null || string.IsNullOrEmpty(item.birthday)))
                {
                    Actress  actress = item;
                    MySqlite db      = new MySqlite("BusActress");
                    if (string.IsNullOrEmpty(item.id))
                    {
                        actress.id = db.GetInfoBySql($"select id from censored where name='{item.name}'");
                    }
                    db.CloseDB();
                    if (string.IsNullOrEmpty(item.imageurl))
                    {
                        //TODO 没法解决演员头像骑兵和步兵的问题
                        //默认骑兵吧,反正拍过步兵的肯定也拍过骑兵
                        //拼接网址
                        actress.imageurl = $"{JvedioServers.Bus.Url}pics/actress/{item.id}_a.jpg";
                    }

                    actresslist.Add(actress);
                }
            }

            ProgressBarUpdate.maximum = actresslist.Count;
            for (int i = 0; i < actresslist.Count; i++)
            {
                Console.WriteLine("开始进程 " + i);
                Thread threadObject = new Thread(DownLoad);
                threadObject.Start(actresslist[i]);
            }
        }
Beispiel #5
0
        /// <summary>
        /// 开始下载
        /// </summary>
        public void StartThread()
        {
            if (Movies.Count == 0 & MoviesFC2.Count == 0)
            {
                this.State = DownLoadState.Completed; return;
            }
            for (int i = 0; i < Movies.Count; i++)
            {
                Thread threadObject = new Thread(DownLoad);
                threadObject.Start(Movies[i]);
            }

            for (int i = 0; i < MoviesFC2.Count; i++)
            {
                Thread threadObject = new Thread(DownLoad);
                threadObject.Start(MoviesFC2[i]);
            }

            Console.WriteLine($"启动了{Movies.Count+ MoviesFC2.Count}个线程");
        }
Beispiel #6
0
        private static void GetObjectCallback(IAsyncResult ar)
        {
            OssClient ossClient = new OssClient(Config.Endpoint, Config.AccessKeyId, Config.AccessKeySecret);

            try
            {
                var result = ossClient.EndGetObject(ar);
                Debug.LogError("total length:" + result.Metadata.ContentLength);
                int downloadLen = 0;
                using (var requestStream = result.Content)
                {
                    using (var fs = File.Open(Config.DirToDownload + "/" + (ar.AsyncState as string), FileMode.OpenOrCreate))
                    {
                        int length = 4 * 1024;
                        var buf    = new byte[length];
                        do
                        {
                            length = requestStream.Read(buf, 0, length);
                            fs.Write(buf, 0, length);
                            downloadLen       += length;
                            m_DownLoadProgress = (float)downloadLen / result.Metadata.ContentLength;
                            m_DownLoadState    = DownLoadState.DOWNLOADING;
                        } while (length != 0);
                    }
                }
                m_DownLoadState = DownLoadState.DOWNLOADCOMPLETE;
                Debug.LogError("download done!");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                _event.Set();
            }
        }
Beispiel #7
0
        private async void DownLoad(object o)
        {
            //下载信息=>下载图片
            Movie movie = o as Movie;

            try
            {
                if (movie.id.ToUpper().IndexOf("FC2") >= 0)
                {
                    SemaphoreFC2.WaitOne();
                }
                else
                {
                    Semaphore.WaitOne();
                }
                if (Cancel | movie.id == "")
                {
                    return;
                }
                bool success; string resultMessage;
                //下载信息
                State = DownLoadState.DownLoading;
                if (movie.title == "" | movie.smallimageurl == "" | movie.bigimageurl == "" | movie.sourceurl == "")
                {
                    (success, resultMessage) = await Task.Run(() => { return(Net.DownLoadFromNet(movie)); });

                    if (success)
                    {
                        InfoUpdate?.Invoke(this, new InfoUpdateEventArgs()
                        {
                            Movie = movie, progress = downLoadProgress.value
                        });                                                                                                               //委托到主界面显示
                    }
                }


                DetailMovie dm = new DetailMovie();
                dm = DataBase.SelectDetailMovieById(movie.id);
                //下载小图
                await DownLoadSmallPic(dm);

                dm.smallimage = StaticClass.GetBitmapImage(dm.id, "SmallPic");
                InfoUpdate?.Invoke(this, new InfoUpdateEventArgs()
                {
                    Movie = dm, progress = downLoadProgress.value, state = State
                });                                                                                                                  //委托到主界面显示


                if (dm.sourceurl?.IndexOf("fc2club") >= 0)
                {
                    //复制大图
                    if (File.Exists(StaticVariable.BasePicPath + $"SmallPic\\{dm.id}.jpg") & !File.Exists(StaticVariable.BasePicPath + $"BigPic\\{dm.id}.jpg"))
                    {
                        File.Copy(StaticVariable.BasePicPath + $"SmallPic\\{dm.id}.jpg", StaticVariable.BasePicPath + $"BigPic\\{dm.id}.jpg");
                    }
                }
                else
                {
                    //下载大图
                    await DownLoadBigPic(dm);
                }
                dm.bigimage = StaticClass.GetBitmapImage(dm.id, "BigPic");
                lock (downLoadProgress.lockobject) downLoadProgress.value += 1;
                InfoUpdate?.Invoke(this, new InfoUpdateEventArgs()
                {
                    Movie = dm, progress = downLoadProgress.value, state = State
                });                                                                                                                  //委托到主界面显示

                Task.Delay(1000).Wait();
            }
            catch (Exception e)
            {
                Logger.LogE(e);
            }
            finally
            {
                if (movie.id.ToUpper().IndexOf("FC2") >= 0)
                {
                    SemaphoreFC2.Release();
                }
                else
                {
                    Semaphore.Release();
                }
            }
        }
Beispiel #8
0
 public AssetBundleLoader(string path, string fileName, Type type, string assetName = null, bool cache = false, DownLoadState state = DownLoadState.Init, bool isScene = false, bool asynLoad = false)
 {
     this.path      = path;
     this.fileName  = fileName;
     this.assetName = assetName;
     this.state     = state;
     this.isScene   = isScene;
     this.assetType = type;
     this.asynLoad  = asynLoad;
 }
Beispiel #9
0
        private async void DownLoad(object o)
        {
            DownLoadInfo downLoadInfo = o as DownLoadInfo;

            try
            {
                if (downLoadInfo.id.ToUpper().IndexOf("FC2") >= 0)
                {
                    SemaphoreFC2.WaitOne();
                }
                else
                {
                    Semaphore.WaitOne();
                }
                if (Cancel)
                {
                    return;
                }
                while (Pause & !Cancel)
                {
                    Task.Delay(300).Wait();
                }


                this.State = DownLoadState.DownLoading;

                DataBase cdb   = new DataBase("");
                Movie    movie = await cdb.SelectMovieByID(downLoadInfo.id);

                cdb.CloseDB();

                string[] url       = new string[] { Properties.Settings.Default.Bus, Properties.Settings.Default.BusEurope, Properties.Settings.Default.DB, Properties.Settings.Default.Library };
                bool[]   enableurl = new bool[] { Properties.Settings.Default.EnableBus, Properties.Settings.Default.EnableBusEu, Properties.Settings.Default.EnableDB, Properties.Settings.Default.EnableLibrary, Properties.Settings.Default.EnableFC2 };
                string[] cookies   = new string[] { Properties.Settings.Default.DBCookie };

                if (movie.title == "" | movie.smallimageurl == "" | movie.bigimageurl == "" | movie.sourceurl == "")
                {
                    await Task.Run(() => { return(Net.DownLoadFromNet(movie)); });
                }


                //写入NFO
                //if (Properties.Settings.Default.DLNFO)
                //    SaveToNFO(dm, GetNfoPath(dm));

                cdb   = new DataBase("");
                movie = await cdb.SelectMovieByID(downLoadInfo.id);

                cdb.CloseDB();


                //更新总进度
                List <string> extrapicurlList = new List <string>();
                var           list            = movie.extraimageurl.Split(';');
                foreach (var item in list)
                {
                    if (!string.IsNullOrEmpty(item))
                    {
                        extrapicurlList.Add(item);
                    }
                }

                downLoadInfo.maximum  = extrapicurlList.Count;
                downLoadInfo.maximum += 2;

                //小图
                await DownLoadSmallPic(movie);

                downLoadInfo.progress += 1; InfoUpdate?.Invoke(this, new DownloadUpdateEventArgs()
                {
                    DownLoadInfo = downLoadInfo
                });                                                                                                                     //更新进度
                //大图
                await DownLoadBigPic(movie);

                downLoadInfo.progress += 1; InfoUpdate?.Invoke(this, new DownloadUpdateEventArgs()
                {
                    DownLoadInfo = downLoadInfo
                });                                                                                                                     //更新进度



                //预览图
                bool dlimageSuccess; string cookie = "";
                for (int i = 0; i < extrapicurlList.Count(); i++)
                {
                    if (!File.Exists(StaticVariable.BasePicPath + $"Extrapic\\{movie.id.ToUpper()}\\{movie.id.ToUpper()}.jpg"))
                    {
                        if (Cancel)
                        {
                            return;
                        }
                        while (Pause & !Cancel)
                        {
                            Task.Delay(300).Wait();
                        }
                        if (extrapicurlList[i].Length > 0)
                        {
                            (dlimageSuccess, cookie) = await DownLoadExtraPic(movie.id, extrapicurlList[i], cookie);

                            if (dlimageSuccess)
                            {
                                Task.Delay(1000).Wait();
                            }
                        }
                    }
                    downLoadInfo.progress += 1; InfoUpdate?.Invoke(this, new DownloadUpdateEventArgs()
                    {
                        DownLoadInfo = downLoadInfo
                    });                                                                                                                 //更新进度
                }
            }
            finally
            {
                if (downLoadInfo.id.ToUpper().IndexOf("FC2") >= 0)
                {
                    SemaphoreFC2.Release();
                }
                else
                {
                    Semaphore.Release();
                }
            }
        }
Beispiel #10
0
 public void PauseDownload()
 {
     Pause      = true;
     this.State = DownLoadState.Pause;
 }
Beispiel #11
0
 public NewNotiData(DownLoadState st, object param)
 {
     this.evState = st;
     this.evParam = param;
 }
Beispiel #12
0
        //下载
        private async Task <IRandomAccessStream> Download(Uri uri, DownLoadState downLoadState = DownLoadState.Start)
        {
            hc  = new HttpClient();
            cts = new CancellationTokenSource();
            byte[] bytes = null;
            IRandomAccessStream idaStream = null;

            if (downLoadState == DownLoadState.Start)
            {
                DownloadBytesCount = new DownLoadBytes();
                Bytes = new List <byte>();
                TriggerDownLoadChanging(new DownLoadChangingEventArgs(DownloadBytesCount, 0, bytes));
                if (percentage == 0)
                {
                    await GetTotalBytes(uri);
                }
            }
            if (downLoadState == DownLoadState.Continue)
            {
                await GetTotalBytes(uri);
            }

            try
            {
                //100, 10, 1
                for (int i = completePercentage; i < percentageCoefficient;)
                {
                    if (cts.IsCancellationRequested)
                    {
                        return(await this.ByteToInMemoryRandomAccessStream(bytes));
                    }

                    if (i == 0)
                    {
                        idaStream = (await DownLoadIRandomAccessStream(uri, i * percentage, (i + 1) * percentage, cts.Token));
                    }
                    else
                    {
                        idaStream = (await DownLoadIRandomAccessStream(uri, i * percentage + 1, (i + 1) * percentage, cts.Token));
                    }
                    if (idaStream != null)
                    {
                        bytes = Combine(idaStream);
                        DownloadBytesCount.BytesReceived = (i + 1) * percentage;
                        i++;
                        TriggerDownLoadChanging(new DownLoadChangingEventArgs(DownloadBytesCount, i * progressCoefficient, bytes));
                        if (i * progressCoefficient == 100)
                        {
                            TriggerDownLoadComplete(new DownLoadCompleteEventArgs((await this.ByteToInMemoryRandomAccessStream(bytes))));
                        }
                    }
                    else
                    {
                        return(await this.ByteToInMemoryRandomAccessStream(Bytes.ToArray()));
                    }
                }
                return(await this.ByteToInMemoryRandomAccessStream(bytes));
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                return(this.ByteToInMemoryRandomAccessStream(bytes).Result);
            }
        }
Beispiel #13
0
        private async void DownLoad(object o)
        {
            //下载信息=>下载图片
            Movie movie = o as Movie;

            if (movie.id.ToUpper().StartsWith("FC2"))
            {
                SemaphoreFC2.WaitOne();
            }
            else
            {
                Semaphore.WaitOne();                                                                   //阻塞
            }
            if (Cancel || string.IsNullOrEmpty(movie.id))
            {
                if (movie.id.ToUpper().StartsWith("FC2"))
                {
                    SemaphoreFC2.Release();
                }
                else
                {
                    Semaphore.Release();
                }
                return;
            }
            bool success; string resultMessage;

            //下载信息
            State = DownLoadState.DownLoading;
            if (Net.IsToDownLoadInfo(movie) || enforce)
            {
                //满足一定条件才下载信息
                (success, resultMessage) = await Task.Run(() => { return(Net.DownLoadFromNet(movie)); });

                InfoUpdate?.Invoke(this, new InfoUpdateEventArgs()
                {
                    Movie = movie, progress = downLoadProgress.value, Success = success
                });                                                                                                                      //委托到主界面显示
                if (!success)
                {
                    MessageCallBack?.Invoke(this, new MessageCallBackEventArgs($" {movie.id} {Jvedio.Language.Resources.DownloadMessageFailFor}:{(resultMessage.ToStatusMessage())}"));
                }
            }


            DetailMovie dm = new DetailMovie();

            dm = DataBase.SelectDetailMovieById(movie.id);

            if (!File.Exists(BasePicPath + $"BigPic\\{dm.id}.jpg") || enforce)
            {
                string message2 = "";
                (bool success2, string cookie2) = await Net.DownLoadImage(dm.bigimageurl, ImageType.BigImage, dm.id, callback : (sc) => { message2 = sc.ToString(); });//下载大图

                //if (!success2) MessageCallBack?.Invoke(this, new MessageCallBackEventArgs($" {dm.id} 海报图下载失败,原因:{message2.ToStatusMessage()}"));
            }



            //fc2 没有缩略图
            if (dm.id.IndexOf("FC2") >= 0)
            {
                //复制海报图作为缩略图
                if (File.Exists(BasePicPath + $"BigPic\\{dm.id}.jpg") && !File.Exists(BasePicPath + $"SmallPic\\{dm.id}.jpg"))
                {
                    File.Copy(BasePicPath + $"BigPic\\{dm.id}.jpg", BasePicPath + $"SmallPic\\{dm.id}.jpg");
                }
            }
            else
            {
                if (!File.Exists(BasePicPath + $"SmallPic\\{dm.id}.jpg") || enforce)
                {
                    string message = "";
                    (bool success1, string cookie) = await Net.DownLoadImage(dm.smallimageurl, ImageType.SmallImage, dm.id, callback : (sc) => { message = sc.ToString(); }); //下载小图

                    //if (!success1) MessageCallBack?.Invoke(this, new MessageCallBackEventArgs($" {dm.id} 缩略图下载失败,原因:{message.ToStatusMessage()}"));
                }
            }
            dm.smallimage = ImageProcess.GetBitmapImage(dm.id, "SmallPic");
            InfoUpdate?.Invoke(this, new InfoUpdateEventArgs()
            {
                Movie = dm, progress = downLoadProgress.value, state = State
            });                                                              //委托到主界面显示
            dm.bigimage = ImageProcess.GetBitmapImage(dm.id, "BigPic");
            lock (downLoadProgress.lockobject) downLoadProgress.value += 1;  //完全下载完一个影片
            InfoUpdate?.Invoke(this, new InfoUpdateEventArgs()
            {
                Movie = dm, progress = downLoadProgress.value, state = State, Success = true
            });                                //委托到主界面显示
            Task.Delay(DelayInvterval).Wait(); //每个线程之间暂停
            //取消阻塞
            if (movie.id.ToUpper().IndexOf("FC2") >= 0)
            {
                SemaphoreFC2.Release();
            }
            else
            {
                Semaphore.Release();
            }
        }
Beispiel #14
0
        private async void DownLoad(object o)
        {
            DownLoadInfo downLoadInfo = o as DownLoadInfo;

            try
            {
                if (downLoadInfo.id.ToUpper().IndexOf("FC2") >= 0)
                {
                    SemaphoreFC2.WaitOne();
                }
                else
                {
                    Semaphore.WaitOne();
                }
                if (Cancel)
                {
                    return;
                }
                while (Pause & !Cancel)
                {
                    Task.Delay(300).Wait();
                }


                this.State = DownLoadState.DownLoading;

                Movie movie = DataBase.SelectMovieByID(downLoadInfo.id);


                if (movie.title == "" | movie.smallimageurl == "" | movie.bigimageurl == "" | movie.sourceurl == "")
                {
                    await Task.Run(() => { return(Net.DownLoadFromNet(movie)); });
                }



                movie = DataBase.SelectMovieByID(downLoadInfo.id);



                //更新总进度
                List <string> extrapicurlList = new List <string>();
                var           list            = movie.extraimageurl.Split(';');
                foreach (var item in list)
                {
                    if (!string.IsNullOrEmpty(item))
                    {
                        extrapicurlList.Add(item);
                    }
                }

                downLoadInfo.maximum  = extrapicurlList.Count;
                downLoadInfo.maximum += 2;

                //小图
                await DownLoadSmallPic(movie);

                downLoadInfo.progress += 1; InfoUpdate?.Invoke(this, new DownloadUpdateEventArgs()
                {
                    DownLoadInfo = downLoadInfo
                });                                                                                                                     //更新进度
                //大图
                await DownLoadBigPic(movie);

                downLoadInfo.progress += 1; InfoUpdate?.Invoke(this, new DownloadUpdateEventArgs()
                {
                    DownLoadInfo = downLoadInfo
                });                                                                                                                     //更新进度



                //预览图
                bool dlimageSuccess; string cookie = "";
                for (int i = 0; i < extrapicurlList.Count(); i++)
                {
                    if (!File.Exists(GlobalVariable.BasePicPath + $"Extrapic\\{movie.id.ToUpper()}\\{movie.id.ToUpper()}.jpg"))
                    {
                        if (Cancel)
                        {
                            return;
                        }
                        while (Pause & !Cancel)
                        {
                            Task.Delay(300).Wait();
                        }
                        if (extrapicurlList[i].Length > 0)
                        {
                            (dlimageSuccess, cookie) = await DownLoadExtraPic(movie.id, extrapicurlList[i], cookie);

                            if (dlimageSuccess)
                            {
                                Task.Delay(1000).Wait();
                            }
                        }
                    }
                    downLoadInfo.progress += 1; InfoUpdate?.Invoke(this, new DownloadUpdateEventArgs()
                    {
                        DownLoadInfo = downLoadInfo
                    });                                                                                                                 //更新进度
                }
            }
            finally
            {
                if (downLoadInfo.id.ToUpper().IndexOf("FC2") >= 0)
                {
                    SemaphoreFC2.Release();
                }
                else
                {
                    Semaphore.Release();
                }
            }
        }
Beispiel #15
0
        private async void DownLoad(object o)
        {
            //下载信息
            Movie movie = o as Movie;

            if (movie.id.ToUpper().StartsWith("FC2"))
            {
                SemaphoreFC2.WaitOne();
            }
            else
            {
                Semaphore.WaitOne();//阻塞
            }
            if (Cancel || string.IsNullOrEmpty(movie.id))
            {
                if (movie.id.ToUpper().StartsWith("FC2"))
                {
                    SemaphoreFC2.Release();
                }
                else
                {
                    Semaphore.Release();
                }
                return;
            }

            //下载信息
            State = DownLoadState.DownLoading;
            if (movie.IsToDownLoadInfo() || enforce)
            {
                //满足一定条件才下载信息
                HttpResult httpResult = await Net.DownLoadFromNet(movie);

                if (httpResult != null)
                {
                    if (httpResult.Success)
                    {
                        InfoUpdate?.Invoke(this, new InfoUpdateEventArgs()
                        {
                            Movie = movie, progress = downLoadProgress.value, Success = httpResult.Success
                        });                                                                                                                                    //委托到主界面显示
                    }
                    else
                    {
                        string error = httpResult.Error != "" ? httpResult.Error : httpResult.StatusCode.ToStatusMessage();
                        MessageCallBack?.Invoke(this, new MessageCallBackEventArgs($" {movie.id} {Jvedio.Language.Resources.DownloadMessageFailFor}:{error}"));
                    }
                }
            }
            DetailMovie dm = DataBase.SelectDetailMovieById(movie.id);

            if (dm == null)
            {
                if (movie.id.ToUpper().StartsWith("FC2"))
                {
                    SemaphoreFC2.Release();
                }
                else
                {
                    Semaphore.Release();
                }
                return;
            }

            if (!File.Exists(BasePicPath + $"BigPic\\{dm.id}.jpg") || enforce)
            {
                await Net.DownLoadImage(dm.bigimageurl, ImageType.BigImage, dm.id);//下载大图
            }



            //fc2 没有缩略图
            if (dm.id.IndexOf("FC2") >= 0)
            {
                //复制海报图作为缩略图
                if (File.Exists(BasePicPath + $"BigPic\\{dm.id}.jpg") && !File.Exists(BasePicPath + $"SmallPic\\{dm.id}.jpg"))
                {
                    try {
                        File.Copy(BasePicPath + $"BigPic\\{dm.id}.jpg", BasePicPath + $"SmallPic\\{dm.id}.jpg");
                    }
                    catch (Exception ex)
                    {
                        Logger.LogF(ex);
                    }
                }
            }
            else
            {
                if (!File.Exists(BasePicPath + $"SmallPic\\{dm.id}.jpg") || enforce)
                {
                    await Net.DownLoadImage(dm.smallimageurl, ImageType.SmallImage, dm.id); //下载小图
                }
            }
            dm.smallimage = ImageProcess.GetBitmapImage(dm.id, "SmallPic");
            InfoUpdate?.Invoke(this, new InfoUpdateEventArgs()
            {
                Movie = dm, progress = downLoadProgress.value, state = State
            });                                                              //委托到主界面显示
            dm.bigimage = ImageProcess.GetBitmapImage(dm.id, "BigPic");
            lock (downLoadProgress.lockobject) downLoadProgress.value += 1;  //完全下载完一个影片
            InfoUpdate?.Invoke(this, new InfoUpdateEventArgs()
            {
                Movie = dm, progress = downLoadProgress.value, state = State, Success = true
            });                                //委托到主界面显示
            Task.Delay(DelayInvterval).Wait(); //每个线程之间暂停
            //取消阻塞
            if (movie.id.ToUpper().IndexOf("FC2") >= 0)
            {
                SemaphoreFC2.Release();
            }
            else
            {
                Semaphore.Release();
            }
        }
Beispiel #16
0
 /// <summary>
 /// 取消下载
 /// </summary>
 public void CancelDownload()
 {
     Cancel = true;
     State  = DownLoadState.Fail;
 }
Beispiel #17
0
 public void ContinueDownload()
 {
     Pause      = false;
     this.State = DownLoadState.DownLoading;
 }