public IEnumerable <SongForApiContract> GetDerived(int id, SongOptionalFields fields = SongOptionalFields.None, ContentLanguagePreference lang = ContentLanguagePreference.Default) { var songs = queries.HandleQuery(s => s.Load(id).AlternateVersions.Select(child => new SongForApiContract(child, null, lang, fields)).ToArray()); return(songs); }
public PartialFindResult <RatedSongForUserForApiContract> GetRatedSongs( int userId, string query = "", string tag = null, int?artistId = null, bool childVoicebanks = false, SongVoteRating?rating = null, int?songListId = null, bool groupByRating = true, 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); query = FindHelpers.GetMatchModeAndQueryForSearch(query, ref nameMatchMode); var queryParams = new RatedSongQueryParams(userId, new PagingProperties(start, maxResults, getTotalCount)) { Query = query, NameMatchMode = nameMatchMode, SortRule = sort ?? SongSortRule.Name, ArtistId = artistId ?? 0, ChildVoicebanks = childVoicebanks, FilterByRating = rating ?? SongVoteRating.Nothing, GroupByRating = groupByRating, SonglistId = songListId ?? 0, Tag = tag }; var songs = queries.GetRatedSongs(queryParams, ratedSong => new RatedSongForUserForApiContract(ratedSong, lang, fields)); return(songs); }
public SongInListForApiContract(SongInList songInList, ContentLanguagePreference languagePreference, SongOptionalFields fields) { this.Notes = songInList.Notes; this.Order = songInList.Order; this.Song = new SongForApiContract(songInList.Song, null, languagePreference, fields); }
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 RelatedSongsContract GetRelatedSongs(int songId, SongOptionalFields fields, ContentLanguagePreference?lang = null) { var language = lang ?? permissionContext.LanguagePreference; return(repository.HandleQuery(ctx => { var song = ctx.Load(songId); var songs = new RelatedSongsQuery(ctx).GetRelatedSongs(song); return new RelatedSongsContract { ArtistMatches = songs.ArtistMatches .Select(a => new SongForApiContract(a, null, language, fields)) .OrderBy(a => a.Name) .ToArray(), LikeMatches = songs.LikeMatches .Select(a => new SongForApiContract(a, null, language, fields)) .OrderBy(a => a.Name) .ToArray(), TagMatches = songs.TagMatches .Select(a => new SongForApiContract(a, null, language, fields)) .OrderBy(a => a.Name) .ToArray() }; })); }
public async Task <IEnumerable <SongForApiContract> > GetTopSongs( int?durationHours = null, DateTime?startDate = null, TopSongsDateFilterType?filterBy = null, SongVocalistSelection?vocalist = null, int maxResults = 25, SongOptionalFields fields = SongOptionalFields.None, ContentLanguagePreference languagePreference = ContentLanguagePreference.Default) => await _queries.GetTopRated(durationHours, startDate, filterBy, vocalist, maxResults, fields, languagePreference);
public SongForApiContract[] GetPublishedSongs(int eventId, SongOptionalFields fields = SongOptionalFields.None, ContentLanguagePreference lang = ContentLanguagePreference.Default) { return(repository.HandleQuery(ctx => { var ev = ctx.Load(eventId); return ev.Songs.Select(a => new SongForApiContract(a, lang, fields)).ToArray(); })); }
public AlbumForApiContract( Album album, ContentLanguagePreference languagePreference, IEntryThumbPersister thumbPersister, AlbumOptionalFields fields, SongOptionalFields songFields = SongOptionalFields.None) : this(album, null, languagePreference, thumbPersister, true, fields, songFields) { }
public AlbumForApiContract( Album album, ContentLanguagePreference languagePreference, IAggregatedEntryImageUrlFactory thumbPersister, AlbumOptionalFields fields, SongOptionalFields songFields = SongOptionalFields.None) : this(album, null, languagePreference, thumbPersister, fields, songFields) { }
public SongInAlbumForApiContract[] GetTracks( int id, SongOptionalFields fields = SongOptionalFields.None, ContentLanguagePreference lang = ContentLanguagePreference.Default) { var tracks = service.GetAlbum(id, a => a.Songs.Select(s => new SongInAlbumForApiContract(s, lang, fields)).ToArray()); return(tracks); }
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 AlbumForApiContract GetOne( int id, AlbumOptionalFields fields = AlbumOptionalFields.None, SongOptionalFields songFields = SongOptionalFields.None, ContentLanguagePreference lang = ContentLanguagePreference.Default) { var album = queries.GetAlbumWithMergeRecord(id, (a, m) => new AlbumForApiContract(a, m, lang, thumbPersister, fields, songFields)); return(album); }
public SongForApiContract GetByPV( PVService pvService, string pvId, SongOptionalFields fields = SongOptionalFields.None, ContentLanguagePreference lang = ContentLanguagePreference.Default) { var song = service.GetSongWithPV(s => new SongForApiContract(s, null, lang, fields), pvService, pvId); return(song); }
public AlbumForApiContract GetOne( int id, AlbumOptionalFields fields = AlbumOptionalFields.None, SongOptionalFields songFields = SongOptionalFields.None, ContentLanguagePreference lang = ContentLanguagePreference.Default) { var ssl = WebHelper.IsSSL(Request); var album = service.GetAlbumWithMergeRecord(id, (a, m) => new AlbumForApiContract(a, m, lang, thumbPersister, ssl, fields, songFields)); return(album); }
public SongForApiContract(Song song, SongMergeRecord mergeRecord, ContentLanguagePreference languagePreference, SongOptionalFields fields) { ArtistString = song.ArtistString[languagePreference]; CreateDate = song.CreateDate; DefaultName = song.DefaultName; DefaultNameLanguage = song.Names.SortNames.DefaultLanguage; FavoritedTimes = song.FavoritedTimes; Id = song.Id; LengthSeconds = song.LengthSeconds; Name = song.Names.SortNames[languagePreference]; PVServices = song.PVServices; RatingScore = song.RatingScore; SongType = song.SongType; Status = song.Status; Version = song.Version; if (languagePreference != ContentLanguagePreference.Default || fields.HasFlag(SongOptionalFields.AdditionalNames)) { AdditionalNames = song.Names.GetAdditionalNamesStringForLanguage(languagePreference); } if (languagePreference != ContentLanguagePreference.Default) { LocalizedName = song.Names.SortNames[languagePreference]; } if (fields.HasFlag(SongOptionalFields.Albums)) Albums = song.Albums.Select(a => new AlbumContract(a.Album, languagePreference)).ToArray(); if (fields.HasFlag(SongOptionalFields.Artists)) Artists = song.Artists.Select(a => new ArtistForSongContract(a, languagePreference)).ToArray(); if (fields.HasFlag(SongOptionalFields.Names)) Names = song.Names.Select(n => new LocalizedStringContract(n)).ToArray(); if (fields.HasFlag(SongOptionalFields.PVs)) PVs = song.PVs.Select(p => new PVContract(p)).ToArray(); if (fields.HasFlag(SongOptionalFields.Tags)) Tags = song.Tags.Usages.Select(u => new TagUsageForApiContract(u)).ToArray(); if (fields.HasFlag(SongOptionalFields.ThumbUrl)) ThumbUrl = VideoServiceHelper.GetThumbUrl(song.PVs.PVs); if (fields.HasFlag(SongOptionalFields.WebLinks)) WebLinks = song.WebLinks.Select(w => new WebLinkContract(w)).ToArray(); if (mergeRecord != null) MergedTo = mergeRecord.Target.Id; }
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 <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); }
public PartialFindResult <SongForApiContract> GetList( string query = "", SongType songTypes = SongType.Unspecified, string tag = null, int?artistId = null, ArtistAlbumParticipationStatus artistParticipationStatus = ArtistAlbumParticipationStatus.Everything, bool childVoicebanks = false, bool onlyWithPvs = false, int?since = null, [FromUri] ContentLanguageSelections?lyrics = null, int?userCollectionId = null, EntryStatus?status = null, int start = 0, int maxResults = defaultMax, bool getTotalCount = false, SongSortRule sort = SongSortRule.Name, NameMatchMode nameMatchMode = NameMatchMode.Exact, SongOptionalFields fields = SongOptionalFields.None, ContentLanguagePreference lang = ContentLanguagePreference.Default) { query = FindHelpers.GetMatchModeAndQueryForSearch(query, ref nameMatchMode); var types = songTypes != SongType.Unspecified ? new[] { songTypes } : new SongType[0]; var param = new SongQueryParams(query, types, start, Math.Min(maxResults, absoluteMax), false, getTotalCount, nameMatchMode, sort, false, false, 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, UserCollectionId = userCollectionId ?? 0 }; param.Common.EntryStatus = status; var artists = service.Find(s => new SongForApiContract(s, null, lang, fields), param); return(artists); }
public AlbumForApiContract( Album album, AlbumMergeRecord mergeRecord, ContentLanguagePreference languagePreference, IAggregatedEntryImageUrlFactory thumbPersister, AlbumOptionalFields fields, SongOptionalFields songFields) { ArtistString = album.ArtistString[languagePreference]; CatalogNumber = album.OriginalRelease != null ? album.OriginalRelease.CatNum : null; CreateDate = album.CreateDate; DefaultName = album.DefaultName; DefaultNameLanguage = album.Names.SortNames.DefaultLanguage; DiscType = album.DiscType; Id = album.Id; Name = album.Names.SortNames[languagePreference]; RatingAverage = album.RatingAverage; RatingCount = album.RatingCount; ReleaseDate = new OptionalDateTimeContract(album.OriginalReleaseDate); Status = album.Status; Version = album.Version; if (fields.HasFlag(AlbumOptionalFields.AdditionalNames)) { AdditionalNames = album.Names.GetAdditionalNamesStringForLanguage(languagePreference); } if (fields.HasFlag(AlbumOptionalFields.Artists)) { Artists = album.Artists.Select(a => new ArtistForAlbumForApiContract(a, languagePreference)).ToArray(); } if (fields.HasFlag(AlbumOptionalFields.Description)) { Description = album.Description[languagePreference]; } if (fields.HasFlag(AlbumOptionalFields.Discs)) { Discs = album.Discs.Select(d => new AlbumDiscPropertiesContract(d)).ToArray(); } if (fields.HasFlag(AlbumOptionalFields.Identifiers)) { Identifiers = album.Identifiers.Select(i => new AlbumIdentifierContract(i)).ToArray(); } if (thumbPersister != null && fields.HasFlag(AlbumOptionalFields.MainPicture) && album.Thumb != null) { MainPicture = new EntryThumbForApiContract(album.Thumb, thumbPersister); } if (fields.HasFlag(AlbumOptionalFields.Names)) { Names = album.Names.Select(n => new LocalizedStringContract(n)).ToArray(); } if (fields.HasFlag(AlbumOptionalFields.PVs)) { PVs = album.PVs.Select(p => new PVContract(p)).ToArray(); } if (fields.HasFlag(AlbumOptionalFields.ReleaseEvent)) { ReleaseEvent = album.OriginalReleaseEvent != null ? new ReleaseEventForApiContract(album.OriginalReleaseEvent, languagePreference, ReleaseEventOptionalFields.None, thumbPersister) : null; } if (fields.HasFlag(AlbumOptionalFields.Tags)) { Tags = album.Tags.ActiveUsages.Select(u => new TagUsageForApiContract(u, languagePreference)).ToArray(); } if (fields.HasFlag(AlbumOptionalFields.Tracks)) { Tracks = album.Songs.Select(s => new SongInAlbumForApiContract(s, languagePreference, songFields)).ToArray(); } if (fields.HasFlag(AlbumOptionalFields.WebLinks)) { WebLinks = album.WebLinks.Select(w => new WebLinkForApiContract(w)).ToArray(); } if (mergeRecord != null) { MergedTo = mergeRecord.Target.Id; } }
public PartialFindResult<RatedSongForUserForApiContract> GetRatedSongs( int userId, string query = "", string tag = null, int? artistId = null, bool childVoicebanks = false, SongVoteRating? rating = null, int? songListId = null, bool groupByRating = true, 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); query = FindHelpers.GetMatchModeAndQueryForSearch(query, ref nameMatchMode); var queryParams = new RatedSongQueryParams(userId, new PagingProperties(start, maxResults, getTotalCount)) { Query = query, NameMatchMode = nameMatchMode, SortRule = sort ?? SongSortRule.Name, ArtistId = artistId ?? 0, ChildVoicebanks = childVoicebanks, FilterByRating = rating ?? SongVoteRating.Nothing, GroupByRating = groupByRating, SonglistId = songListId ?? 0, Tag = tag }; var songs = queries.GetRatedSongs(queryParams, ratedSong => new RatedSongForUserForApiContract(ratedSong, lang, fields)); return songs; }
public SongForApiContract GetByPV( PVService pvService, string pvId, SongOptionalFields fields = SongOptionalFields.None, ContentLanguagePreference lang = ContentLanguagePreference.Default) { var song = service.GetSongWithPV(s => new SongForApiContract(s, null, lang, fields), pvService, pvId); return song; }
public SongForApiContract(Song song, ContentLanguagePreference languagePreference, SongOptionalFields fields) : this(song, null, languagePreference, fields) { }
public SongForApiContract[] GetPublishedSongs(int eventId, SongOptionalFields fields = SongOptionalFields.None, ContentLanguagePreference lang = ContentLanguagePreference.Default) => _queries.GetPublishedSongs(eventId, fields, lang);
public async Task <SongForApiContract[]> GetHighlightedSongs(ContentLanguagePreference languagePreference, SongOptionalFields fields) { return(await HandleQueryAsync(async session => { return (await GetHighlightedSongs(session)) .Select(s => new SongForApiContract(s, languagePreference, fields)) .ToArray(); })); }
public SongForApiContract(Song song, SongMergeRecord mergeRecord, ContentLanguagePreference languagePreference, SongOptionalFields fields) { ArtistString = song.ArtistString[languagePreference]; CreateDate = song.CreateDate; DefaultName = song.DefaultName; DefaultNameLanguage = song.Names.SortNames.DefaultLanguage; FavoritedTimes = song.FavoritedTimes; Id = song.Id; LengthSeconds = song.LengthSeconds; Name = song.Names.SortNames[languagePreference]; PublishDate = song.PublishDate; PVServices = song.PVServices; RatingScore = song.RatingScore; SongType = song.SongType; Status = song.Status; Version = song.Version; if (fields.HasFlag(SongOptionalFields.AdditionalNames)) { AdditionalNames = song.Names.GetAdditionalNamesStringForLanguage(languagePreference); } if (fields.HasFlag(SongOptionalFields.Albums)) { Albums = song.OnAlbums.Select(a => new AlbumContract(a, languagePreference)).ToArray(); } if (fields.HasFlag(SongOptionalFields.Artists)) { Artists = song.Artists.Select(a => new ArtistForSongContract(a, languagePreference)).ToArray(); } if (fields.HasFlag(SongOptionalFields.Lyrics)) { Lyrics = song.Lyrics.Select(l => new LyricsForSongContract(l)).ToArray(); } if (fields.HasFlag(SongOptionalFields.MainPicture)) { var thumb = song.GetThumbUrl(); if (!string.IsNullOrEmpty(thumb)) { MainPicture = new EntryThumbForApiContract { UrlThumb = thumb }; } } if (fields.HasFlag(SongOptionalFields.Names)) { Names = song.Names.Select(n => new LocalizedStringContract(n)).ToArray(); } if (song.HasOriginalVersion) { OriginalVersionId = song.OriginalVersion.Id; } if (fields.HasFlag(SongOptionalFields.PVs)) { PVs = song.PVs.Select(p => new PVContract(p)).ToArray(); } if (fields.HasFlag(SongOptionalFields.ReleaseEvent) && song.ReleaseEvent != null) { ReleaseEvent = new ReleaseEventForApiContract(song.ReleaseEvent, languagePreference, ReleaseEventOptionalFields.None, null, true); } if (fields.HasFlag(SongOptionalFields.Tags)) { Tags = song.Tags.ActiveUsages.Select(u => new TagUsageForApiContract(u, languagePreference)).ToArray(); } if (fields.HasFlag(SongOptionalFields.ThumbUrl)) { ThumbUrl = song.GetThumbUrl(); } if (fields.HasFlag(SongOptionalFields.WebLinks)) { WebLinks = song.WebLinks.Select(w => new WebLinkForApiContract(w)).ToArray(); } if (mergeRecord != null) { MergedTo = mergeRecord.Target.Id; } }
public SongForApiContract GetSongForApi(int songId, SongOptionalFields fields, ContentLanguagePreference?lang = null) { return(GetSongWithMergeRecord(songId, (song, r) => new SongForApiContract(song, r, lang ?? PermissionContext.LanguagePreference, fields))); }
public IEnumerable <SongForApiContract> GetTopSongs( int?durationHours = null, DateTime?startDate = null, TopSongsDateFilterType?filterBy = null, SongVocalistSelection?vocalist = null, int maxResults = 25, SongOptionalFields fields = SongOptionalFields.None, ContentLanguagePreference languagePreference = ContentLanguagePreference.Default) { return(queries.HandleQuery(ctx => { var query = ctx.Query() .Where(s => !s.Deleted && s.RatingScore > 0) .WhereHasVocalist(vocalist ?? SongVocalistSelection.Nothing); if (durationHours.HasValue) { var timeSpan = TimeSpan.FromHours(durationHours.Value); DateTime?endDate = null; if (!startDate.HasValue) { startDate = DateTime.Now - timeSpan; } else { endDate = startDate + timeSpan; } switch (filterBy) { case TopSongsDateFilterType.PublishDate: { startDate = startDate?.Date; endDate = endDate?.Date; query = query.WherePublishDateIsBetween(startDate, endDate); break; } case TopSongsDateFilterType.CreateDate: { query = query.Where(s => s.CreateDate >= startDate); break; } case TopSongsDateFilterType.Popularity: { // Sort by number of ratings and hits during that time // Older songs get more hits so value them even less query = query.OrderByDescending(s => s.UserFavorites .Where(f => f.Date >= startDate) .Sum(f => (int)f.Rating) + (s.Hits.Count(h => h.Date >= startDate) / 100)); break; } } if (filterBy != TopSongsDateFilterType.Popularity) { query = query.OrderByDescending(s => s.RatingScore + (s.Hits.Count / 30)); } } else { query = query.OrderByDescending(s => s.RatingScore); } var songs = query .Take(maxResults) .ToArray(); var contracts = songs .Select(s => new SongForApiContract(s, null, languagePreference, fields)) .ToArray(); return contracts; })); }
public SongForApiContract GetById(int id, SongOptionalFields fields = SongOptionalFields.None, ContentLanguagePreference lang = ContentLanguagePreference.Default) { var song = queries.GetSongForApi(id, fields, lang); return(song); }
public RelatedSongsContract GetRelated(int id, SongOptionalFields fields = SongOptionalFields.None, ContentLanguagePreference lang = ContentLanguagePreference.Default) { return(queries.GetRelatedSongs(id, fields, lang)); }
public SongForApiContract GetById(int id, SongOptionalFields fields = SongOptionalFields.None, ContentLanguagePreference lang = ContentLanguagePreference.Default) { var song = service.GetSongWithMergeRecord(id, (s, m) => new SongForApiContract(s, m, lang, fields)); return song; }
public async Task <IEnumerable <SongForApiContract> > GetHighlightedSongs( ContentLanguagePreference languagePreference = ContentLanguagePreference.Default, SongOptionalFields fields = SongOptionalFields.None) { return(await otherService.GetHighlightedSongs(languagePreference, fields)); }
public RatedSongForUserForApiContract(FavoriteSongForUser ratedSong, ContentLanguagePreference languagePreference, SongOptionalFields fields) { this.Rating = ratedSong.Rating; this.Song = new SongForApiContract(ratedSong.Song, null, languagePreference, fields); }
public SongForApiContract(Song song, SongMergeRecord mergeRecord, ContentLanguagePreference languagePreference, SongOptionalFields fields) { ArtistString = song.ArtistString[languagePreference]; CreateDate = song.CreateDate; DefaultName = song.DefaultName; DefaultNameLanguage = song.Names.SortNames.DefaultLanguage; FavoritedTimes = song.FavoritedTimes; Id = song.Id; LengthSeconds = song.LengthSeconds; Name = song.Names.SortNames[languagePreference]; PVServices = song.PVServices; RatingScore = song.RatingScore; SongType = song.SongType; Status = song.Status; Version = song.Version; if (languagePreference != ContentLanguagePreference.Default || fields.HasFlag(SongOptionalFields.AdditionalNames)) { AdditionalNames = song.Names.GetAdditionalNamesStringForLanguage(languagePreference); } if (languagePreference != ContentLanguagePreference.Default) { LocalizedName = song.Names.SortNames[languagePreference]; } if (fields.HasFlag(SongOptionalFields.Albums)) { Albums = song.OnAlbums.Select(a => new AlbumContract(a, languagePreference)).ToArray(); } if (fields.HasFlag(SongOptionalFields.Artists)) { Artists = song.Artists.Select(a => new ArtistForSongContract(a, languagePreference)).ToArray(); } if (fields.HasFlag(SongOptionalFields.Names)) { Names = song.Names.Select(n => new LocalizedStringContract(n)).ToArray(); } if (fields.HasFlag(SongOptionalFields.PVs)) { PVs = song.PVs.Select(p => new PVContract(p)).ToArray(); } if (fields.HasFlag(SongOptionalFields.Tags)) { Tags = song.Tags.Usages.Select(u => new TagUsageForApiContract(u)).ToArray(); } if (fields.HasFlag(SongOptionalFields.ThumbUrl)) { ThumbUrl = VideoServiceHelper.GetThumbUrl(song.PVs.PVs); } if (fields.HasFlag(SongOptionalFields.WebLinks)) { WebLinks = song.WebLinks.Select(w => new WebLinkContract(w)).ToArray(); } if (mergeRecord != null) { MergedTo = mergeRecord.Target.Id; } }
public SongForApiContract GetById(int id, SongOptionalFields fields = SongOptionalFields.None, ContentLanguagePreference lang = ContentLanguagePreference.Default) { var song = service.GetSongWithMergeRecord(id, (s, m) => new SongForApiContract(s, m, lang, fields)); return(song); }
public PartialFindResult<SongForApiContract> GetList( string query = "", SongType songTypes = SongType.Unspecified, string tag = null, int? artistId = null, ArtistAlbumParticipationStatus artistParticipationStatus = ArtistAlbumParticipationStatus.Everything, bool childVoicebanks = false, bool onlyWithPvs = false, int? since = null, [FromUri] ContentLanguageSelections? lyrics = null, int? userCollectionId = null, EntryStatus? status = null, int start = 0, int maxResults = defaultMax, bool getTotalCount = false, SongSortRule sort = SongSortRule.Name, NameMatchMode nameMatchMode = NameMatchMode.Exact, SongOptionalFields fields = SongOptionalFields.None, ContentLanguagePreference lang = ContentLanguagePreference.Default) { query = FindHelpers.GetMatchModeAndQueryForSearch(query, ref nameMatchMode); var types = songTypes != SongType.Unspecified ? new[] { songTypes } : new SongType[0]; var param = new SongQueryParams(query, types, start, Math.Min(maxResults, absoluteMax), false, getTotalCount, nameMatchMode, sort, false, false, 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, UserCollectionId = userCollectionId ?? 0 }; param.Common.EntryStatus = status; var artists = service.Find(s => new SongForApiContract(s, null, lang, fields), param); return artists; }