Exemple #1
0
        public void ParseTitle_WhiteSpace()
        {
            var result = NicoHelper.ParseTitle("【 鏡音リン 】 sister's noise (FULL) 【とある科学の超電磁砲S】", ArtistFunc);

            Assert.AreEqual(1, result.Artists.Count, "1 artist");
            Assert.AreEqual("鏡音リン", result.Artists.First().DefaultName, "artist");
            Assert.AreEqual("sister's noise (FULL)", result.Title, "title");
        }
Exemple #2
0
        public void ParseTitle_WhiteSpace()
        {
            var result = NicoHelper.ParseTitle("【 鏡音リン 】 sister's noise (FULL) 【とある科学の超電磁砲S】", ArtistFunc);

            result.Artists.Count.Should().Be(1, "1 artist");
            result.Artists.First().DefaultName.Should().Be("鏡音リン", "artist");
            result.Title.Should().Be("sister's noise (FULL)", "title");
        }
Exemple #3
0
        public void ParseTitle_ArtistOriginal()
        {
            var result = NicoHelper.ParseTitle("libido / L.A.M.B 【MEIKOオリジナル】", ArtistFunc);

            Assert.AreEqual(1, result.Artists.Count, "1 artist");
            Assert.AreEqual("MEIKO", result.Artists.First().DefaultName, "artist");
            Assert.AreEqual("libido / L.A.M.B", result.Title, "title");
            Assert.AreEqual(SongType.Original, result.SongType, "song type");
        }
Exemple #4
0
        public void ParseTitle_MultipleArtistFields()
        {
            var result = NicoHelper.ParseTitle("【初音ミク】恋風~liebe wind~【鏡音リン】", ArtistFunc);

            Assert.AreEqual(2, result.Artists.Count, "2 artists");
            Assert.AreEqual("初音ミク", result.Artists.First().DefaultName, "artist");
            Assert.AreEqual("鏡音リン", result.Artists[1].DefaultName, "artist");
            Assert.AreEqual("恋風~liebe wind~", result.Title, "title");
        }
Exemple #5
0
        public void ParseTitle_Valid()
        {
            var result = NicoHelper.ParseTitle("【重音テト】 ハイゲインワンダーランド 【オリジナル】", ArtistFunc);

            Assert.AreEqual(1, result.ArtistNames.Length, "1 artist");
            Assert.AreEqual("重音テト", result.ArtistNames.First().DefaultName, "artist");
            Assert.AreEqual("ハイゲインワンダーランド", result.Title, "title");
            Assert.AreEqual(SongType.Original, result.SongType, "song type");
        }
Exemple #6
0
        public void ParseTitle_ArtistOriginal()
        {
            var result = NicoHelper.ParseTitle("libido / L.A.M.B 【MEIKOオリジナル】", ArtistFunc);

            result.Artists.Count.Should().Be(1, "1 artist");
            result.Artists.First().DefaultName.Should().Be("MEIKO", "artist");
            result.Title.Should().Be("libido / L.A.M.B", "title");
            result.SongType.Should().Be(SongType.Original, "song type");
        }
Exemple #7
0
        public void ParseTitle_MultipleArtistFields()
        {
            var result = NicoHelper.ParseTitle("【初音ミク】恋風~liebe wind~【鏡音リン】", ArtistFunc);

            result.Artists.Count.Should().Be(2, "2 artists");
            result.Artists.First().DefaultName.Should().Be("初音ミク", "artist");
            result.Artists[1].DefaultName.Should().Be("鏡音リン", "artist");
            result.Title.Should().Be("恋風~liebe wind~", "title");
        }
Exemple #8
0
        public void ParseTitle_EmptyParts()
        {
            // "オリジナル・PV" lead to an empty artist name being searched.
            // The database collation matches this with an invalid artist, so empty artist searches are ignored.
            var result = NicoHelper.ParseTitle("【初音ミク】心闇【オリジナル・PV】", val => {
                if (string.IsNullOrEmpty(val))
                {
                    Assert.Fail("Empty name not allowed");
                }
                return(CreateEntry.Artist(ArtistType.Producer, name: val));
            });

            Assert.AreEqual(2, result.Artists.Count, "Number of parsed artists");
        }
Exemple #9
0
        public void ParseTitle_EmptyParts()
        {
            // "オリジナル・PV" lead to an empty artist name being searched.
            // The database collation matches this with an invalid artist, so empty artist searches are ignored.
            var result = NicoHelper.ParseTitle("【初音ミク】心闇【オリジナル・PV】", val =>
            {
                Action action = () =>
                {
                    if (string.IsNullOrEmpty(val))
                    {
                        throw new InvalidOperationException("Empty name not allowed");
                    }
                };
                action.Should().NotThrow <InvalidOperationException>();
                return(CreateEntry.Artist(ArtistType.Producer, name: val));
            });

            result.Artists.Count.Should().Be(2, "Number of parsed artists");
        }
Exemple #10
0
        private NicoTitleParseResult ParseNicoPV(IDatabaseContext <PVForSong> ctx, VideoUrlParseResult res)
        {
            if (res == null || !res.IsOk)
            {
                return(null);
            }

            var titleParseResult = NicoHelper.ParseTitle(res.Title, a => GetArtist(a, ctx, AppConfig.PreferredNicoArtistTypes));

            if (!string.IsNullOrEmpty(titleParseResult.Title))
            {
                titleParseResult.TitleLanguage = languageDetector.Detect(titleParseResult.Title, ContentLanguageSelection.Unspecified);
            }

            if (titleParseResult.SongType == SongType.Unspecified)
            {
                titleParseResult.SongType = HasCoverTag(ctx, res) ? SongType.Cover : SongType.Original;
            }

            if (!string.IsNullOrEmpty(res.AuthorId))
            {
                var authorPage = NicoHelper.GetUserProfileUrlById(res.AuthorId);

                var author = ctx.OfType <ArtistWebLink>().Query()
                             .Where(w => w.Url == authorPage && !w.Entry.Deleted)
                             .Select(w => w.Entry)
                             .FirstOrDefault();

                if (author != null && !titleParseResult.Artists.Contains(author))
                {
                    titleParseResult.Artists.Add(author);
                }
            }

            return(titleParseResult);
        }
Exemple #11
0
 private NicoTitleParseResult CallParseTitle(string title)
 {
     return(NicoHelper.ParseTitle(title, ArtistFunc));
 }