Ejemplo n.º 1
0
		private IArtistWithSupport CreateArtist(ArtistType artistType, string name) {

			var p = new Artist { ArtistType = artistType };
			p.Names.Add(new ArtistName(p, new LocalizedString(name, ContentLanguageSelection.English)));
			return p.AddAlbum(new Album());

		}
Ejemplo n.º 2
0
        public ActionResult Index(string filter, EntryType searchType = EntryType.Undefined, bool allowRedirect = true,
            string tag = null,
            string sort = null,
            int? artistId = null,
            ArtistType? artistType = null,
            DiscType? discType = null,
            SongType? songType = null,
            bool? onlyWithPVs = null
            )
        {
            filter = !string.IsNullOrEmpty(filter) ? filter.Trim() : string.Empty;

            if (allowRedirect && !string.IsNullOrEmpty(filter)) {

                var redirectResult = TryRedirect(filter, searchType);

                if (redirectResult != null)
                    return redirectResult;

            }

            ViewBag.Query = filter;
            ViewBag.SearchType = searchType != EntryType.Undefined ? searchType.ToString() : "Anything";
            ViewBag.Tag = tag;
            ViewBag.Sort = sort;
            ViewBag.ArtistId = artistId;
            ViewBag.ArtistType = artistType;
            ViewBag.DiscType = discType;
            ViewBag.SongType = songType;
            ViewBag.OnlyWithPVs = onlyWithPVs;

            SetSearchEntryType(searchType);
            return View();
        }
Ejemplo n.º 3
0
		public ArtistQueryParams() {

			Common = new CommonSearchParams();
			Paging = new PagingProperties(0, 30, true);
			ArtistTypes = new ArtistType[] { };

		}
Ejemplo n.º 4
0
        public static IQueryable<ArtistName> FilterByArtistType(this IQueryable<ArtistName> queryable, ArtistType[] types)
        {
            if (types == null || !types.Any())
                return queryable;

            return queryable.Where(n => types.Contains(n.Artist.ArtistType));
        }
Ejemplo n.º 5
0
        /// <param name="query">Query search string. Can be null or empty, in which case no filtering by name is done.</param>
        /// <param name="songTypes">Allowed song types. Can be null or empy, in which case no filtering by song type is done.</param>
        /// <param name="start">0-based order number of the first item to be returned.</param>
        /// <param name="maxResults">Maximum number of results to be returned.</param>
        /// <param name="draftsOnly">Whether to return only entries with a draft status.</param>
        /// <param name="getTotalCount">Whether to return the total number of entries matching the criteria.</param>
        /// <param name="nameMatchMode">Mode for name maching. Ignored when query string is null or empty.</param>
        /// <param name="sortRule">Sort rule for results.</param>
        /// <param name="moveExactToTop">Whether to move exact match to the top of search results.</param>
        public ArtistQueryParams(string query, ArtistType[] songTypes, int start, int maxResults,
            bool draftsOnly, bool getTotalCount, NameMatchMode nameMatchMode, ArtistSortRule sortRule, bool moveExactToTop)
        {
            Common = new CommonSearchParams(query, draftsOnly, nameMatchMode, true, moveExactToTop);
            Paging = new PagingProperties(start, maxResults, getTotalCount);

            ArtistTypes = songTypes ?? new ArtistType[] { };
            SortRule = sortRule;
        }
		/// <summary>
		/// Filters out songs that aren't "main" songs for a particular artist type.
		/// 
		/// At the moment this just filters out PVs for music producers.
		/// Used by the "recent songs" list on artist page.
		/// </summary>
		/// <param name="query">Query. Cannot be null.</param>
		/// <param name="artistType">Artist type.</param>
		/// <returns>Filtered query.</returns>
		public static IQueryable<ArtistForSong> WhereIsMainSong(this IQueryable<ArtistForSong> query, ArtistType artistType) {
			
			if (artistType == ArtistType.Producer) {

				return query.Where(q => q.Song.SongType != SongType.MusicPV 
					|| (q.Roles & ArtistRoles.Animator) != ArtistRoles.Default);

			}

			return query;

		}
Ejemplo n.º 7
0
        public ArtistIndex(PartialFindResult<ArtistWithAdditionalNamesContract> result, string filter,
            ArtistType artistType, bool? draftsOnly, ArtistSortRule sort, int? page, IndexRouteParams routeParams)
        {
            Artists = new StaticPagedList<ArtistWithAdditionalNamesContract>(result.Items, page ?? 1, 30, result.TotalCount);
            DraftsOnly = draftsOnly ?? false;
            Filter = filter;
            ArtistType = artistType;
            Sort = sort;
            RouteParams = routeParams;

            FilterableArtistTypes = EnumVal<ArtistType>.Values.ToDictionary(a => a, Translate.ArtistTypeName);
        }
