Exemplo n.º 1
0
 public static SourceTrack[] ToTracksModel(this TracksModel tracks)
 {
     return(tracks?.Tracks?
            .Select(x =>
                    new SourceTrack
     {
         Title = x.Title,
         Artist = x.Artist
     })
            .ToArray() ?? Array.Empty <SourceTrack>());
 }
        private dynamic TracksByGenre(dynamic parameters)
        {
            int id          = parameters.id;
            var genreTracks = _trackDataProvider.GetAll().Where(t => t.GenreId.Equals(id)).ToList();

            foreach (Track track in genreTracks)
            {
                track.Artist = _artistDataProvider.GetEntityById(track.ArtistId).ArtistName;
            }
            var tracksModel = new TracksModel {
                TracksPresent = genreTracks.Any(), Tracks = genreTracks
            };

            return(View["mp3player/tracksbygenre", tracksModel]);
        }
Exemplo n.º 3
0
        public String Get()
        {
            TracksModel model = new TracksModel();

            model.ParseAudioLibrary();
            string result = "";
            var    item   = new
            {
                Songs = model.Tracks
            };
            var    jsonObject = JObject.FromObject(item);
            JArray array      = (JArray)jsonObject["Songs"];

            result = array.ToString();

            return(result);
        }
Exemplo n.º 4
0
        public ActionResult Tracks(FormModel model)
        {
            var spotifyApi  = new SpotifyIntegration.SpotifyIntegration();
            var tracksModel = new TracksModel();

            if (model.Name != null && model.Name.ToLower() == "tom araya")
            {
                tracksModel.TrackList = spotifyApi.GetSingleTrack("4Yx9Tw9dTgQ8eGCq3PRDyn");
            }
            else
            {
                var targetTrack = new TuneableTrack()
                {
                    Valence      = model.Valence / 100,
                    Danceability = model.FeelLikeDancing / 100,
                };

                if (model.SelectedGenres.Length + model.SelectedArtists.Length + model.SelectedTracks.Length > 5)
                {
                    model.Genres       = FormModelListItemHelper.GetGenres();
                    model.Tracks       = FormModelListItemHelper.GetTracks();
                    model.Artists      = FormModelListItemHelper.GetArtists();
                    model.ErrorMessage =
                        "Whoops, according to Spotify you can only select a total of 5 tracks, genres and artists for recommendations. Deselect a few and try again and sorry for the inconvenience.";
                    return(View("~/Views/Genre/Genre.cshtml", model)); //RedirectToRoute("Genre", model);
                }

                tracksModel.TrackList = spotifyApi.GetRecommendations(
                    artists: model.SelectedArtists.ToList(),
                    tracks: model.SelectedTracks.ToList(),
                    genres: model.SelectedGenres.ToList(),
                    targetTrack: targetTrack);
            }

            return(View(tracksModel));
        }
Exemplo n.º 5
0
            private string ParseCueTools(string lx)
            {
                do
                {
                    lx = parser.ReadLineLTrim();
                    if (parser.EOF || lx.StartsWith("==== "))
                    {
                        return(lx);
                    }
                } while (!lx.StartsWith("[CTDB"));

                if (lx.Contains("not present"))
                {
                    Data.CueToolsConfidence = 0;
                    lx = parser.ReadLineLTrim();
                    if (!parser.EOF && lx.StartsWith("Submit"))
                    {
                        lx = parser.ReadLineLTrim();
                    }
                    return(lx);
                }

                if (!lx.Contains(" found"))
                {
                    return(lx);
                }

                do
                {
                    lx = parser.ReadLineLTrim();
                    if (parser.EOF || lx.StartsWith("==== "))
                    {
                        return(lx);
                    }

                    if (lx.StartsWith("["))
                    {
                        int ctConfidence = -1;
                        if (lx.Contains("Accurately ripped"))
                        {
                            bool isOK = ToInt(lx, 12, out ctConfidence);
                        }
                        Data.CueToolsConfidence = ctConfidence;
                        lx = parser.ReadLineLTrim();
                        return(lx);
                    }
                } while (!lx.StartsWith("Track"));

                for (int tx = 0; ; ++tx)
                {
                    lx = parser.ReadLine();
                    if (parser.EOF || lx.StartsWith("==== ") || lx.StartsWith("All tracks"))
                    {
                        return(lx);
                    }

                    int ctConfidence;
                    if (lx.Contains("Accurately ripped"))
                    {
                        bool isOK = ToInt(lx, 9, out ctConfidence);
                        if (!isOK)
                        {
                            Data.CueToolsConfidence = -1; return(lx);
                        }
                    }
                    else if (lx.Contains("Differs"))
                    {
                        ctConfidence = -1;
                    }
                    else
                    {
                        break;
                    }

                    if (tx < TracksModel.Data.Items.Count)
                    {
                        TracksModel.SetCtConfidence(tx, ctConfidence);
                    }
                    if (Data.CueToolsConfidence == null || Data.CueToolsConfidence > ctConfidence)
                    {
                        Data.CueToolsConfidence = ctConfidence;
                    }
                }
                return(parser.ReadLineLTrim());
            }
