Esempio n. 1
0
        public v_Actress ActressDetails(string actressName)
        {
            v_Actress actress = new v_Actress();
            var       _cache  = _memoryCache.Get <List <v_Actress> >("ActressTempList");
            Dictionary <string, DataValue> dict = this.GetViewCountDict();
            List <v_Movie> movieLists           = new List <v_Movie>();

            if (_cache != null && _cache.Count > 0)
            {
                var detail = _cache.Where(x => x.FullName == actressName).FirstOrDefault();
                int count  = 0;
                var dt     = SQLiteHelper.Query($"SELECT * FROM Dict  WHERE DataKey='{detail.FullName}'");
                if (dt.Tables[0].Rows.Count > 0)
                {
                    var dr = dt.Tables[0].Rows[0];
                    count = int.Parse(dr["DataValue"].ToString());
                    int row = SQLiteHelper.ExecuteNonQuery($"UPDATE Dict SET DataValue = '{ ++count}' WHERE DataKey = '{actressName}'; ");
                }
                else
                {
                    int row = SQLiteHelper.ExecuteNonQuery($"INSERT INTO Dict ( DataKey,DataValue) VALUES ('{actressName}','1');");
                }
                detail.ViewCount = dict.Any(x => x.Key == detail.FullName) ? dict[detail.FullName].count : 0;
                detail.IsLiked   = dict.Any(x => x.Key == detail.FullName) ? dict[detail.FullName].isLiked : 0;
                actress          = detail;
            }
            return(actress);
        }
Esempio n. 2
0
        private List <v_Actress> GetActressesInternal(int?isLiked)
        {
            //播放量字典
            Dictionary <string, DataValue> dict = this.GetViewCountDict();
            string           movieServer        = _configuration.GetValue <string>("movieServer");
            List <v_Actress> lsActress          = new List <v_Actress>();

            var actressDirs = new DirectoryInfo(movieRootPath).GetDirectories();

            foreach (var actressItem in actressDirs) //每女优
            {
                var       fanHaoDirs = actressItem.GetDirectories();
                v_Actress actress    = new v_Actress();
                actress.FullName   = actressItem.Name;
                actress.MovieCount = fanHaoDirs.Count();
                int _totalViewCount = 0;
                foreach (var item in fanHaoDirs)
                {
                    string _fanHao = item.Name.TrimEnd("-C".ToCharArray());
                    _totalViewCount += dict.Any(x => x.Key == _fanHao) ? dict[_fanHao].count : 0;
                }
                actress.TotalViewCount = _totalViewCount;
                var actressFiles = actressItem.GetFiles();// 获取女优图片
                foreach (var photoItem in actressFiles)
                {
                    string picRelativePath = photoItem.FullName.Replace(movieRootPath, "");
                    string path            = movieServer + picRelativePath?.Replace("\\", "/");
                    actress.Portraits.Add(path);
                    if (string.IsNullOrEmpty(actress.Cover) && photoItem.FullName.ToLower().Contains("cover"))
                    {
                        actress.Cover = path;
                    }
                    if (string.IsNullOrEmpty(actress.Background) && photoItem.FullName.ToLower().Contains("background"))
                    {
                        actress.Background = path;
                    }
                }
                if (string.IsNullOrEmpty(actress.Cover) && actress.Portraits.Count > 0)
                {
                    actress.Cover = actress.Portraits.FirstOrDefault();
                }
                lsActress.Add(actress);
            }
            lsActress = lsActress.Where(y => y.IsLiked == isLiked.GetValueOrDefault()).ToList();
            _memoryCache.Set("ActressTempList", lsActress, new MemoryCacheEntryOptions()
                             .SetAbsoluteExpiration(TimeSpan.FromMinutes(30)));
            return(lsActress);
        }
