예제 #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);
        }
예제 #2
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);
        }
 public LanguageDetectorResult Detect(ISourceRepo sourceRepo)
 {
     return(_detector.Detect(sourceRepo));
 }
예제 #4
0
 public LanguageDetectorResult Detect(RepositoryContext context)
 {
     return(_detector?.Detect(context));
 }
예제 #5
0
 public LanguageDetectorResult Detect(BuildScriptGeneratorContext context)
 {
     return(_detector?.Detect(context));
 }