Esempio n. 1
0
    internal static ArtistViewModel ProjectToViewModel(Artist artist, List <string> languages)
    {
        ArtistMetadata metadata = Optional(artist.ArtistMetadata).Flatten().Head();

        return(new ArtistViewModel(
                   metadata.Title,
                   metadata.Disambiguation,
                   metadata.Biography,
                   Artwork(metadata, ArtworkKind.Thumbnail),
                   Artwork(metadata, ArtworkKind.FanArt),
                   metadata.Genres.Map(g => g.Name).ToList(),
                   metadata.Styles.Map(s => s.Name).ToList(),
                   metadata.Moods.Map(m => m.Name).ToList(),
                   LanguagesForArtist(languages)));
    }
 private void RefreshFromMetadata(ArtistMetadata metadata)
 {
     Biography   = metadata.Biography;
     BornOn      = metadata.BornOn;
     DiedOn      = metadata.DiedOn;
     DisbandedOn = metadata.DisbandedOn;
     FormedOn    = metadata.FormedOn;
     Genres.ReplaceWith(metadata.Genres);
     Id          = metadata.Mbid;
     Instruments = metadata.Instruments;
     Moods.ReplaceWith(metadata.Moods);
     Name.Value = metadata.Name;
     Name.Save();
     Styles.ReplaceWith(metadata.Styles);
     YearsActive.ReplaceWith(metadata.YearsActive);
 }
Esempio n. 3
0
        private static ArtistMetadata MapArtistMetadata(ArtistResource resource)
        {
            ArtistMetadata artist = new ArtistMetadata();

            artist.Name                = resource.ArtistName;
            artist.Aliases             = resource.ArtistAliases;
            artist.ForeignArtistId     = resource.Id;
            artist.OldForeignArtistIds = resource.OldIds;
            artist.Genres              = resource.Genres;
            artist.Overview            = resource.Overview;
            artist.Disambiguation      = resource.Disambiguation;
            artist.Type                = resource.Type;
            artist.Status              = MapArtistStatus(resource.Status);
            artist.Ratings             = MapRatings(resource.Rating);
            artist.Images              = resource.Images?.Select(MapImage).ToList();
            artist.Links               = resource.Links?.Select(MapLink).ToList();
            return(artist);
        }
Esempio n. 4
0
    private async Task <Either <BaseError, MediaItemScanResult <Artist> > > UpdateArtworkForArtist(
        MediaItemScanResult <Artist> result,
        string artistFolder,
        ArtworkKind artworkKind,
        CancellationToken cancellationToken)
    {
        try
        {
            Artist artist = result.Item;
            await LocateArtworkForArtist(artistFolder, artworkKind).IfSomeAsync(
                async artworkFile =>
            {
                ArtistMetadata metadata = artist.ArtistMetadata.Head();
                await RefreshArtwork(artworkFile, metadata, artworkKind, None, None, cancellationToken);
            });

            return(result);
        }
        catch (Exception ex)
        {
            _client.Notify(ex);
            return(BaseError.New(ex.ToString()));
        }
    }
Esempio n. 5
0
 public ArtistListTests()
 {
     this.data = TestHelper.Get <ArtistMetadata>("artist-search.xml", false);
 }
Esempio n. 6
0
        private static TrackFile Map(Dictionary <int, TrackFile> dict, TrackFile file, Track track, Album album, Artist artist, ArtistMetadata metadata)
        {
            if (!dict.TryGetValue(file.Id, out var entry))
            {
                if (artist != null)
                {
                    artist.Metadata = metadata;
                }

                entry        = file;
                entry.Tracks = new List <Track>();
                entry.Album  = album;
                entry.Artist = artist;
                dict.Add(entry.Id, entry);
            }

            if (track != null)
            {
                entry.Tracks.Value.Add(track);
            }

            return(entry);
        }
Esempio n. 7
0
        public FileNameSampleService(IBuildFileNames buildFileNames)
        {
            _buildFileNames = buildFileNames;
            var artistMetadata = new ArtistMetadata
            {
                Name           = "The Artist Name",
                Disambiguation = "US Rock Band"
            };

            _standardArtist = new Artist
            {
                Metadata = artistMetadata
            };

            _standardAlbum = new Album
            {
                Title          = "The Album Title",
                ReleaseDate    = System.DateTime.Today,
                AlbumType      = "Album",
                Disambiguation = "The Best Album",
            };

            _singleRelease = new AlbumRelease
            {
                Album = _standardAlbum,
                Media = new List <Medium>
                {
                    new Medium
                    {
                        Name   = "CD 1: First Years",
                        Format = "CD",
                        Number = 1
                    }
                },
                Monitored = true
            };

            _multiRelease = new AlbumRelease
            {
                Album = _standardAlbum,
                Media = new List <Medium>
                {
                    new Medium
                    {
                        Name   = "CD 1: First Years",
                        Format = "CD",
                        Number = 1
                    },
                    new Medium
                    {
                        Name   = "CD 2: Second Best",
                        Format = "CD",
                        Number = 2
                    }
                },
                Monitored = true
            };

            _track1 = new Track
            {
                AlbumRelease        = _singleRelease,
                Artist              = _standardArtist,
                AbsoluteTrackNumber = 3,
                MediumNumber        = 1,
                ArtistMetadata      = artistMetadata,

                Title = "Track Title (1)",
            };

            _singleTrack = new List <Track> {
                _track1
            };

            var mediaInfo = new MediaInfoModel()
            {
                AudioFormat     = "Flac Audio",
                AudioChannels   = 2,
                AudioBitrate    = 875,
                AudioBits       = 24,
                AudioSampleRate = 44100
            };

            _singleTrackFile = new TrackFile
            {
                Quality      = new QualityModel(Quality.MP3_256, new Revision(2)),
                Path         = "/music/Artist.Name.Album.Name.TrackNum.Track.Title.MP3256.mp3",
                SceneName    = "Artist.Name.Album.Name.TrackNum.Track.Title.MP3256",
                ReleaseGroup = "RlsGrp",
                MediaInfo    = mediaInfo
            };

            _preferredWords = new List <string>
            {
                "iNTERNAL"
            };
        }
 protected override async Task SaveInternal()
 {
     Name.Save();
     ArtistMetadata metadata = CreateMetadata();
     await _metadataService.Save(Path, metadata);
 }