public async Task <IActionResult> Edit(int id, [Bind("AnimeInfoId,StudioName,Status,AgeRating,Type,Description,Source,Season")] AnimeInfo animeInfo)
        {
            if (id != animeInfo.AnimeInfoId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(animeInfo);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AnimeInfoExists(animeInfo.AnimeInfoId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(animeInfo));
        }
Пример #2
0
        private void ReadAnime(IEnumerable <IXLRangeRow> rows)
        {
            string[] genres;

            foreach (var row in rows)
            {
                Anime     anime     = new Anime();
                AnimeInfo animeInfo = new AnimeInfo();

                anime.Poster    = row.Cell(1).Value.ToString();
                anime.AnimeName = row.Cell(2).Value.ToString();
                anime.Rating    = Convert.ToInt32(row.Cell(3).Value);

                animeInfo.StudioName  = row.Cell(4).Value.ToString();
                animeInfo.Status      = row.Cell(5).Value.ToString();
                animeInfo.AgeRating   = row.Cell(6).Value.ToString();
                animeInfo.Type        = row.Cell(7).Value.ToString();
                animeInfo.Description = row.Cell(8).Value.ToString();
                animeInfo.Source      = row.Cell(9).Value.ToString();
                animeInfo.Season      = row.Cell(10).Value.ToString();

                genres = row.Cell(11).Value.ToString().Split(',');

                if (_context.Animes.Any(an => an.AnimeName == anime.AnimeName) == false) // if anime is already exists
                {
                    int animeInfoID = AddAnime(anime, animeInfo);
                    DistributeGenres(genres, animeInfoID);
                    _context.SaveChanges();
                }
            }
        }
        public async Task <ActionResult <AnimeInfo> > PostAnimeInfo(AnimeInfo animeInfo)
        {
            _context.AnimeInfoes.Add(animeInfo);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetAnimeInfo", new { id = animeInfo.AnimeInfoId }, animeInfo));
        }
Пример #4
0
        private void DistributeGenres(string[] genres, int animeInfoID)
        {
            Genre     genre;
            AnimeInfo animeInfo = _context.AnimeInfos.Find(animeInfoID);

            foreach (string genreName in genres)
            {
                AnimeGenre animeGenre = new AnimeGenre {
                    AnimeInfo = animeInfo, AnimeInfoId = animeInfoID
                };

                if (GenreExists(genreName) == false)
                {
                    genre = new Genre {
                        GenreName = genreName
                    };
                    _context.Genres.Add(genre);
                    _context.SaveChanges();
                }

                else
                {
                    genre = GetGenre(genreName);
                }

                animeGenre.Genre   = genre;
                animeGenre.GenreId = genre.GenreId;

                _context.AnimeGenres.Add(animeGenre);
                _context.SaveChanges();

                genre.AnimeGenres.Add(animeGenre);
                animeInfo.AnimeGenres.Add(animeGenre);
            }
        }
Пример #5
0
        public async Task <IActionResult> PutAnimeInfos(int id, AnimeInfo AnimeInfos)
        {
            if (id != AnimeInfos.id)
            {
                return(BadRequest());
            }

            _context.Entry(AnimeInfos).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AnimeInfosExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Пример #6
0
        private void InitTabs()
        {
            if (ObjectListView.IsVistaOrLater)
            {
                this.Font = new Font("Segoe UI", 8);                    // Microsoft YaHei
            }
            this.tabPageAnime.Tag = this.tabAnimes;

            // temp
            this.tabControlMain.Controls.Remove(this.tabPageMusic);

            // Anime, Music, Other Info todo
            AnimeInfo info = new AnimeInfo(this);

            this.tabAnimes.AnimeInfo = info;

            foreach (XatXml xx in TXml.XatLst)
            {
                switch (xx.XatType)
                {
                case TidyType.Anime:
                    this.tabAnimes.InitAnimeInfo(xx);
                    break;

                case TidyType.Music:
                    break;

                case TidyType.Other:
                    break;

                default:
                    break;
                }
            }
        }
Пример #7
0
        public async Task <ActionResult <AnimeInfo> > PostAnimeInfos(AnimeInfo AnimeInfos)
        {
            _context.AnimeInfos.Add(AnimeInfos);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetAnimeInfos", new { id = AnimeInfos.id }, AnimeInfos));
        }
Пример #8
0
        //        /// <summary>
        //        /// 获取字符串的Duration毫秒值.
        //        /// </summary>
        //        private static int GetDurationMsec(string input)
        //        {
        //            //Duration: 00:00:10.32, start: 0.021333, bitrate: 543 kb / s
        //            Regex regex = new Regex("Duration:\\s?(\\d{2}):(\\d{2}):(\\d{2}).(\\d{2})\\s?");
        //            Match m = regex.Match(input);
        //            int duration = 0, H = 0, M = 0, S = 0, dotS = 0;
        //            if (m.Success && m.Groups.Count == 5)
        //            {
        //                int.TryParse(m.Groups[1].Value, out H);
        //                int.TryParse(m.Groups[2].Value, out M);
        //                int.TryParse(m.Groups[3].Value, out S);
        //                int.TryParse(m.Groups[4].Value, out dotS);
        //                duration = (H * 3600 + M * 60 + S) * 1000 + dotS * 10;
        //            }
        //            return duration;
        //        }
        //        public static int GetDuration(String mediaFile)
        //        {
        //            if (!File.Exists(mediaFile))
        //                return 0;

        //            String aArguments = string.Format("-i \"{0}\"", mediaFile);
        //            string strOutput = RunProcess(aArguments);
        //            return GetDurationMsec(strOutput);
        //        }
        //        #region 视频
        /// <summary>
        /// 图片转视频
        /// </summary>
        /// <param name="animeInfo"></param>
        /// <param name="fileText"></param>
        /// <param name="fileOut"></param>
        public static void MakeVideoFromTextFile(AnimeInfo animeInfo, string fileText, double dStepProgressBegin = 0, double dStepProgressTotal = 0)
        {
            //ffmpeg -f concat -safe 0 -i inputp.txt -r 30 -y -vcodec libopenh264 outp.mp4
            string arguments = string.Format(@"-f concat -safe 0 -i ""{0}"" -r {1} -y -vcodec libopenh264 -b:v {2}k ""{3}"""
                                             , fileText, animeInfo.IntFPS, animeInfo.QualityV, animeInfo.FileOut);

            RunProcess(arguments);
        }
        public async Task <IActionResult> Create([Bind("AnimeInfoId,StudioName,Status,AgeRating,Type,Description,Source,Season")] AnimeInfo animeInfo)
        {
            if (ModelState.IsValid)
            {
                _context.Add(animeInfo);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(animeInfo));
        }
Пример #10
0
        public void ShouldMapWhenDateIsNone()
        {
            var animeInfo = new AnimeInfo(
                NonEmptyString.FromString("a"),
                NonEmptyString.FromString("title"),
                NonEmptyString.FromString(null),
                NonEmptyString.FromString("test"),
                new SeasonInformation(Season.Spring, new Year(2015)),
                None,
                false);


            var sut = AnimeInfoMappers.ProjectToStorageModel(animeInfo);

            Assert.Null(sut.Date);
        }
Пример #11
0
        private int AddAnime(Anime anime, AnimeInfo animeInfo)
        {
            int newAnimeInfoID;

            _context.AnimeInfos.Add(animeInfo);
            _context.SaveChanges();
            newAnimeInfoID = animeInfo.AnimeInfoId;

            anime.AnimeInfo   = animeInfo;
            anime.AnimeInfoId = newAnimeInfoID;

            _context.Animes.Add(anime);
            _context.SaveChanges();

            return(newAnimeInfoID);
        }
        internal static AnimeInfoStorage ProjectToStorageModel(AnimeInfo source)
        {
            var year = OptionUtils.UnpackOption <ushort>(source.SeasonInformation.Year.Value, 0);

            return(new AnimeInfoStorage
            {
                RowKey = OptionUtils.UnpackOption(source.Id.Value, string.Empty),
                PartitionKey = IdHelpers.GenerateAnimePartitionKey(source.SeasonInformation.Season, year),
                Season = source.SeasonInformation.Season.Value,
                Year = year,
                Synopsis = OptionUtils.UnpackOption(source.Synopsis.Value, string.Empty),
                FeedTitle = OptionUtils.UnpackOption(source.FeedTitle.Value, string.Empty),
                Date = MapDate(source.Date),
                Title = OptionUtils.UnpackOption(source.Title.Value, string.Empty),
                Completed = source.Completed
            });
        }
Пример #13
0
        public void InitializeAnimations()
        {
            foreach (var targetComponent in Selection.objects.OfType <GameObject>().Select(x => x.GetComponent <ItemComponent>()).Where(x => x != null))
            {
                var targetGameobject = targetComponent.gameObject;
                var animator         = targetGameobject.GetComponent <Animator>();
                var controller       = animator.runtimeAnimatorController;
                var clips            = controller.animationClips;

                if (clips.Length <= 0)
                {
                    targetComponent.isAnime = false;
                    return;
                }

                var anims = new AnimeInfo[clips.Length];
                var index = 0;
                foreach (var clip in clips)
                {
                    var animInfo = new AnimeInfo();

                    // Make name not-developer friendly.
                    var niceName = clip.name;
                    if (niceName.IndexOf("|", StringComparison.Ordinal) > 0)
                    {
                        niceName = niceName.Substring(niceName.IndexOf("|", StringComparison.Ordinal) + 1);
                    }
                    niceName = Regex.Replace(niceName, @"([a-z])([A-Z])", "$1 $2");
                    niceName = Regex.Replace(niceName, @"([_-])", " ");
                    niceName = Regex.Replace(niceName, @"(^| )[a-z]", m => m.ToString().ToUpper());

                    // But put those in developer friendly form.
                    animInfo.name  = niceName;
                    animInfo.state = clip.name;
                    anims[index]   = animInfo;
                    index++;

                    // Debug if you need em'
                    //Debug.Log(niceName);
                }

                targetComponent.animeInfos = anims;

                EditorUtility.SetDirty(targetComponent);
            }
        }
Пример #14
0
        private void tsBtnRefresh_Click(object sender, EventArgs e)
        {
            if (!AnimeInfo.IsStorageReady())
            {
                return;
            }

            long lSize    = 0L;
            long lSelSize = 0L;
            long lSpace   = _ai.Space;
            bool bCheck   = false;

            foreach (Anime a in this.folvAnime.SelectedObjects)
            {
                if (a.Path.Length == 0)
                {
                    continue;
                }

                lSize = Anime.GetSize(a.Path);
                if (a.Size != lSize)
                {
                    bCheck = true;

                    lSpace += lSize - a.Size;
                    a.Size  = lSize;
                    this.folvAnime.RefreshItem(this.folvAnime.ModelToItem(a));
                }
                lSelSize += a.Size;
            }

            if (bCheck)
            {
                _ai.IsSaved = false;
            }

            if (lSpace != _ai.Space)
            {
                _ai.Space = lSpace;

                this.tsslSelSpace.Text = (lSelSize == 0L) ? "Selected Size: -" :
                                         (lSelSize >= 1000000000L) ? String.Format("Selected Size: {0:#,##0.#0} GB", lSelSize / 1073741824D) :
                                         String.Format("Selected Size: {0:#,##0.#0} MB", lSelSize / 1048576D);
                this.tsslSpace.Text = String.Format("Total Size: {0:#,##0.#0} GB", _ai.Space / 1073741824D);
            }
        }
Пример #15
0
        private void title_Click(object sender, EventArgs e)
        {
            var frm = new AnimeInfo(anime_id);

            frm.Location      = this.FindForm().Location;
            frm.StartPosition = FormStartPosition.Manual;
            frm.FormClosing  += delegate { frm.Dispose(); Program.CloseAllButSearch(); };
            frm.KeyDown      += new KeyEventHandler((s, key) =>
            {
                if (key.KeyCode == Keys.X)
                {
                    Console.WriteLine("key pressed");
                    this.FindForm().Show();
                    frm.Close();
                    frm.Dispose();
                }
            });
            frm.Show();
            this.FindForm().Hide();
        }
Пример #16
0
        public void mp4Generated()
        {
            AnimeInfo animeinfo = new AnimeInfo();

            animeinfo.IntFPS       = Request["frame"];
            animeinfo.Keyframe     = Request["keyframe"];
            animeinfo.Channel      = Request.Form.Get("channel");
            animeinfo.Bitrate      = Request.Form.Get("bitrate");
            animeinfo.SamplingRate = Request.Form.Get("SamplingRate");
            string folderName = @"D:\BaiduNetdiskDownload\WebMP4\WebMP4\MP4Generated\BGImg\";
            string savePath   = @"D:\BaiduNetdiskDownload\WebMP4\WebMP4\MP4Generated\Results\";
            string curTime    = DateTime.Now.ToString("hh_mm_ss_ms");

            animeinfo.FileOut = string.Format(@"{0}{1}.mp4", savePath, curTime);
            Size       size       = new Size(1600, 900); //视频宽高
            double     time       = 3;                   //每张图片播放时间
            Mp4Handler mp4handler = new Mp4Handler(folderName, size, time);

            mp4handler.CreateMP4(animeinfo);
        }
Пример #17
0
        public async Task <ActionResult <AnimeInfo> > GetAnimeInfos(string id)
        {
            IJikan jikan = new Jikan();

            AnimeInfo         animeInfo = new AnimeInfo();
            AnimeSearchResult animes    = await jikan.SearchAnime(id);

            if (animes.Results.Count <= 0)
            {
                animeInfo.Title = "nsrf";
            }
            else
            {
                AnimeSearchEntry firstFound = animes.Results.First();
                animeInfo.Title            = firstFound.Title;
                animeInfo.ReleaseDate      = firstFound.StartDate.Value.ToShortDateString();
                animeInfo.NumberOfEpisodes = firstFound.Episodes.GetValueOrDefault();
                animeInfo.Summary          = firstFound.Description;
            }

            return(animeInfo);
        }
Пример #18
0
        public static Classes.AnimeInfo getInformation(int id)
        {
            string      response = Connections.GetResponse(Properties.Settings.Default.InformationApiUrl + id.ToString());
            XmlDocument doc      = new XmlDocument();

            doc.LoadXml(response);

            AnimeInfo info = new AnimeInfo();

            info.Title = doc.SelectSingleNode("/ann/anime[1]/info[@type='Main title']").InnerText;
            info.Start = doc.SelectSingleNode("/ann/anime[1]/info[@type='Vintage'][1]").InnerText;
            info.Web   = doc.SelectSingleNode("/ann/anime[1]/info[@type='Official website'][1]").Attributes["href"].Value;
            XmlNodeList genreList = doc.SelectNodes("/ann/anime[1]/info[@type='Themes'] | /ann/anime[1]/info[@type='Genres']");

            foreach (XmlNode genre in genreList)
            {
                info.Genres.Add(genre.InnerText);
            }
            XmlNodeList episodes = doc.SelectNodes("/ann/anime[1]/episode");

            foreach (XmlNode episode in episodes)
            {
                int number;
                if (int.TryParse(episode.Attributes["num"].Value, out number))
                {
                    string title = episode.FirstChild.InnerText;
                    if (number > 0)
                    {
                        info.OfficialEpisodes.Add(number, title);
                    }
                }
            }
            string screenshotUrl = doc.SelectSingleNode("/ann/anime[1]/info[@type='Picture'][1]").Attributes["src"].Value;

            info.ScreenShot = Properties.Settings.Default.ImagesPath + "\\" + Guid.NewGuid().ToString().Replace("-", "") + ".jpg";
            Connections.downloadFile(screenshotUrl, info.ScreenShot);
            info.Description = doc.SelectSingleNode("/ann/anime[1]/info[@type='Plot Summary']").InnerText;
            return(info);
        }
Пример #19
0
 public void CreateMP4(AnimeInfo animeinfo)
 {
     ProcessFFMPEG.MakeVideoFromTextFile(animeinfo, fileText);
 }
 internal static AnimeInfoStorage ProjectToStorageModelWithEtag(AnimeInfo source) => ProjectToStorageModel(source).AddEtag();
Пример #21
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            // edit 13/1/13 for fun3
            //if (this.tbTitle.Text == "")
            //{
            //    MessageBox.Show("The title is a null value!", "Title error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            //    this.tbTitle.Focus();

            //    return;
            //}

            //Regex rx = new Regex(@"^(?!0000)[0-9]{4}$");

            //if (!rx.IsMatch(this.cboYear.Text))
            //{
            //    MessageBox.Show("The Year is wrong!", "Year error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            //    this.cboYear.ResetText();
            //    this.cboYear.Focus();

            //    return;
            //}

            //if (this.tbStoreIndex.Text != "")
            //{
            //    rx = new Regex(@"^[a-zA-Z]:(\\[^\s\.\\/:\*\?\x22<>\|][^\\/:\*\?\x22<>\|]*[^\s\.\\/:\*\?\x22<>\|])+$");

            //    if (!rx.IsMatch(this.tbStoreIndex.Text))
            //    {
            //        MessageBox.Show("The Path do not match!", "Path error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            //        this.tbStoreIndex.ResetText();
            //        this.tbStoreIndex.Focus();

            //        return;
            //    }

            //    if (Directory.Exists(this.tbStoreIndex.Text))
            //        _anime.Size = AnimeSpace.GetSpace(this.tbStoreIndex.Text);
            //}
            //else _anime.Size = 0L;

            //bool btitle, byear, bstoreindex;

            //btitle = MatchTitle();
            //byear = MatchYear();
            //bstoreindex = MatchStoreIndex();

            //if (!btitle)
            //{
            //	this.tbTitle.Focus();
            //	return;
            //}
            //else if (!byear)
            //{
            //	this.cboYear.Text = String.Empty;
            //	this.cboYear.Focus();
            //	return;
            //}
            //else if (!bstoreindex)
            //{
            //	this.tbStoreIndex.Text = String.Empty;
            //	this.tbStoreIndex.Focus();
            //	return;
            //}
            // edit fin

            if (this.tbStoreIndex.Text.Length == 0)
            {
                _anime.Size = 0L;
            }
            else if (AnimeInfo.IsStorageReady())
            {
                _anime.Size = Anime.GetSize(this.tbStoreIndex.Text);
            }

            _anime.Title  = this.tbTitle.Text;
            _anime.Year   = UInt32.Parse(this.cboYear.Text);
            _anime.Season = (PlaySeason)this.cboSeason.SelectedItem;
            _anime.Path   = this.tbStoreIndex.Text;

            _anime.Format   = (MergeFormat)this.cboFormat.SelectedItem;
            _anime.SubStyle = (SubStyles)this.cboSubStyle.SelectedItem;

            _anime.UpdateTime = DateTime.Now;
            _anime.Kana       = this.tbKana.Text;
            _anime.Episode    = this.tbEpisode.Text;
            _anime.Inc        = this.tbInc.Text;
            _anime.Note       = this.rtbNote.Text.Replace('\n', '\u0002');

            lsize = _anime.Size - lsize;

            this.Close();
        }