Example #1
0
        public int CreateSongListFromWVR(string url, bool parseAll)
        {
            PermissionContext.VerifyPermission(PermissionToken.EditProfile);

            var parsed = new NNDWVRParser().GetSongs(url, parseAll);

            return(HandleTransaction(session => {
                var user = GetLoggedUser(session);
                var list = new SongList("Weekly Vocaloid ranking #" + parsed.WVRId, user)
                {
                    Description = parsed.Name,
                    FeaturedCategory = SongListFeaturedCategory.VocaloidRanking
                };
                session.Save(list);

                foreach (var entry in parsed.Songs)
                {
                    var song = session.Query <PVForSong>()
                               .Where(p => p.Service == PVService.NicoNicoDouga && p.PVId == entry.NicoId)
                               .First().Song;

                    session.Save(list.AddSong(song));
                }

                AuditLog(string.Format("created {0}", EntryLinkFactory.CreateEntryLink(list)), session, user);
                return list.Id;
            }));
        }
Example #2
0
        public WVRListResult ParseWVRList(string url, bool parseAll)
        {
            var parsed = new NNDWVRParser().GetSongs(url, parseAll);

            return(HandleQuery(session => {
                var songs = new List <WVRListEntryResult>();

                foreach (var entry in parsed.Songs)
                {
                    var pv = session.Query <PVForSong>()
                             .FirstOrDefault(p => p.Service == PVService.NicoNicoDouga && p.PVId == entry.NicoId && !p.Song.Deleted);

                    var song = pv != null ? new SongContract(pv.Song, LanguagePreference) : null;

                    songs.Add(new WVRListEntryResult(entry.NicoId, entry.SortIndex, entry.Name, entry.Url, song));
                }

                return new WVRListResult(parsed.Name, parsed.WVRId, songs);
            }));
        }