Beispiel #1
0
        private NicoTitleParseResult ParseNicoPV(IRepositoryContext <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 (!string.IsNullOrEmpty(res.AuthorId))
            {
                var authorPage = string.Format("http://www.nicovideo.jp/user/{0}", res.AuthorId);

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

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

            return(titleParseResult);
        }
Beispiel #2
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");
        }
Beispiel #3
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");
        }
Beispiel #4
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");
        }
Beispiel #5
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");
        }
Beispiel #6
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");
        }
Beispiel #7
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");
        }
Beispiel #8
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");
        }
Beispiel #9
0
        public void GetResponse_Error()
        {
            NicoResponse response;

            using (var stream = ResourceHelper.GetFileStream("NicoResponse_Error.xml")) {
                response = NicoHelper.GetResponse(stream);
            }

            var result = NicoHelper.ParseResponse(response);

            Assert.IsFalse(result.Success, "Success");
            Assert.AreEqual("NicoVideo (error): not found or invalid", result.Error, "Error");
        }
Beispiel #10
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");
        }
Beispiel #11
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");
        }
Beispiel #12
0
        public void GetResponse_Ok()
        {
            NicoResponse response;

            using (var stream = ResourceHelper.GetFileStream("NicoResponse_Ok.xml")) {
                response = NicoHelper.GetResponse(stream);
            }

            var result = NicoHelper.ParseResponse(response);

            Assert.IsTrue(result.Success, "Success");
            Assert.AreEqual("【初音ミク】17:00【オリジナル曲】", result.Title, "Title");
            Assert.AreEqual("http://tn-skr1.smilevideo.jp/smile?i=12464004", result.ThumbUrl, "ThumbUrl");
            Assert.IsNotNull(result.UploadDate, "UploadDate");
            Assert.AreEqual(new DateTime(2010, 10, 17).Date, result.UploadDate.Value.Date, "UploadDate");
            Assert.AreEqual(178, result.LengthSeconds, "LengthSeconds");
            Assert.AreEqual("14270239", result.AuthorId, "AuthorId");
            Assert.AreEqual("ProjectDIVAチャンネル", result.Author, "Author");
            Assert.AreEqual(11, result.Tags.Length, "Tags.Length");
            Assert.IsTrue(result.Tags.Contains("VOCALOID"), "Found tag");
        }
Beispiel #13
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);
        }
Beispiel #14
0
 private NicoTitleParseResult CallParseTitle(string title)
 {
     return(NicoHelper.ParseTitle(title, ArtistFunc));
 }
Beispiel #15
0
        public void ParseLength_MoreThan60Mins()
        {
            var result = NicoHelper.ParseLength("339:39");

            Assert.AreEqual(20379, result, "result");
        }
Beispiel #16
0
        public void ParseLength_LessThan10Mins()
        {
            var result = NicoHelper.ParseLength("3:09");

            Assert.AreEqual(189, result, "result");
        }