Exemple #1
0
        public async Task SaveMediaTags()
        {
            var api = new LastFMAPI();
            var mp3 = TagLib.File.Create(CurrentFile);

            if (OrderNumberInMediaTagEnabled && Count.HasValue)
            {
                mp3.Tag.Track = (uint)Count.Value;
            }

            mp3.Tag.Title        = Track.Title;
            mp3.Tag.AlbumArtists = new[] { Track.Artist };
            mp3.Tag.Performers   = new[] { Track.Artist };

            if (Track.AlbumPosition != null)
            {
                mp3.Tag.Track = (uint)Track.AlbumPosition;
            }

            mp3.Tag.Album  = Track.Album;
            mp3.Tag.Genres = Track.Genres;

            mp3.Tag.Performers   = Track.Performers;
            mp3.Tag.Disc         = Track.Disc;
            mp3.Tag.AlbumArtists = Track.AlbumArtists;
            mp3.Tag.Year         = Track.Year;

            if (File.Exists(CurrentFile))
            {
                mp3.Save();
            }

            var taskGetArtXL = Track.GetArtExtraLargeAsync();
            var taskGetArtL  = Track.GetArtLargeAsync();
            var taskGetArtM  = Track.GetArtMediumAsync();
            var taskGetArtS  = Track.GetArtSmallAsync();

            await Task.WhenAll(taskGetArtXL, taskGetArtL, taskGetArtM, taskGetArtS);

            mp3.Tag.Pictures = new TagLib.IPicture[4]
            {
                GetAlbumCoverToPicture(Track.ArtExtraLarge),
                GetAlbumCoverToPicture(Track.ArtLarge),
                GetAlbumCoverToPicture(Track.ArtMedium),
                GetAlbumCoverToPicture(Track.ArtSmall)
            };

            if (File.Exists(CurrentFile))
            {
                mp3.Save();
            }

            mp3.Dispose();
        }
Exemple #2
0
        public SpotifyAPI(string clientId, string secretId, string redirectUrl = "http://localhost:4002")
        {
            _clientId  = clientId;
            _secretId  = secretId;
            _lastFmApi = new LastFMAPI();

            if (!string.IsNullOrEmpty(_clientId) && !string.IsNullOrEmpty(_secretId))
            {
                _auth = new AuthorizationCodeAuth(_clientId, _secretId, redirectUrl, redirectUrl,
                                                  Scope.Streaming | Scope.PlaylistReadCollaborative | Scope.UserReadCurrentlyPlaying | Scope.UserReadRecentlyPlayed | Scope.UserReadPlaybackState);
                _auth.AuthReceived += AuthOnAuthReceived;
                _auth.Start();
            }
        }