public void SetUp() { producer = CreateEntry.Producer(id: 1, name: "Tripshots"); vocalist = CreateEntry.Vocalist(id: 39, name: "Hatsune Miku"); vocalist2 = CreateEntry.Vocalist(id: 40, name: "Kagamine Rin"); song = CreateEntry.Song(id: 1, name: "Nebula"); song.LengthSeconds = 39; repository = new FakeSongRepository(song); Save(song.AddArtist(producer)); Save(song.AddArtist(vocalist)); Save(song.CreatePV(new PVContract { Id = 1, Service = PVService.Youtube, PVId = "hoLu7c2XZYU", Name = "Nebula", PVType = PVType.Original })); repository.SaveNames(song); user = CreateEntry.User(id: 1, name: "Miku"); user.GroupId = UserGroupId.Trusted; user2 = CreateEntry.User(id: 2, name: "Rin", email: "*****@*****.**"); user3 = CreateEntry.User(id: 3, name: "Luka", email: "*****@*****.**"); repository.Add(user, user2); repository.Add(producer, vocalist); tag = new Tag("vocarock"); repository.Add(tag, new Tag("vocaloud")); releaseEvent = repository.Save(new ReleaseEvent { Name = "Comiket 39" }); permissionContext = new FakePermissionContext(user); entryLinkFactory = new EntryAnchorFactory("http://test.vocadb.net"); newSongContract = new CreateSongContract { SongType = SongType.Original, Names = new[] { new LocalizedStringContract("Resistance", ContentLanguageSelection.English) }, Artists = new[] { new ArtistForSongContract { Artist = new ArtistContract(producer, ContentLanguagePreference.Default) }, new ArtistForSongContract { Artist = new ArtistContract(vocalist, ContentLanguagePreference.Default) }, }, PVUrl = "http://test.vocadb.net/" }; pvParser = new FakePVParser(); pvParser.ResultFunc = (url, getMeta) => VideoUrlParseResult.CreateOk(url, PVService.NicoNicoDouga, "sm393939", getMeta ? VideoTitleParseResult.CreateSuccess("Resistance", "Tripshots", "testimg.jpg", 39) : VideoTitleParseResult.Empty); mailer = new FakeUserMessageMailer(); queries = new SongQueries(repository, permissionContext, entryLinkFactory, pvParser, mailer, new FakeLanguageDetector(), new FakeUserIconFactory(), new EnumTranslations(), new InMemoryImagePersister(), new FakeObjectCache(), new Model.Utils.Config.VdbConfigManager()); }
private VideoUrlParseResult ParseByUrl(string url, bool getTitle, IUserPermissionContext permissionContext) { if (!MatchedPVs.ContainsKey(url)) { return(ResultFunc != null?ResultFunc(url, getTitle) : VideoUrlParseResult.CreateOk(url, PVService.NicoNicoDouga, "sm393939", VideoTitleParseResult.Empty)); } return(MatchedPVs[url]); }
public async Task FindDuplicates_CoverInSongTitle_CoverType() { pvParser.MatchedPVs.Add("http://www.nicovideo.jp/watch/sm27114783", VideoUrlParseResult.CreateOk("http://www.nicovideo.jp/watch/sm27114783", PVService.NicoNicoDouga, "123456567", VideoTitleParseResult.CreateSuccess("【GUMI】 光(宇多田ヒカル) 【アレンジカバー】", string.Empty, null, "testimg2.jpg", 33))); var result = await CallFindDuplicates(anyPv : new[] { "http://www.nicovideo.jp/watch/sm27114783" }); Assert.AreEqual(SongType.Cover, result.SongType, "SongType is cover because of the 'cover' in title"); }
public static VideoUrlParseResult VideoUrlParseResultWithTitle( string url = "http://nicovideo.jp/watch/sm1234567", PVService service = PVService.NicoNicoDouga, string id = "sm1234567", string title = "Resistance", string author = "tripshots", string thumbUrl = "", int?length = null, string[] tags = null) { return(VideoUrlParseResult.CreateOk(url, service, id, VideoTitleParseResult.CreateSuccess(title, author, thumbUrl, length, tags))); }
public void SetUp() { producer = CreateEntry.Producer(id: 1, name: "Tripshots"); vocalist = CreateEntry.Vocalist(id: 39, name: "Hatsune Miku"); vocalist2 = CreateEntry.Vocalist(id: 40, name: "Kagamine Rin"); song = CreateEntry.Song(id: 1, name: "Nebula"); song.LengthSeconds = 39; repository = new FakeSongRepository(song); Save(song.AddArtist(producer)); Save(song.AddArtist(vocalist)); Save(song.CreatePV(new PVContract { Service = PVService.Youtube, PVId = "hoLu7c2XZYU", Name = "Nebula", PVType = PVType.Original })); foreach (var name in song.Names) { repository.Save(name); } user = CreateEntry.User(id: 1, name: "Miku"); user.GroupId = UserGroupId.Trusted; user2 = CreateEntry.User(id: 2, name: "Rin", email: "*****@*****.**"); repository.Add(user, user2); repository.Add(producer, vocalist); repository.Add(new Tag("vocarock"), new Tag("vocaloud")); permissionContext = new FakePermissionContext(user); var entryLinkFactory = new EntryAnchorFactory("http://test.vocadb.net"); newSongContract = new CreateSongContract { SongType = SongType.Original, Names = new[] { new LocalizedStringContract("Resistance", ContentLanguageSelection.English) }, Artists = new[] { new ArtistContract(producer, ContentLanguagePreference.Default), new ArtistContract(vocalist, ContentLanguagePreference.Default), }, PVUrl = "http://test.vocadb.net/" }; pvParser = new FakePVParser(); pvParser.ResultFunc = (url, getMeta) => VideoUrlParseResult.CreateOk(url, PVService.NicoNicoDouga, "sm393939", getMeta ? VideoTitleParseResult.CreateSuccess("Resistance", "Tripshots", "testimg.jpg", 39) : VideoTitleParseResult.Empty); mailer = new FakeUserMessageMailer(); queries = new SongQueries(repository, permissionContext, entryLinkFactory, pvParser, mailer, new FakeLanguageDetector()); }
public async Task FindDuplicates_MatchPV() { pvParser.MatchedPVs.Add("http://youtu.be/hoLu7c2XZYU", VideoUrlParseResult.CreateOk("http://youtu.be/hoLu7c2XZYU", PVService.Youtube, "hoLu7c2XZYU", VideoTitleParseResult.Empty)); var result = await CallFindDuplicates(anyPv : new [] { "http://youtu.be/hoLu7c2XZYU" }); Assert.AreEqual(1, result.Matches.Length, "Matches"); var match = result.Matches.First(); Assert.AreEqual(song.Id, match.Entry.Id, "Matched song"); Assert.AreEqual(SongMatchProperty.PV, match.MatchProperty, "Matched property"); }
public async Task FindDuplicates_NoMatches_ParsePVInfo() { // Note: Nico will be preferred, if available pvParser.MatchedPVs.Add("http://youtu.be/123456567", VideoUrlParseResult.CreateOk("http://youtu.be/123456567", PVService.Youtube, "123456567", VideoTitleParseResult.CreateSuccess("anger PV", "Tripshots", null, "testimg2.jpg", 33))); pvParser.MatchedPVs.Add("http://www.nicovideo.jp/watch/sm3183550", VideoUrlParseResult.CreateOk("http://www.nicovideo.jp/watch/sm3183550", PVService.NicoNicoDouga, "sm3183550", VideoTitleParseResult.CreateSuccess("【初音ミク】anger【VOCALOID3DPV】", "Tripshots", null, "testimg.jpg", 39))); var result = await CallFindDuplicates(new [] { "【初音ミク】anger【VOCALOID3DPV】" }, new [] { "http://youtu.be/123456567", "http://www.nicovideo.jp/watch/sm3183550" }); Assert.AreEqual("anger", result.Title, "Title"); // Title from PV Assert.AreEqual(0, result.Matches.Length, "No matches"); }
public void FindDuplicates_NoMatches_ParsePVInfo() { // Note: for now only NNDPV will be used for song metadata parsing. pvParser.MatchedPVs.Add("http://youtu.be/123456567", VideoUrlParseResult.CreateOk("http://youtu.be/123456567", PVService.Youtube, "123456567", VideoTitleParseResult.CreateSuccess("Resistance", "Tripshots", "testimg2.jpg", 33))); pvParser.MatchedPVs.Add("http://www.nicovideo.jp/watch/sm3183550", VideoUrlParseResult.CreateOk("http://www.nicovideo.jp/watch/sm3183550", PVService.NicoNicoDouga, "sm3183550", VideoTitleParseResult.CreateSuccess("anger", "Tripshots", "testimg.jpg", 39))); var result = CallFindDuplicates(new [] { "【初音ミク】anger PV EDIT【VOCALOID3DPV】" }, new [] { "http://youtu.be/123456567", "http://www.nicovideo.jp/watch/sm3183550" }); Assert.AreEqual("anger", result.Title, "Title"); // Title from PV Assert.AreEqual(0, result.Matches.Length, "No matches"); }
public async Task FindDuplicates_ParsePVInfo_YouTube() { var artist = repository.Save(CreateEntry.Artist(ArtistType.Producer, name: "Clean Tears")); repository.Save(artist.CreateWebLink("YouTube", "https://www.youtube.com/channel/UCnHGCQ0pwnRFF5Oe2YTeOcA", WebLinkCategory.Official)); var titleParseResult = VideoTitleParseResult.CreateSuccess("Clean Tears - Ruby", "Clean Tears", null, "http://tn.smilevideo.jp/smile?i=32347786", 39); titleParseResult.Author = "Clean Tears"; titleParseResult.AuthorId = "UCnHGCQ0pwnRFF5Oe2YTeOcA"; pvParser.MatchedPVs.Add("https://youtu.be/aJKY_EeAeYc", VideoUrlParseResult.CreateOk("https://youtu.be/aJKY_EeAeYc", PVService.Youtube, "aJKY_EeAeYc", titleParseResult)); var result = await CallFindDuplicates(new string[0], new[] { "https://youtu.be/aJKY_EeAeYc" }); Assert.AreEqual("Clean Tears - Ruby", result.Title, "Title"); // Title from PV Assert.AreEqual(1, result.Artists.Length, "Number of matched artists"); Assert.AreEqual(artist.Id, result.Artists[0].Id, "Matched artist"); }
public async Task GetTagSuggestions() { var tag2 = repository.Save(CreateEntry.Tag("metalcore")); repository.Save(new TagMapping(tag, "vocarock")); repository.Save(new TagMapping(tag2, "vocacore")); pvParser.ResultFunc = (url, getMeta) => VideoUrlParseResult.CreateOk(url, PVService.NicoNicoDouga, "sm393939", getMeta ? VideoTitleParseResult.CreateSuccess("Resistance", "Tripshots", null, "testimg.jpg", tags: new [] { "vocarock", "vocacore" }) : VideoTitleParseResult.Empty); song.AddTag(tag); song.PVs.Add(new PVForSong(song, new PVContract { Service = PVService.NicoNicoDouga, PVType = PVType.Original, PVId = "sm393939" })); var result = await queries.GetTagSuggestionsAsync(song.Id); Assert.AreEqual(1, result.Count, "One suggestion"); Assert.AreEqual("metalcore", result[0].Tag.Name, "Tag name"); }