public ParsedSongQuery ParseTextQuery(SearchTextQuery textQuery) { var query = textQuery.OriginalQuery; if (string.IsNullOrWhiteSpace(query)) { return(new ParsedSongQuery()); } var trimmed = query.Trim(); var term = GetTerm(trimmed, "id", "tag", "artist-tag", "artist-type", "publish-date"); return((term?.PropertyName) switch { "tag" => new ParsedSongQuery { TagName = term.Value }, "artist-tag" => new ParsedSongQuery { ArtistTag = term.Value }, "artist-type" => new ParsedSongQuery { ArtistType = EnumVal <ArtistType> .ParseSafe(term.Value, ArtistType.Unknown) }, "id" => new ParsedSongQuery { Id = PrimitiveParseHelper.ParseIntOrDefault(term.Value, 0) }, "publish-date" => ParseDateRange(term.Value), _ => ParseReferenceQuery(trimmed, query) ?? new ParsedSongQuery { Name = textQuery }, });
public static IQueryable <Artist> WhereMatchFilter(this IQueryable <Artist> query, AdvancedSearchFilter filter) { switch (filter.FilterType) { case AdvancedFilterType.HasUserAccount: { return(query.Where(a => a.OwnerUsers.Any())); } case AdvancedFilterType.RootVoicebank: { return(filter.Negate ? query.Where(a => a.BaseVoicebank != null) : query.Where(a => ArtistHelper.VoiceSynthesizerTypes.Contains(a.ArtistType) && a.BaseVoicebank == null)); } case AdvancedFilterType.VoiceProvider: { var param = EnumVal <ArtistType> .ParseSafe(filter.Param, ArtistType.Unknown); return(param == ArtistType.Unknown ? query.Where(a => a.AllMembers.Any(m => m.LinkType == ArtistLinkType.VoiceProvider)) : query.Where(a => a.AllMembers.Any(m => m.LinkType == ArtistLinkType.VoiceProvider && m.Member.ArtistType == param))); } case AdvancedFilterType.WebLink: { return(query.WhereHasLink <Artist, ArtistWebLink>(filter.Param)); } } return(query); }
private ParsedSongQuery ParseTextQuery(string query) { if (string.IsNullOrWhiteSpace(query)) { return(new ParsedSongQuery()); } var term = GetTerm(query.Trim(), "tag", "artist-tag", "artist-type"); if (term == null) { var nicoId = VideoService.NicoNicoDouga.GetIdByUrl(query); if (!string.IsNullOrEmpty(nicoId)) { return new ParsedSongQuery { NicoId = nicoId } } ; } else { switch (term.PropertyName) { case "tag": return(new ParsedSongQuery { TagName = term.Value }); case "artist-tag": return(new ParsedSongQuery { ArtistTag = term.Value }); case "artist-type": return(new ParsedSongQuery { ArtistType = EnumVal <ArtistType> .ParseSafe(term.Value, ArtistType.Unknown) }); } } return(new ParsedSongQuery { Name = query.Trim() }); }
public static string EntryIndex(this UrlHelper urlHelper, EntryTypeAndSubType fullEntryType) { SearchRouteParams searchRouteParams = null; switch (fullEntryType.EntryType) { case EntryType.Artist: searchRouteParams = new SearchRouteParams(EntryType.Artist) { artistType = EnumVal <ArtistType> .ParseSafe(fullEntryType.SubType) }; break; case EntryType.Album: searchRouteParams = new SearchRouteParams(EntryType.Album) { discType = EnumVal <DiscType> .ParseSafe(fullEntryType.SubType) }; break; case EntryType.Song: searchRouteParams = new SearchRouteParams(EntryType.Song) { songType = EnumVal <SongType> .ParseSafe(fullEntryType.SubType) }; break; case EntryType.ReleaseEvent: searchRouteParams = new SearchRouteParams(EntryType.ReleaseEvent); break; case EntryType.Tag: searchRouteParams = new SearchRouteParams(EntryType.Tag); break; } if (searchRouteParams != null) { return(urlHelper.Action("Index", "Search", searchRouteParams)); } return(""); }
private ParsedSongQuery ParseTextQuery(string query) { if (string.IsNullOrWhiteSpace(query)) { return(new ParsedSongQuery()); } var trimmed = query.Trim(); var term = GetTerm(trimmed, "id", "tag", "artist-tag", "artist-type"); if (term == null) { // Optimization: check prefix, in most cases the user won't be searching by URL if (trimmed.StartsWith("/s/", StringComparison.InvariantCultureIgnoreCase) || trimmed.StartsWith("http", StringComparison.InvariantCultureIgnoreCase)) { var nicoId = VideoService.NicoNicoDouga.GetIdByUrl(query); if (!string.IsNullOrEmpty(nicoId)) { return new ParsedSongQuery { NicoId = nicoId } } ; var entryId = entryUrlParser.Parse(trimmed, allowRelative: true); if (entryId.EntryType == EntryType.Song) { return new ParsedSongQuery { Id = entryId.Id } } ; } } else { switch (term.PropertyName) { case "tag": return(new ParsedSongQuery { TagName = term.Value }); case "artist-tag": return(new ParsedSongQuery { ArtistTag = term.Value }); case "artist-type": return(new ParsedSongQuery { ArtistType = EnumVal <ArtistType> .ParseSafe(term.Value, ArtistType.Unknown) }); case "id": return(new ParsedSongQuery { Id = PrimitiveParseHelper.ParseIntOrDefault(term.Value, 0) }); } } return(new ParsedSongQuery { Name = trimmed }); }
public ParsedSongQuery ParseTextQuery(SearchTextQuery textQuery) { var query = textQuery.OriginalQuery; if (string.IsNullOrWhiteSpace(query)) { return(new ParsedSongQuery()); } var trimmed = query.Trim(); var term = GetTerm(trimmed, "id", "tag", "artist-tag", "artist-type", "publish-date"); if (term == null) { // Optimization: check prefix, in most cases the user won't be searching by URL if (trimmed.StartsWith("/s/", StringComparison.InvariantCultureIgnoreCase)) { var entryId = entryUrlParser.Parse(trimmed, allowRelative: true); if (entryId.EntryType == EntryType.Song) { return new ParsedSongQuery { Id = entryId.Id } } ; } else if (trimmed.StartsWith("http", StringComparison.InvariantCultureIgnoreCase)) { // Test PV URL with services that don't require a web call var videoParseResult = VideoServiceHelper.ParseByUrl(query, false, null, VideoService.NicoNicoDouga, VideoService.Youtube, VideoService.Bilibili, VideoService.File, VideoService.LocalFile, VideoService.Vimeo); if (videoParseResult.IsOk) { if (videoParseResult.Service == Domain.PVs.PVService.NicoNicoDouga) { return(new ParsedSongQuery { NicoId = videoParseResult.Id }); } else { return(new ParsedSongQuery { PV = new PVContract { PVId = videoParseResult.Id, Service = videoParseResult.Service } }); } } var entryId = entryUrlParser.Parse(trimmed, allowRelative: false); if (entryId.EntryType == EntryType.Song) { return new ParsedSongQuery { Id = entryId.Id } } ; } } else { switch (term.PropertyName) { case "tag": return(new ParsedSongQuery { TagName = term.Value }); case "artist-tag": return(new ParsedSongQuery { ArtistTag = term.Value }); case "artist-type": return(new ParsedSongQuery { ArtistType = EnumVal <ArtistType> .ParseSafe(term.Value, ArtistType.Unknown) }); case "id": return(new ParsedSongQuery { Id = PrimitiveParseHelper.ParseIntOrDefault(term.Value, 0) }); case "publish-date": return(ParseDateRange(term.Value)); } } return(new ParsedSongQuery { Name = textQuery }); }