Ejemplo n.º 8
0
 public Artist(ArtistType type, string name, short year)
 {
     this.type = type;
     this.name = name ?? string.Empty;
     this.year = year;
 }
Ejemplo n.º 9
0
		public static Artist Vocalist(int id = 0, string name = null, ArtistType artistType = ArtistType.Vocaloid) {
			return new Artist(TranslatedString.Create(name ?? "Hatsune Miku")) { Id = id, ArtistType = artistType };			
		}
Ejemplo n.º 10
0
		public static Artist Artist(ArtistType artistType, int id = 0, string name = "Artist") {
			return new Artist(TranslatedString.Create(name)) { Id = id, ArtistType = artistType };
		}
Ejemplo n.º 11
0
 public static bool IsVoiceSynthesizer(ArtistType artistType)
 {
     return(VoiceSynthesizerTypes.Contains(artistType));
 }
Ejemplo n.º 12
0
 public Artist(int id, string fullName, ArtistType artistType)
 {
     Id = id; FullName = fullName; ArtistType = artistType;
 }
Ejemplo n.º 13
0
        public async Task <IList <AlbumData> > GetArtistAlbumDataAsync(IList <string> artists, ArtistType artistType)
        {
            var albumData = new List <AlbumData>();

            await Task.Run(() =>
            {
                try
                {
                    using (var conn = this.factory.GetConnection())
                    {
                        try
                        {
                            string filterQuery = string.Empty;

                            if (artists != null)
                            {
                                if (artistType.Equals(ArtistType.All))
                                {
                                    filterQuery = $" AND ({DataUtils.CreateOrLikeClause("Artists", artists, Constants.ColumnValueDelimiter)} OR {DataUtils.CreateOrLikeClause("AlbumArtists", artists, Constants.ColumnValueDelimiter)})";
                                }
                                else if (artistType.Equals(ArtistType.Track))
                                {
                                    filterQuery = $" AND ({DataUtils.CreateOrLikeClause("Artists", artists, Constants.ColumnValueDelimiter)})";
                                }
                                else if (artistType.Equals(ArtistType.Album))
                                {
                                    filterQuery = $" AND ({DataUtils.CreateOrLikeClause("AlbumArtists", artists, Constants.ColumnValueDelimiter)})";
                                }
                            }

                            string query = this.SelectVisibleAlbumDataQuery() + filterQuery + " GROUP BY AlbumKey";

                            albumData = conn.Query <AlbumData>(query);
                        }
                        catch (Exception ex)
                        {
                            LogClient.Error("Could not get all the album values. Exception: {0}", ex.Message);
                        }
                    }
                }
                catch (Exception ex)
                {
                    LogClient.Error("Could not connect to the database. Exception: {0}", ex.Message);
                }
            });

            return(albumData);
        }
Ejemplo n.º 14
0
 public static IQueryable <Song> WhereArtistHasType(this IQueryable <Song> query, ArtistType artistType)
 {
     return(query.WhereArtistHasType <Song, ArtistForSong>(artistType));
 }
Ejemplo n.º 15
0
        public static IQueryable <T> WhereArtistHasType <T>(this IQueryable <T> query, ArtistType artistType) where T : IArtistLink
        {
            if (artistType == ArtistType.Unknown)
            {
                return(query);
            }

            return(query.Where(m => m.Artist.ArtistType == artistType));
        }
Ejemplo n.º 16
0
 public ArtistQueryParams()
 {
     Common      = new CommonSearchParams();
     Paging      = new PagingProperties(0, 30, true);
     ArtistTypes = new ArtistType[] { };
 }
Ejemplo n.º 17
0
 public static string ArtistTypeName(ArtistType artistType)
 {
     return(Model.Resources.ArtistTypeNames.ResourceManager.GetString(artistType.ToString()));
 }
Ejemplo n.º 18
0
 public Artist(string artist, ArtistType type)
 {
     this.artist = artist;
     this.type   = type;
 }
Ejemplo n.º 19
0
 public Artist(ArtistType type, string name, short year)
 {
     this.type = type;
     this.name = name ?? string.Empty;
     this.year = year;
 }
