Ejemplo n.º 1
0
        public IActionResult Index(int id, double set)
        {
            if (!_context.AnimateList.Any(anime => anime.Id == id))
            {
                return(null);
            }
            var item = _context.SetDetail.FirstOrDefault(anime => anime.Id == id && anime.SetName == set);

            if (item == null)
            {
                return(null);
            }
            item.ClickCount++;
            _context.Entry(item).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            _context.SaveChanges();
            var title = LanguageHelper.GetLanguegeName(Request.Headers["Accept-Language"], _context.AnimateList.FirstOrDefault(amine => amine.Id == id));

            ViewBag.Title    = $"{title} - {set}";
            ViewBag.IsMobile = Request.IsMobileBrowser();
            var model = new SetResult {
                HighQuality = item.HighQuality, LowQuality = item.LowQuality, MediumQuality = item.MediumQuality, OriginalQuality = item.OriginalQuality ?? item.FilePath
            };

            return(View(model));
        }
Ejemplo n.º 2
0
        public SetResult Watch(string language, int id, double set)
        {
            if (!_context.AnimateList.Any(anime => anime.Id == id))
            {
                return(null);
            }
            var item = _context.SetDetail.FirstOrDefault(anime => anime.Id == id && anime.SetName == set);

            if (item == null)
            {
                return(null);
            }
            item.ClickCount++;
            _context.Entry(item).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            _context.SaveChanges();
            return(new SetResult {
                HighQuality = item.HighQuality, LowQuality = item.LowQuality, MediumQuality = item.MediumQuality, OriginalQuality = item.OriginalQuality ?? item.FilePath
            });
        }
Ejemplo n.º 3
0
 private static bool CheckForVideoQuality(string title, string setName, dynamic obj)
 {
     using (var context = new AnimateDatabaseContext())
     {
         var id = context.AnimateList.FirstOrDefault(anime => anime.EnUs == title).Id;
         if (id != -1)
         {
             var set = context.SetDetail.FirstOrDefault(anime => anime.Id == id && anime.SetName == double.Parse(setName));
             if (set != null)
             {
                 if (string.IsNullOrEmpty(set.FileThumb) && !string.IsNullOrEmpty((string)obj.data?.video_cover))
                 {
                     if (EnableAdvLogging)
                     {
                         Logger.Info("add file thumb");
                     }
                     set.FileThumb = obj.data.video_cover;
                 }
                 if (string.IsNullOrEmpty(set.LowQuality) && !string.IsNullOrEmpty((string)obj.data?.video_play_url?.f10))
                 {
                     if (EnableAdvLogging)
                     {
                         Logger.Info("add LowQuality");
                     }
                     set.LowQuality = obj.data.video_play_url.f10;
                 }
                 if (string.IsNullOrEmpty(set.MediumQuality) && !string.IsNullOrEmpty((string)obj.data?.video_play_url?.f20))
                 {
                     if (EnableAdvLogging)
                     {
                         Logger.Info("add MediumQuality");
                     }
                     set.MediumQuality = obj.data.video_play_url.f20;
                 }
                 if (string.IsNullOrEmpty(set.HighQuality) && !string.IsNullOrEmpty((string)obj.data?.video_play_url?.f30))
                 {
                     if (EnableAdvLogging)
                     {
                         Logger.Info("add HighQuality");
                     }
                     set.HighQuality = obj.data.video_play_url.f30;
                 }
                 if (string.IsNullOrEmpty(set.OriginalQuality) && !string.IsNullOrEmpty((string)obj.data?.video_play_url?.f0))
                 {
                     if (EnableAdvLogging)
                     {
                         Logger.Info("add OriginalQuality");
                     }
                     set.OriginalQuality = obj.data.video_play_url.f0;
                 }
                 context.Entry(set).State = EntityState.Modified;
                 context.SaveChanges();
                 if (!string.IsNullOrEmpty(set.FileThumb) && !string.IsNullOrEmpty(set.LowQuality) && !string.IsNullOrEmpty(set.MediumQuality) && !string.IsNullOrEmpty(set.HighQuality) && !string.IsNullOrEmpty(set.OriginalQuality))
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
Ejemplo n.º 4
0
        private static async Task AddSet(string item, string title, string setName)
        {
            if (EnableAdvLogging)
            {
                Logger.Info($"adding {title} {setName} into database");
            }
            using (var context = new AnimateDatabaseContext())
            {
                if (!context.AnimateList.Any(anime => anime.EnUs == title))
                {
                    if (EnableAdvLogging)
                    {
                        Logger.Info("cannot find id, create new");
                    }
                    context.AnimateList.Add(new AnimateList {
                        EnUs = title, Updated_At = DateTime.Now
                    });
                    context.SaveChanges();
                }
                var id = context.AnimateList.FirstOrDefault(anime => anime.EnUs == title).Id;
                if (id != -1)
                {
                    if (EnableAdvLogging)
                    {
                        Logger.Info($"checking for file data...");
                    }
                    dynamic obj = await AutoRetry(Cloud.GetFileStat(BucketName, $"/{title}/{setName}.mp4"));

                    if (obj != null && obj.code == 0)
                    {
                        if (obj.data.access_url != null)
                        {
                            if (context.SetDetail.Any(anime => anime.Id == id && anime.SetName == double.Parse(setName)))
                            {
                                if (EnableAdvLogging)
                                {
                                    Logger.Info("existed,add check");
                                }
                                var animeItem = context.AnimateList.FirstOrDefault(anime => anime.Id == id);
                                using (var ctx = new CheckContext())
                                {
                                    if (!ctx.CheckList.Any(check => check.ID == id && check.SetName == setName))
                                    {
                                        ctx.CheckList.Add(new CheckModel {
                                            ItemID = id, Name = title, SetName = setName
                                        });
                                    }
                                    if (ShareToWeibo && !ctx.WeiboList.Any(check => check.ID == id && check.SetName == setName))
                                    {
                                        ctx.WeiboList.Add(new WeiboModel {
                                            ItemID = id, Name = title, SetName = setName, ZhTW = animeItem.ZhTw
                                        });
                                    }
                                    ctx.SaveChanges();
                                }
                            }
                            else
                            {
                                if (EnableAdvLogging)
                                {
                                    Logger.Info("adding set...");
                                }
                                context.SetDetail.Add(new SetDetail {
                                    Id = id, SetName = double.Parse(setName), FilePath = obj.data.access_url, ClickCount = 0, Created_At = DateTime.Now
                                });
                                var animeItem = context.AnimateList.FirstOrDefault(anime => anime.Id == id);
                                animeItem.Updated_At = DateTime.Now;
                                animeItem            = await GetAnimeTitle(title, animeItem);

                                context.Entry(animeItem).State = EntityState.Modified;
                                context.SaveChanges();
                                using (var ctx = new CheckContext())
                                {
                                    if (ctx.CheckList.Count(check => check.ID == id && check.SetName == setName) == 0)
                                    {
                                        ctx.CheckList.Add(new CheckModel {
                                            ItemID = id, Name = title, SetName = setName
                                        });
                                    }
                                    if (ShareToWeibo && ctx.WeiboList.Count(check => check.ID == id && check.SetName == setName) == 0)
                                    {
                                        ctx.WeiboList.Add(new WeiboModel {
                                            ItemID = id, Name = title, SetName = setName, ZhTW = animeItem.ZhTw
                                        });
                                    }
                                    ctx.SaveChanges();
                                }
                                if (EnableAdvLogging)
                                {
                                    Logger.Info("add set complete");
                                }
                            }
                        }
                    }
                }
            }
        }