Esempio n. 1
0
        private void BigImage_Drop(object sender, DragEventArgs e)
        {
            //分为文件夹和文件
            string[] dragdropFiles = (string[])e.Data.GetData(DataFormats.FileDrop);
            string   file          = dragdropFiles[0];

            if (StaticClass.IsFile(file))
            {
                FileInfo fileInfo = new FileInfo(file);
                if (fileInfo.Extension.ToLower() == ".jpg")
                {
                    try
                    {
                        File.Copy(fileInfo.FullName, BasePicPath + $"BigPic\\{vieModel.DetailMovie.id.ToUpper()}.jpg", true);
                        DetailMovie detailMovie = vieModel.DetailMovie;
                        detailMovie.bigimage = null;
                        vieModel.DetailMovie = null;
                        detailMovie.bigimage = StaticClass.BitmapImageFromFile(fileInfo.FullName);
                        vieModel.DetailMovie = detailMovie;

                        RefreshUI("", fileInfo.FullName);
                    }
                    catch (Exception ex)
                    {
                        new Msgbox(this, ex.Message).ShowDialog();
                    }
                }
                else
                {
                    new Msgbox(this, "仅支持 jpg").ShowDialog();
                }
            }
        }
Esempio n. 2
0
        private async void UpdateMain()
        {
            Main main = App.Current.Windows[0] as Main;

            for (int i = 0; i < main.vieModel.CurrentMovieList.Count; i++)
            {
                try
                {
                    if (main.vieModel.CurrentMovieList[i]?.id.ToUpper() == vieModel.id.ToUpper())
                    {
                        DataBase cdb   = new DataBase();
                        Movie    movie = await cdb.SelectMovieByID(vieModel.DetailMovie.id);

                        cdb.CloseDB();
                        if (Properties.Settings.Default.ShowImageMode == "预览图")
                        {
                        }
                        else
                        {
                            movie.smallimage = StaticClass.GetBitmapImage(movie.id, "SmallPic");
                            movie.bigimage   = StaticClass.GetBitmapImage(movie.id, "BigPic");
                        }
                        main.vieModel.CurrentMovieList[i] = null;
                        main.vieModel.CurrentMovieList[i] = movie;
                        break;
                    }
                }
                catch { }
            }
        }
Esempio n. 3
0
        public static string GenerateSign(string query, string appid, string pwd, string salt)
        {
            //http://api.fanyi.baidu.com/doc/21
            //appid+q+salt+密钥
            string r = appid + query + salt + pwd;

            return(StaticClass.CalculateMD5Hash(r));
        }
Esempio n. 4
0
        public static async Task <(bool, string)> DownLoadImage(string Url, ImageType imageType, string ID, string Cookie = "")
        {
            if (Url.IndexOf('/') < 0)
            {
                return(false, "");
            }
            bool result = false; string cookies = Cookie;

            byte[] ImageBytes = null;
            (ImageBytes, cookies) = await Task.Run(() =>
            {
                string Host = "";
                if (Url.IndexOf("pics.dmm") >= 0)
                {
                    Host = "pics.dmm.co.jp";
                }
                else if (Url.IndexOf("pics.javcdn.pw") >= 0)
                {
                    Host = "pics.javcdn.pw";
                }
                else if (Url.IndexOf("images.javcdn.pw") >= 0)
                {
                    Host = "images.javcdn.pw";
                }

                //if (Url.IndexOf("jdbimgs") >= 0) cookies = AllCookies.DB;

                //if (imageType == ImageType.ExtraImage)
                //{
                (ImageBytes, cookies) = DownLoadFile(Url, Host: Host, SetCookie: cookies);
                //}
                //else { (ImageBytes, cookies) = DownLoadFile(Url, Host: Host, SetCookie: Cookie); }
                return(ImageBytes, cookies);
            });


            if (ImageBytes == null)
            {
                result = false;
            }
            else
            {
                result = true;
                StaticClass.SaveImage(ID, ImageBytes, imageType, Url);
            }
            return(result, cookies);
        }
Esempio n. 5
0
        private void SetToBigPic(object sender, RoutedEventArgs e)
        {
            MenuItem m1 = sender as MenuItem;
            MenuItem m2 = m1.Parent as MenuItem;

            ContextMenu contextMenu = m2.Parent as ContextMenu;

            Image      image      = contextMenu.PlacementTarget as Image;
            StackPanel stackPanel = image.Parent as StackPanel;
            TextBlock  textBox    = stackPanel.Children.OfType <TextBlock>().First();
            int        idx        = int.Parse(textBox.Text);

            string path = vieModel.DetailMovie.extraimagePath[idx];

            if (!File.Exists(path))
            {
                return;
            }

            try {
                File.Copy(path, BasePicPath + $"BigPic\\{vieModel.DetailMovie.id.ToUpper()}.jpg", true);
                //更新到 UI

                //BigImage.Source = new BitmapImage(new Uri(path));
                DetailMovie detailMovie = vieModel.DetailMovie;
                detailMovie.bigimage = null;

                vieModel.DetailMovie = null;

                detailMovie.bigimage = StaticClass.BitmapImageFromFile(path);
                vieModel.DetailMovie = detailMovie;

                RefreshUI("", path);
            }
            catch (Exception ex)
            {
                new Msgbox(this, ex.Message).ShowDialog();
            }
        }