Esempio n. 3
0
        private List <v_Movie> GetListInternal(string actressName, int?isLiked)
        {
            //播放量字典
            Dictionary <string, DataValue> dict = this.GetViewCountDict();
            string movieServer = _configuration.GetValue <string>("movieServer");

            List <v_Movie> LsMovies    = new List <v_Movie>();
            var            dirs        = new DirectoryInfo(movieRootPath).GetDirectories();
            var            actressDirs = string.IsNullOrEmpty(actressName) ? dirs : dirs.Where(y => y.Name.Contains(actressName));

            foreach (var actressItem in actressDirs) //每女优
            {
                v_Actress actress = new v_Actress();
                actress.FullName = actressItem.Name;
                var actressFiles = actressItem.GetFiles();// 获取女优图片
                foreach (var photoItem in actressFiles)
                {
                    string picRelativePath = photoItem.FullName.Replace(movieRootPath, "");
                    string path            = movieServer + picRelativePath?.Replace("\\", "/");
                    actress.Portraits.Add(path);
                    if (string.IsNullOrEmpty(actress.Cover))
                    {
                        actress.Cover = path;
                    }
                }
                var fanHaoDirs = actressItem.GetDirectories(); //所有番号 文件夹
                foreach (var fanHaoItem in fanHaoDirs)
                {
                    TimeSpan _totalTime  = new TimeSpan();
                    var      fanHaoFiles = fanHaoItem.GetFiles();
                    string   FanHaoRaw   = fanHaoItem.Name;
                    string   FanHao      = fanHaoItem.Name.TrimEnd("-C".ToCharArray());
                    v_Movie  movie       = new v_Movie();
                    foreach (var item in fanHaoFiles)
                    {
                        var ext = item.Extension;
                        if (ext == ".mp4" || ext == ".webm") //视频
                        {
                            var Source = movieServer + item.FullName.Replace(movieRootPath, "")?.Replace("\\", "/");
                            movie.Sources.Add(Source);
                            VideoEncoder.VideoFile videoFile = null;
                            if (!dict.Keys.Any(x => x == FanHao))
                            {
                                int row = SQLiteHelper.ExecuteNonQuery($"INSERT INTO Dict ( DataKey,DataValue) VALUES ('{FanHao}','0');");
                                dict.Add(FanHao, new DataValue()
                                {
                                    LastAccessTime = DateTime.Now
                                });
                            }
                            bool isffmpeg = dict[FanHao].TotalTime == "0";
                            if (isffmpeg)
                            {
                                VideoEncoder.Encoder enc = new VideoEncoder.Encoder();
                                //ffmpeg.exe的路径,程序会在执行目录(....FFmpeg测试\bin\Debug)下找此文件,
                                enc.FFmpegPath = "ffmpeg.exe";
                                //视频路径
                                videoFile = new VideoEncoder.VideoFile(item.FullName);
                                enc.GetVideoInfo(videoFile);
                                _totalTime = _totalTime.Add(videoFile.Duration); //总时长
                                int row = SQLiteHelper.ExecuteNonQuery($"UPDATE Dict SET TotalTime='{string.Format("{0:00}:{1:00}:{2:00}", (int)_totalTime.TotalHours, _totalTime.Minutes, _totalTime.Seconds)}' WHERE DataKey = '{FanHao}'; ");
                            }
                            else
                            {
                                if (dict.Any(x => x.Key == FanHao))
                                {
                                    TimeSpan.TryParse(dict[FanHao].TotalTime, out TimeSpan t);
                                    _totalTime = t;
                                }
                                else
                                {
                                    _totalTime = new TimeSpan();
                                }
                            }
                            if (!LsMovies.Contains(movie))
                            {
                                movie.Id             = LsMovies.Count + 1;
                                movie.FanHao         = FanHao;
                                movie.Date           = item.CreationTime.ToString("yyyy-MM-dd HH:mm");
                                movie.CreationTime   = item.CreationTime;
                                movie.PostedDate     = this.FormatPostedDate(item.CreationTime);
                                movie.LastAccessTime = dict.Any(x => x.Key == FanHao) ? dict[FanHao].LastAccessTime :DateTime.Now;
                                movie.LastAccess     = movie.LastAccessTime.ToString("yyyy-MM-dd HH:mm:ss");
                                movie.ViewCount      = dict.Any(x => x.Key == FanHao) ? dict[FanHao].count : 0;
                                movie.IsLiked        = dict.Any(x => x.Key == FanHao) ? dict[FanHao].isLiked : 0;
                                movie.Actress        = actress;
                                if (isffmpeg)
                                {
                                    //mpeg信息
                                    movie.Height            = videoFile.Height;
                                    movie.Width             = videoFile.Width;
                                    movie.DisPlayResolution = videoFile.Width + "x" + videoFile.Height;
                                    int row = SQLiteHelper.ExecuteNonQuery($"UPDATE Dict SET Height='{videoFile.Height}',Width='{videoFile.Width}' WHERE DataKey = '{FanHao}'; ");
                                }
                                else
                                {
                                    movie.Height            = dict[FanHao].Height;
                                    movie.Width             = dict[FanHao].Width;
                                    movie.DisPlayResolution = movie.Width + "x" + movie.Height;
                                }
                                LsMovies.Add(movie);
                            }
                            movie.TotalTime = string.Format("{0:00}:{1:00}:{2:00}", (int)_totalTime.TotalHours, _totalTime.Minutes, _totalTime.Seconds);
                            movie.Duration  = _totalTime;

                            // //FileInfo fi = new FileInfo(item.FullName); //xx/xx/aa.rar
                            // var rnj= fanHaoFiles.Where(x =>Path.GetExtension( x.Name) == ".jpg" && x.Name.Contains(FanHao)).FirstOrDefault();
                            // //fi.MoveTo(Path.GetFileNameWithoutExtension(rnj.FullName) + ".mp4"); //xx/xx/xx.rar
                            // if(rnj != null)
                            // {
                            //     if(item.FullName.EndsWith("-A.mp4") || item.FullName.EndsWith("-B.mp4"))
                            //     {
                            //         Console.WriteLine( "$AB集$  " + item.FullName );
                            //     }
                            //     else
                            //     {
                            //         if(FanHaoRaw.EndsWith("-C"))
                            //         {
                            //             Computer MyComputer = new Computer();
                            //             string newName = FanHaoRaw + Path.GetFileNameWithoutExtension(rnj.FullName).Replace(FanHaoRaw, "").Replace(FanHao, "") + ".mp4";
                            //             MyComputer.FileSystem.RenameFile(item.FullName, newName);
                            //             string newJpgName = newName.Replace(".mp4", "") + ".jpg";
                            //             MyComputer.FileSystem.RenameFile(rnj.FullName, newJpgName);
                            //             Console.WriteLine( "#中文#  " + item.FullName + " => " + newName);
                            //             Console.WriteLine( "#中文图片#  " + rnj.FullName + " => " + newJpgName);
                            //         }
                            //         else
                            //         {
                            //             Computer MyComputer = new Computer();
                            //             string newName = Path.GetFileNameWithoutExtension(rnj.FullName) + ".mp4";
                            //             MyComputer.FileSystem.RenameFile(item.FullName, newName);
                            //             Console.WriteLine( item.FullName + " => " + newName);
                            //         }
                            //     }


                            // }
                            // else
                            // {
                            //     Console.WriteLine("[失败]" + item.FullName);
                            // }
                        }
                        if (ext == ".jpg" || ext == ".png") //图片
                        {
                            string picRelativePath = item.FullName.Replace(movieRootPath, "")?.Replace("\\", "/");

                            if (item.Name.Contains(FanHao))
                            {
                                movie.Title = Path.GetFileNameWithoutExtension(item.Name);
                                movie.Cover = movieServer + picRelativePath;
                            }
                            else
                            {
                                movie.Preview.Add(movieServer + picRelativePath);
                            }
                        }
                    }
                }
            }
            //默认值
            foreach (var item in LsMovies)
            {
                if (item.Cover == null)
                {
                    continue;
                }
                if (!item.Cover.Contains(".jpg")) //视频不包含图片添加默认图片
                {
                    item.Cover = "../images/default.jpg";
                }
            }
            //是否喜欢条件
            LsMovies = isLiked == null ? LsMovies : LsMovies.Where(x => x.IsLiked == isLiked.GetValueOrDefault()).ToList();
            _memoryCache.Set("movieTempList", LsMovies, new MemoryCacheEntryOptions()
                             .SetAbsoluteExpiration(TimeSpan.FromMinutes(30)));
            return(LsMovies);
        }