Ejemplo n.º 20
0
		public static IQueryable<Artist> WhereHasType(this IQueryable<Artist> query, ArtistType[] artistTypes) {

			if (!artistTypes.Any())
				return query;

			return query.Where(m => artistTypes.Contains(m.ArtistType));

		}
Ejemplo n.º 21
0
        public PartialFindResult<ArtistForUserForApiContract> GetFollowedArtists(
            int userId,
            ArtistType artistType = ArtistType.Unknown,
            int start = 0,
            int maxResults = defaultMax,
            bool getTotalCount = false,
            ArtistOptionalFields fields = ArtistOptionalFields.None,
            ContentLanguagePreference lang = ContentLanguagePreference.Default)
        {
            maxResults = Math.Min(maxResults, absoluteMax);
            var ssl = WebHelper.IsSSL(Request);

            var queryParams = new FollowedArtistQueryParams {
                UserId = userId,
                ArtistType = artistType,
                Paging = new PagingProperties(start, maxResults, getTotalCount),
            };

            var artists = queries.GetArtists(queryParams, afu =>
                new ArtistForUserForApiContract(afu, lang, thumbPersister, ssl, fields));

            return artists;
        }
Ejemplo n.º 22
0
        public static IQueryable <T> WhereAlbumHasArtistWithType <T>(this IQueryable <T> query, ArtistType artistType)
            where T : IAlbumLink
        {
            if (artistType == ArtistType.Unknown)
            {
                return(query);
            }

            return(query.Where(s => s.Album.AllArtists.Any(a => !a.IsSupport && a.Artist.ArtistType == artistType)));
        }
Ejemplo n.º 23
0
		public static ArtistRoles GetOtherArtistRoles(ArtistType artistType) {

			switch (artistType) {
				case ArtistType.Illustrator:
					return ArtistRoles.Illustrator;

				case ArtistType.Lyricist:
					return ArtistRoles.Lyricist;

				default:
					return ArtistRoles.Default;
			}

		}
Ejemplo n.º 24
0
 public static string ArtistTypeName(ArtistType artistType)
 {
     return ArtistTypeNames.ResourceManager.GetString(artistType.ToString());
 }
Ejemplo n.º 25
0
        public static IQueryable <Song> WhereArtistHasType(this IQueryable <Song> query, ArtistType artistType)
        {
            if (artistType == ArtistType.Unknown)
            {
                return(query);
            }

            return(query.Where(s => s.AllArtists.Any(a => a.Artist.ArtistType == artistType)));
        }
        /// <summary>
        /// Filters out songs that aren't "main" songs for a particular artist type.
        ///
        /// At the moment this just filters out PVs for music producers.
        /// Used by the "recent songs" list on artist page.
        /// </summary>
        /// <param name="query">Query. Cannot be null.</param>
        /// <param name="artistType">Artist type.</param>
        /// <returns>Filtered query.</returns>
        public static IQueryable <ArtistForSong> WhereIsMainSong(this IQueryable <ArtistForSong> query, ArtistType artistType)
        {
            if (artistType == ArtistType.Producer)
            {
                return(query.Where(q => q.Song.SongType != SongType.MusicPV ||
                                   (q.Roles & ArtistRoles.Animator) != ArtistRoles.Default));
            }

            return(query);
        }
Ejemplo n.º 27
0
 public static bool IsCustomizable(ArtistType at)
 {
     return(CustomizableTypes.Contains(at));
 }
        /// <summary>
        /// Filters out songs that aren't "main" songs for a particular artist type.
        ///
        /// At the moment this just filters out PVs for music producers.
        /// Used by the "recent songs" list on artist page.
        /// </summary>
        /// <param name="query">Query. Cannot be null.</param>
        /// <param name="artistType">Artist type.</param>
        /// <returns>Filtered query.</returns>
        public static IQueryable <ArtistForSong> WhereIsMainSong(this IQueryable <ArtistForSong> query, ArtistType artistType)
        {
            if (artistType == ArtistType.Producer)
            {
                return(query
                       .Where(artistForSong => (artistForSong.Song.SongType != SongType.MusicPV || (artistForSong.Roles & ArtistRoles.Animator) != ArtistRoles.Default) &&
                              artistForSong.Roles != ArtistRoles.VocalDataProvider));
            }

            return(query);
        }
Ejemplo n.º 29
0
 public Artist(int id, string name, ArtistType artistType)
 {
     ID         = id;
     Name       = name;
     ArtistType = artistType;
 }