Esempio n. 6
0
 private void RefreshUI(string smallPicPath, string BigPicPath = "")
 {
     windowMain = App.Current.Windows[0] as Main;
     for (int i = 0; i < windowMain.vieModel.CurrentMovieList.Count; i++)
     {
         try
         {
             if (windowMain.vieModel.CurrentMovieList[i]?.id.ToUpper() == vieModel.DetailMovie.id.ToUpper())
             {
                 Movie movie = windowMain.vieModel.CurrentMovieList[i];
                 if (smallPicPath != "")
                 {
                     movie.bigimage = null;
                 }
                 if (BigPicPath != "")
                 {
                     movie.smallimage = null;
                 }
                 windowMain.vieModel.CurrentMovieList[i] = null;
                 if (smallPicPath != "")
                 {
                     movie.smallimage = StaticClass.BitmapImageFromFile(smallPicPath);
                 }
                 if (BigPicPath != "")
                 {
                     movie.bigimage = StaticClass.BitmapImageFromFile(BigPicPath);
                 }
                 windowMain.vieModel.CurrentMovieList[i] = movie;
             }
         }
         catch (Exception ex1)
         {
             Console.WriteLine(ex1.StackTrace);
             Console.WriteLine(ex1.Message);
         }
     }
 }
Esempio n. 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();
                }
            }
        }
Esempio n. 8
0
        private void Border_Drop(object sender, DragEventArgs e)
        {
            //分为文件夹和文件
            string[]         dragdropFiles    = (string[])e.Data.GetData(DataFormats.FileDrop);
            List <string>    files            = new List <string>();
            StringCollection stringCollection = new StringCollection();

            foreach (var item in dragdropFiles)
            {
                if (IsFile(item))
                {
                    files.Add(item);
                }
                else
                {
                    stringCollection.Add(item);
                }
            }
            List <string> filepaths = new List <string>();

            //扫描导入
            foreach (var item in stringCollection)
            {
                try { filepaths.AddRange(Directory.GetFiles(item, "*.jpg").ToList <string>()); }
                catch (Exception ex) { Console.WriteLine(ex.Message); continue; }
            }
            if (files.Count > 0)
            {
                filepaths.AddRange(files);
            }

            //复制文件
            string path = BasePicPath + $"ExtraPic\\{vieModel.DetailMovie.id.ToUpper()}\\";

            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);
            }
            bool success = false;

            foreach (var item in filepaths)
            {
                try
                {
                    File.Copy(item, path + item.Split('\\').Last());
                    success = true;
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    continue;
                }
            }
            if (success)
            {
                //更新UI
                DetailMovie         detailMovie  = vieModel.DetailMovie;
                List <BitmapSource> oldImageList = detailMovie.extraimagelist;
                List <string>       oldImagePath = detailMovie.extraimagePath;

                detailMovie.extraimagelist = new List <BitmapSource>();
                detailMovie.extraimagePath = new List <string>();
                vieModel.DetailMovie       = null;

                //载入默认的和新的
                detailMovie.extraimagelist.AddRange(oldImageList);
                detailMovie.extraimagePath.AddRange(oldImagePath);


                foreach (var item in filepaths)
                {
                    detailMovie.extraimagelist.Add(StaticClass.GetExtraImage(item));
                    detailMovie.extraimagePath.Add(path + item.Split('\\').Last());
                }
                vieModel.DetailMovie = detailMovie;
            }
        }
Esempio n. 9
0
        public static async Task <bool> ParseSpecifiedInfo(WebSite webSite, string id, string url)
        {
            string content    = "";
            int    StatusCode = 404;

            if (webSite == WebSite.DB)
            {
                (content, StatusCode) = await Net.Http(url, Cookie : Properties.Settings.Default.DBCookie);
            }
            else
            {
                (content, StatusCode) = await Net.Http(url);
            }

            if (StatusCode != 200 || content == "")
            {
                return(false);
            }
            else
            {
                Dictionary <string, string> Info = new Dictionary <string, string>();
                Info.Add("sourceurl", url);
                if (webSite == WebSite.Bus)
                {
                    Info = new BusParse(id, content, Identify.GetVedioType(id)).Parse();
                    Info.Add("source", "javbus");
                }
                else if (webSite == WebSite.BusEu)
                {
                    Info = new BusParse(id, content, VedioType.欧美).Parse();
                    Info.Add("source", "javbus");
                }
                else if (webSite == WebSite.DB)
                {
                    Info = new JavDBParse(id, content, url.Split('/').Last()).Parse();
                    Info.Add("source", "javdb");
                }
                else if (webSite == WebSite.Library)
                {
                    Info = new LibraryParse(id, content).Parse();
                    Info.Add("source", "javlibrary");
                }
                if (Info.Count > 2)
                {
                    //保存信息
                    Info["id"] = id;
                    DataBase.UpdateInfoFromNet(Info, webSite);
                    DetailMovie detailMovie = DataBase.SelectDetailMovieById(id);


                    //nfo 信息保存到视频同目录
                    if (Properties.Settings.Default.SaveInfoToNFO)
                    {
                        if (Directory.Exists(Properties.Settings.Default.NFOSavePath))
                        {
                            //固定位置
                            StaticClass.SaveToNFO(detailMovie, Path.Combine(Properties.Settings.Default.NFOSavePath, $"{id}.nfo"));
                        }
                        else
                        {
                            //与视频同路径
                            string path = detailMovie.filepath;
                            if (System.IO.File.Exists(path))
                            {
                                StaticClass.SaveToNFO(detailMovie, Path.Combine(new FileInfo(path).DirectoryName, $"{id}.nfo"));
                            }
                        }
                    }
                    return(true);
                }
            }

            return(false);
        }