public async Task <ActionResult> PVPlayer(int id = InvalidId, bool enableScriptAccess = false, string elementId = null, PVServices?pvServices = null) { if (id == InvalidId) { return(NoId()); } var pv = _queries.PrimaryPVForSong(id, pvServices); if (pv == null) { return(new EmptyResult()); } var embedParams = new PVEmbedParams { PV = pv, EnableScriptAccess = enableScriptAccess, ElementId = elementId }; var view = await RenderPartialViewToStringAsync("PVs/_PVEmbedDynamicCustom", embedParams); return(LowercaseJson(new SongWithPVPlayerAndVoteContract { PlayerHtml = view, PVId = pv.PVId, PVService = pv.Service })); }
public PartialFindResult <SongInListForApiContract> GetSongs(int listId, string query = "", string songTypes = null, PVServices?pvServices = null, [FromQuery(Name = "tagId[]")] int[] tagId = null, [FromQuery(Name = "artistId[]")] int[] artistId = null, bool childVoicebanks = false, [FromQuery(Name = "advancedFilters")] AdvancedSearchFilterParams[] advancedFilters = null, int start = 0, int maxResults = DefaultMax, bool getTotalCount = false, SongSortRule?sort = null, NameMatchMode nameMatchMode = NameMatchMode.Auto, SongOptionalFields fields = SongOptionalFields.None, ContentLanguagePreference lang = ContentLanguagePreference.Default) { maxResults = Math.Min(maxResults, AbsoluteMax); var types = EnumVal <SongType> .ParseMultiple(songTypes); return(_queries.GetSongsInList( new SongInListQueryParams { TextQuery = SearchTextQuery.Create(query, nameMatchMode), ListId = listId, Paging = new PagingProperties(start, maxResults, getTotalCount), PVServices = pvServices, ArtistIds = artistId, ChildVoicebanks = childVoicebanks, TagIds = tagId, SortRule = sort, AdvancedFilters = advancedFilters?.Select(advancedFilter => advancedFilter.ToAdvancedSearchFilter()).ToArray(), SongTypes = types, }, songInList => new SongInListForApiContract(songInList, lang, fields))); }
public PVContract PrimaryPVForSong(int songId, PVServices?pvServices) { return(HandleQuery(ctx => { var pvs = ctx.Load(songId).PVs.Where(pv => pvServices == null || (pvServices.Value & (PVServices)pv.Service) == (PVServices)pv.Service); var primaryPv = VideoServiceHelper.PrimaryPV(pvs, PermissionContext.IsLoggedIn ? (PVService?)PermissionContext.LoggedUser.PreferredVideoService : null); return primaryPv != null ? new PVContract(primaryPv) : null; })); }
public PartialFindResult <SongForApiContract> GetList( string query = "", string songTypes = null, [FromUri] string[] tagName = null, [FromUri] int[] tagId = null, bool childTags = false, [FromUri] int[] artistId = null, ArtistAlbumParticipationStatus artistParticipationStatus = ArtistAlbumParticipationStatus.Everything, bool childVoicebanks = false, bool includeMembers = false, bool onlyWithPvs = false, [FromUri] PVServices?pvServices = null, int?since = null, int?minScore = null, int?userCollectionId = null, int?releaseEventId = null, EntryStatus?status = null, [FromUri] AdvancedSearchFilter[] advancedFilters = null, int start = 0, int maxResults = defaultMax, bool getTotalCount = false, SongSortRule sort = SongSortRule.Name, bool preferAccurateMatches = false, NameMatchMode nameMatchMode = NameMatchMode.Exact, SongOptionalFields fields = SongOptionalFields.None, ContentLanguagePreference lang = ContentLanguagePreference.Default) { var textQuery = SearchTextQuery.Create(query, nameMatchMode); var types = EnumVal <SongType> .ParseMultiple(songTypes); var param = new SongQueryParams(textQuery, types, start, Math.Min(maxResults, absoluteMax), getTotalCount, sort, false, preferAccurateMatches, null) { ArtistParticipation = { ArtistIds = artistId, Participation = artistParticipationStatus, ChildVoicebanks = childVoicebanks, IncludeMembers = includeMembers }, TagIds = tagId, Tags = tagName, ChildTags = childTags, OnlyWithPVs = onlyWithPvs, TimeFilter = since.HasValue ? TimeSpan.FromHours(since.Value) : TimeSpan.Zero, MinScore = minScore ?? 0, PVServices = pvServices, UserCollectionId = userCollectionId ?? 0, ReleaseEventId = releaseEventId ?? 0, AdvancedFilters = advancedFilters, LanguagePreference = lang }; param.Common.EntryStatus = status; var artists = service.Find(s => new SongForApiContract(s, null, lang, fields), param); return(artists); }
public PartialFindResult <SongInListForApiContract> GetSongs(int listId, [FromUri] PVServices?pvServices = null, int start = 0, int maxResults = defaultMax, bool getTotalCount = false, SongOptionalFields fields = SongOptionalFields.None, ContentLanguagePreference lang = ContentLanguagePreference.Default ) { maxResults = Math.Min(maxResults, absoluteMax); return(queries.GetSongsInList( new SongListQueryParams { ListId = listId, Paging = new PagingProperties(start, maxResults, getTotalCount), PVServices = pvServices }, songInList => new SongInListForApiContract(songInList, lang, fields))); }
public PartialFindResult <SongForApiContract> GetList( string query = "", string songTypes = null, string tag = null, int?artistId = null, ArtistAlbumParticipationStatus artistParticipationStatus = ArtistAlbumParticipationStatus.Everything, bool childVoicebanks = false, bool onlyWithPvs = false, [FromUri] PVServices?pvServices = null, int?since = null, int?minScore = null, [FromUri] ContentLanguageSelections?lyrics = null, int?userCollectionId = null, EntryStatus?status = null, int start = 0, int maxResults = defaultMax, bool getTotalCount = false, SongSortRule sort = SongSortRule.Name, bool preferAccurateMatches = false, NameMatchMode nameMatchMode = NameMatchMode.Exact, SongOptionalFields fields = SongOptionalFields.None, ContentLanguagePreference lang = ContentLanguagePreference.Default) { var textQuery = SearchTextQuery.Create(query, nameMatchMode); var types = EnumVal <SongType> .ParseMultiple(songTypes); var param = new SongQueryParams(textQuery, types, start, Math.Min(maxResults, absoluteMax), false, getTotalCount, sort, false, preferAccurateMatches, null) { Tag = tag, OnlyWithPVs = onlyWithPvs, ArtistId = artistId ?? 0, ArtistParticipationStatus = artistParticipationStatus, ChildVoicebanks = childVoicebanks, TimeFilter = since.HasValue ? TimeSpan.FromHours(since.Value) : TimeSpan.Zero, LyricsLanguages = lyrics != null?lyrics.Value.ToIndividualSelections().ToArray() : null, MinScore = minScore ?? 0, PVServices = pvServices, UserCollectionId = userCollectionId ?? 0 }; param.Common.EntryStatus = status; var artists = service.Find(s => new SongForApiContract(s, null, lang, fields), param); return(artists); }
public PartialFindResult <RatedSongForUserForApiContract> GetRatedSongs( int id, string query = "", string tagName = null, [FromUri] int[] tagId = null, [FromUri] int[] artistId = null, bool childVoicebanks = false, LogicalGrouping artistGrouping = LogicalGrouping.And, SongVoteRating?rating = null, int?songListId = null, bool groupByRating = true, [FromUri] PVServices?pvServices = null, [FromUri] AdvancedSearchFilter[] advancedFilters = null, int start = 0, int maxResults = defaultMax, bool getTotalCount = false, RatedSongForUserSortRule?sort = null, NameMatchMode nameMatchMode = NameMatchMode.Auto, SongOptionalFields fields = SongOptionalFields.None, ContentLanguagePreference lang = ContentLanguagePreference.Default) { maxResults = Math.Min(maxResults, absoluteMax); var textQuery = SearchTextQuery.Create(query, nameMatchMode); var queryParams = new RatedSongQueryParams(id, new PagingProperties(start, maxResults, getTotalCount)) { TextQuery = textQuery, SortRule = sort ?? RatedSongForUserSortRule.Name, ArtistIds = artistId, ArtistGrouping = artistGrouping, ChildVoicebanks = childVoicebanks, FilterByRating = rating ?? SongVoteRating.Nothing, GroupByRating = groupByRating, PVServices = pvServices, SonglistId = songListId ?? 0, TagIds = tagId, TagName = tagName, AdvancedFilters = advancedFilters }; var songs = queries.GetRatedSongs(queryParams, ratedSong => new RatedSongForUserForApiContract(ratedSong, lang, fields)); return(songs); }
/// <summary> /// Filter query by PV services bit array. /// Song will pass the filter if ANY of the specified PV services matches. /// </summary> /// <typeparam name="T">Type of song link.</typeparam> /// <param name="query">Query. Cannot be null.</param> /// <param name="pvServices">PV services bit array. Can be null, in which case no filtering will be done.</param> /// <returns>Filtered query.</returns> public static IQueryable <T> WhereSongHasPVService <T>(this IQueryable <T> query, PVServices?pvServices) where T : ISongLink { if (pvServices == null) { return(query); } return(query.Where(s => (s.Song.PVServices & pvServices) != PVServices.Nothing)); }
/// <summary> /// Filter query by PV services bit array. /// Song will pass the filter if ANY of the specified PV services matches. /// </summary> /// <param name="query">Query. Cannot be null.</param> /// <param name="pvServices">PV services bit array. Can be null, in which case no filtering will be done.</param> /// <returns>Filtered query.</returns> public static IQueryable <Song> WhereHasPVService(this IQueryable <Song> query, PVServices?pvServices) { if (pvServices == null || pvServices.Value == PVServices.Nothing) { return(query); } return(query.Where(s => (s.PVServices & pvServices) != PVServices.Nothing)); }