Ejemplo n.º 30
0
		public static ArtistCategories GetCategories(ArtistType type, ArtistRoles roles) {

			if (roles == ArtistRoles.Default || !IsCustomizable(type)) {

				return CategoriesForTypes[type];

			} else {

				var cat = ArtistCategories.Nothing;

				if (roles.HasFlag(ArtistRoles.Vocalist) || roles.HasFlag(ArtistRoles.Chorus))
					cat |= ArtistCategories.Vocalist;

				if (roles.HasFlag(ArtistRoles.Arranger) || roles.HasFlag(ArtistRoles.Composer) || roles.HasFlag(ArtistRoles.VoiceManipulator))
					cat |= ArtistCategories.Producer;

				if (roles.HasFlag(ArtistRoles.Distributor) || roles.HasFlag(ArtistRoles.Publisher))
					cat |= ArtistCategories.Circle;

				if (roles.HasFlag(ArtistRoles.Animator))
					cat |= ArtistCategories.Animator;

				//if (roles.HasFlag(ArtistRoles.Illustrator) || roles.HasFlag(ArtistRoles.Lyricist) || roles.HasFlag(ArtistRoles.Mastering))
				//	cat |= ArtistCategories.Other;

				if (cat == ArtistCategories.Nothing)
					cat = ArtistCategories.Other;

				return cat;

			}


		}
Ejemplo n.º 31
0
        public static IQueryable <TEntry> WhereArtistHasType <TEntry, TArtistLink>(this IQueryable <TEntry> query, ArtistType artistType)
            where TEntry : IEntryWithArtistLinks <TArtistLink>
            where TArtistLink : IArtistLinkWithRoles
        {
            if (artistType == ArtistType.Unknown)
            {
                return(query);
            }

            return(query.Where(s => s.AllArtists.Any(a => !a.IsSupport && a.Artist.ArtistType == artistType)));
        }
Ejemplo n.º 32
0
		public static bool IsCustomizable(ArtistType at) {

			return CustomizableTypes.Contains(at);

		}
Ejemplo n.º 33
0
        public async Task <List <Artist> > GetArtistsAsync(ArtistType artistType)
        {
            var artists = new List <Artist>();

            await Task.Run(() =>
            {
                try
                {
                    using (var conn = this.factory.GetConnection())
                    {
                        try
                        {
                            var trackArtists = new List <Artist>();
                            var albumArtists = new List <string>();

                            // Get the Track Artists
                            trackArtists = conn.Query <Artist>("SELECT DISTINCT art.ArtistID, art.ArtistName FROM Artist art" +
                                                               " INNER JOIN Track tra ON art.ArtistID=tra.ArtistID" +
                                                               " INNER JOIN Folder fol ON tra.FolderID=fol.FolderID" +
                                                               " WHERE fol.ShowInCollection=1");

                            // Get the Album Artists
                            var albums = conn.Query <Album>("SELECT DISTINCT alb.AlbumID, alb.AlbumTitle, alb.AlbumArtist, alb.Year, alb.ArtworkID, alb.DateLastSynced, alb.DateAdded FROM Album alb" +
                                                            " INNER JOIN Track tra ON alb.AlbumID=tra.AlbumID" +
                                                            " INNER JOIN Folder fol ON tra.FolderID=fol.FolderID" +
                                                            " INNER JOIN Artist art ON tra.ArtistID=art.ArtistID" +
                                                            " WHERE tra.AlbumID=alb.AlbumID AND tra.ArtistID=tra.ArtistID AND fol.ShowInCollection=1");

                            albumArtists = albums.Select((a) => a.AlbumArtist).ToList();

                            if (artistType == ArtistType.All | artistType == ArtistType.Track)
                            {
                                foreach (Artist trackArtist in trackArtists)
                                {
                                    artists.Add(trackArtist);
                                }
                            }

                            if (artistType == ArtistType.All | artistType == ArtistType.Album)
                            {
                                foreach (string albumArtist in albumArtists)
                                {
                                    if (!artists.Select((art) => art.ArtistName).Contains(albumArtist))
                                    {
                                        artists.Add(new Artist {
                                            ArtistName = albumArtist
                                        });
                                    }
                                }
                            }

                            // Orders the artists
                            artists = artists.OrderBy((a) => Utils.GetSortableString(a.ArtistName, true)).ToList();
                        }
                        catch (Exception ex)
                        {
                            LogClient.Instance.Logger.Error("Could not get the Artists. Exception: {0}", ex.Message);
                        }
                    }
                }
                catch (Exception ex)
                {
                    LogClient.Instance.Logger.Error("Could not connect to the database. Exception: {0}", ex.Message);
                }
            });

            return(artists);
        }