Exemple #1
0
        public IActionResult AddSong(AddSongInputModel inputModel)
        {
            if (!ModelState.IsValid)
            {
                return(this.View(inputModel));
            }

            List <string> artists = this.splitterService.SplitArtistName(inputModel.Artist).ToList();
            int           songId  = this.songsService.CreateSong(inputModel.Song, artists);

            string videoId = this.youtubeDataProvider.SearchVideo(string.Join(" ", artists), inputModel.Song);

            if (!string.IsNullOrEmpty(videoId))
            {
                this.metadataService.AddMetadataInfo(songId, GlobalConstants.YouTubeVideo, videoId);
            }
            else
            {
                this.logger.LogWarning($"Video for {string.Join(" ", artists)} {inputModel.Song} not found");
            }

            string lyrics = this.geniusLyrics.AskForLyrics(inputModel.Song, string.Join(" ", artists));

            if (!string.IsNullOrEmpty(lyrics))
            {
                this.metadataService.AddMetadataInfo(songId, GlobalConstants.Lyrics, lyrics);
            }
            else
            {
                this.logger.LogWarning($"Lyrics for {string.Join(" ", artists)} {inputModel.Song} not found");
            }

            this.songsService.UpdateSongsSystemData(songId);

            return(this.Redirect("/"));
        }
Exemple #2
0
        public IActionResult AddSong()
        {
            AddSongInputModel inputModel = new AddSongInputModel();

            return(this.View(inputModel));
        }