Exemplo n.º 6
0
            private string ParseTrack(string lx, int num)
            {
                string name = "", peak = "", speed = "", pregap = "", qual = "";
                int?   arVersion = null;
                int?   arConfidence = null;
                uint?  testCrc = null, copyCrc = null;
                bool   trackErr = false;
                uint   word;

                name = lx.Substring(9);
                if (name.Length < 10 || (lx.Length < 252 && !lx.EndsWith(".wav")))
                {
                    IssueModel.Add("Unexpected extension " + parser.GetPlace());
                }

                lx = parser.ReadLineLTrim();
                if (lx.StartsWith("Pre-gap length  "))
                {
                    pregap = lx.Substring(16); lx = parser.ReadLineLTrim();
                }

                for (;;)
                {
                    if (parser.EOF)
                    {
                        return(lx);
                    }

                    if (lx.StartsWith("Track quality") || lx.StartsWith("Peak level "))
                    {
                        break;
                    }

                    if (lx.StartsWith("Track "))
                    {
                        return(lx);  // Unexpected start of next track.
                    }
                    if (!trackErr)
                    {
                        trackErr = true;
                        IssueModel.Add($"Track {num}: '{lx}'.");
                    }
                    lx = parser.ReadLineLTrim();
                }

                if (lx.StartsWith("Peak level "))
                {
                    peak = lx.Substring(11); lx = parser.ReadLineLTrim();
                }

                if (lx.StartsWith("Extraction speed "))
                {
                    speed = lx.Substring(17); lx = parser.ReadLineLTrim();
                }

                if (lx.StartsWith("Track quality "))
                {
                    qual = lx.Substring(14); lx = parser.ReadLineLTrim();
                }

                if (lx.StartsWith("Test CRC "))
                {
                    if (uint.TryParse(lx.Substring(9), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out word))
                    {
                        testCrc = word;
                    }
                    else
                    {
                        Data.TpIssue = IssueModel.Add($"Track {num}: Invalid test CRC-32.", Severity.Error, IssueTags.Failure);
                    }
                    lx = parser.ReadLineLTrim();
                }

                if (!lx.StartsWith("Copy CRC "))
                {
                    IssueModel.Add($"Track {num}: Missing copy CRC-32.", Severity.Warning);
                }
                else
                {
                    if (uint.TryParse(lx.Substring(9), NumberStyles.HexNumber, CultureInfo.InvariantCulture, out word))
                    {
                        copyCrc = word;
                    }
                    else
                    {
                        Data.TkIssue = IssueModel.Add($"Track {num}: Invalid copy CRC-32.", Severity.Error, IssueTags.Failure);
                    }
                    lx = parser.ReadLineLTrim();
                }

                if (lx.StartsWith("Accurately ripped (confidence "))
                {
                    arVersion = lx.Contains("AR v2")? 2 : 1;
                    bool isOk = ToInt(lx, 30, out int val);
                    arConfidence = isOk && val > 0? val : -1;
                    lx           = parser.ReadLineLTrim();
                }
                else if (lx.StartsWith("Cannot be verified"))
                {
                    arVersion    = lx.Contains("AR v2")? 2 : 1;
                    arConfidence = -1;
                    lx           = parser.ReadLineLTrim();
                }
                else if (lx.StartsWith("Track not present"))
                {
                    if (peak != "0.0 %")
                    {
                        arConfidence = 0;
                    }
                    lx = parser.ReadLineLTrim();
                }

                if (arConfidence != null)
                {
                    if (Data.AccurateRipConfidence == null || Data.AccurateRipConfidence > arConfidence)
                    {
                        Data.AccurateRipConfidence = arConfidence;
                    }
                    if (arVersion != null)
                    {
                        if (Data.AccurateRip == null || Data.AccurateRip.Value > arVersion.Value)
                        {
                            Data.AccurateRip = arVersion;
                        }
                    }
                }

                bool hasOK = false;

                if (lx == "Copy OK")
                {
                    hasOK = true;
                    lx    = parser.ReadLineLTrim();
                }

                TracksModel.Add(num, name, pregap, peak, speed, qual, testCrc, copyCrc, hasOK, arVersion, arConfidence);
                return(lx);
            }