internal TrackDescriptor(AlbumDescriptor ad, string iname, int tracknumber, int iDiskNumber)
 {
     _Father = ad;
     Name = iname;
     TrackNumber = (uint)tracknumber;
     DiscNumber = (uint)iDiskNumber;
 }
            private void AddExportAlbum(AlbumDescriptor EA)
            {
                if (_EAs == null)
                    _EAs = new List<AlbumDescriptor>();

                _EAs.Add(EA);
                _EA = EA;
            }
 internal TrackDescriptor(AlbumDescriptor ad, string iname, int tracknumber, TimeSpan iDuration, string artits = null, int iDiskNumber = 0)
 {
     _Father = ad;
     Artist = artits;
     Name = iname;
     Duration = iDuration;
     TrackNumber = (uint)tracknumber;
     DiscNumber = (uint)iDiskNumber;
 }
        internal TrackDescriptor(AlbumDescriptor ad,Track tr)
        {
            _Father = ad;

            this.Artist = tr.Artist;
            this.Name = tr.Name;
            this.Path = tr.Path;
            this.TrackNumber = tr.TrackNumber;
            this.Duration = tr.Duration;
            this.MD5 = tr.MD5HashKey;
            this.Rating = tr.Rating;
            this.DateAdded = tr.Interface.DateAdded;
            this.LastPLayed = tr.Interface.LastPlayed;
            this.PlayCount = tr.Interface.PlayCount;
            this.DiscNumber = tr.Interface.DiscNumber;
        }
 internal TrackDescriptor(AlbumDescriptor ad, string iname, int tracknumber, string iDuration,string iAmazonTrackPosition)
 {
     _Father = ad;
     Name = iname;
     TimeSpan res;
     if (TimeSpan.TryParse(iDuration, out res))
     {
         Duration = iDuration.Count(o => o == ':') == 2 ? res : new TimeSpan(0, res.Hours, res.Minutes);
     }
     Regex rg = new Regex(@"(?<DiscNumber>(\d+))(-|\.)(?<TrackNumber>(\d+))");
     
     var match = rg.Match(iAmazonTrackPosition);
     if (match.Success)
     {
         DiscNumber = uint.Parse(match.Groups["DiscNumber"].Value);
         TrackNumber = uint.Parse(match.Groups["TrackNumber"].Value);
     }
     else
     {
         TrackNumber = (uint)tracknumber;
     }
 }
        static internal AlbumDescriptor FromRoviDynamic(dynamic RoviFound, CancellationToken iCancellationToken)
        {
            AlbumDescriptor res = new AlbumDescriptor();

            try
            {
                res.Name = RoviFound.title;
                res.Artist = MusicCollection.Implementation.Artist.AuthorName((RoviFound.primaryArtists as List<dynamic>).Select(o => o.name as string).ToList());

                string ryear = RoviFound.originalReleaseDate;
                if ((ryear != null) && (ryear.Length >= 4))
                {
                    int year = 0;
                    if (int.TryParse(ryear.Substring(0, 4), out year))
                        res.Year = year;
                }

                if (RoviFound.genres.Count > 0)
                    res.Genre = RoviFound.genres[0].name;

                res.RawTrackDescriptors = (RoviFound.tracks as List<dynamic>)
                    .Select((o, i) => new TrackDescriptor(res, o.title, i + 1, TimeSpan.FromSeconds(o.duration), null, o.disc)).ToList();

                res.TracksNumber = (uint)res.TrackDescriptors.Count;            
            }
            catch
            {
                Trace.WriteLine("Problem during Rovi json parsing");
            }

            return res;
        }
        static internal AlbumDescriptor BuildForExport(Album al, bool Copyall, bool CopyImage)
        {
            var res = new AlbumDescriptor();

            res.Artist = al.Author;
            res.Genre = al.Genre;
            res.RawIDs = al.CDIDs;
            res.TracksNumber = al.Interface.TracksNumber;
            res.Name = al.Name;
            res.Year = al.Interface.Year;
            res.DateAdded = al.Interface.DateAdded;

            if (Copyall)
            {
                res.RawTrackDescriptors = (from tr in al.RawTracks select new TrackDescriptor(res, tr)).ToList();

                if (CopyImage)
                    res.RawImages = (from im in al.ModifiableImages select new AImage(BufferFactory.GetBufferProviderFromFile(im.GetPath()), im.Rank)).ToList();

                res.Thumbnail = al.ImageCachePath;
            }

            return res;
        }
        static internal AlbumDescriptor CreateBasicFromCD(ICDInfoHandler dfih, IImportContext Context, string Artist, string Name, bool Basic = false)
        {
            var res = new AlbumDescriptor();
            res.RawIDs = dfih.IDs;
            res.TracksNumber = (uint)dfih.TrackNumbers;

            res.Artist = Artist;
            res.Name = Name;

            res.RawTrackDescriptors = Enumerable.Range(0, dfih.TrackNumbers).Select(i => new TrackDescriptor(res, string.Format("Track {0}", i + 1), i + 1, dfih.Duration(i), res.Artist)).ToList();
            //if (!Basic)
            //    res.MergeTracksIDsFromCDInfos(dfih);

            return res;
        }
 static internal IAlbumDescriptor SimpleAlbumDescriptorFromAlbumModifier(IInternalAlbumModifier found)
 {
     var res = new AlbumDescriptor();
     res.Artist = MusicCollection.Implementation.Artist.AuthorName(found.Artists);
     res.Year = found.Year;
     res.Genre = found.Genre;
     res.Name = found.Name;
     res.RawIDs = found.CDIDs;
     return res;
 }
        static internal IFullAlbumDescriptor FromiTunes(IITAudioCDPlaylist icd)
        {
            AlbumDescriptor res = new AlbumDescriptor();

            res.Artist = icd.Artist;
            res.Year = icd.Year;
            res.Genre = icd.Genre;
            res.Name = icd.Name;

            IITTrackCollection td = icd.Tracks;
            if ((td != null) && (td.Count > 0))
            {
                res.RawTrackDescriptors = td.Cast<IITTrack>().
                    Select((o) => new TrackDescriptor(res, o.Name, o.TrackNumber) { DiscNumber = (uint)(o.DiscNumber) }).ToList();
            }
            else
            {
                res.RawTrackDescriptors = new List<TrackDescriptor>();
            }

            res.TracksNumber = (uint)res.RawTrackDescriptors.Count;

            return res;
        }
        public void TestMergeIDsFromCDInfos()
        {
            //arrange
            AlbumDescriptor ad = new AlbumDescriptor() { Artist = "ATeste", Name = "Name1" };

            ICDInfoHandler ih = Substitute.For<ICDInfoHandler>();
            IDiscIDs dis = Substitute.For<IDiscIDs>();
            ih.IDs.Returns(dis);

            dis.CDDB.Returns("CDDB");
            dis.MusicBrainzID.Returns("MusicBrainzID");
            dis.MusicBrainzCDId.Returns("MusicBrainzCDId");
            dis.Asin.Returns("Asin");

            //act
            ad.MergeIDsFromCDInfos(ih);

            //assert
            ad.CDDB.Should().Be("CDDB");
            ad.MusicBrainzID.Should().Be("MusicBrainzID");
            ad.MusicBrainzCDId.Should().Be("MusicBrainzCDId");
            ad.Asin.Should().Be("Asin");

        }
 internal TrackDescriptor(AlbumDescriptor ad,Track tr, string iPath): this(ad, tr)
 {
     Path = iPath;
 }
 internal TrackDescriptor(AlbumDescriptor ad)
 {
     _Father = ad;
 }
        public void TestGetEditable()
        {
            AlbumDescriptor ad = new AlbumDescriptor() 
            { Artist="ATeste",Name="Name1" };

            List<TrackDescriptor> lt = new List<TrackDescriptor>();
            lt.Add(new TrackDescriptor(){Name="T1",TrackNumber=47,Duration=TimeSpan.FromMinutes(2)});
            ad.RawTrackDescriptors = lt;

            IFullEditableAlbumDescriptor target = ad.GetEditable();


            target.Name.Should().Be("Name1");
            target.Artist.Should().Be("ATeste");
            target.EditableTrackDescriptors.Should().NotBeNull();
            target.EditableTrackDescriptors.Count.Should().Be(1);
            target.EditableTrackDescriptors[0].Name.Should().Be("T1");
            target.EditableTrackDescriptors[0].TrackNumber.Should().Be(47);
            target.EditableTrackDescriptors[0].Duration.Should().Be(TimeSpan.FromMinutes(2));
        }
 internal CollectorForCueConvertMusic(IMusicConverter imc, string Music, List<string> Image, AlbumDescriptor Cue, IImportHelper ClueName)
     : base(Image, ClueName)
 {
     _IMusicConverter = imc;
     _MusicandCue = new List<Tuple<string, AlbumDescriptor>>();
     _MusicandCue.Add(new Tuple<string, AlbumDescriptor>(Music, Cue));
 }
        public void TestInjectImages_Trivial()
        {
            AlbumDescriptor ad = new AlbumDescriptor() 
            { Artist="ATeste",Name="Name1" };

            List<TrackDescriptor> lt = new List<TrackDescriptor>();
            lt.Add(new TrackDescriptor(){Name="T1",TrackNumber=47,Duration=TimeSpan.FromMinutes(2)});
            ad.RawTrackDescriptors = lt;

            lt.ToString().Should().NotBeNull();

            AlbumDescriptor ad2 = new AlbumDescriptor();
            ad.InjectImages(ad2,false);
            ad.RawImages.Should().BeNull();


            ad.InjectImages(null, false);
            ad.RawImages.Should().BeNull();
        }
            internal CDConverter(AlbumDescriptor ICDInfo, IEnumerable<EncoderLAME> Lame, string Outdir, int CD)
            {
                _CD = CD;
                _Lames = Lame;
                _ICI = ICDInfo;

                if (Outdir == null)
                    throw new InvalidDataException();

                _Output = Path.Combine(Outdir, _ICI.Artist.FormatForDirectoryName(), _ICI.Name.FormatForDirectoryName());

                Directory.CreateDirectory(_Output);
            }
Exemplo n.º 18
0
        static internal Album GetAlbumFromExportAlbum(AlbumDescriptor TD, IImportContext Context, ITrackStatusVisitor TSV, bool ImportAllMetaData)
        {
            Album al = null;

            foreach (TrackDescriptor et in TD.RawTrackDescriptors)
            {
                TrackStatus tr = Track.GetTrackFromExportTrackDescriptor(et, false, Context, ImportAllMetaData);

                TSV.Visit(et.Path, tr);
                if ((tr != null) && (tr.Continue))
                {
                    if (al == null)
                        al = tr.Found.RawAlbum;
                    else
                        if (!object.ReferenceEquals(al, tr.Found.RawAlbum))
                            throw new Exception("Not supported");
                }
            }

            if (al == null)
                return null;

            al.ImportImageFromDescriptor(TD);
            return al;
        }
        internal TrackDescriptor Clone(AlbumDescriptor newfather)
        {
            TrackDescriptor res = new TrackDescriptor
            {
                _Father = newfather,
                Artist = Artist,
                Name = Name,
                Path = Path,
                TrackNumber = TrackNumber,
                Duration = Duration,
                MD5 = MD5,
                Rating = Rating,
                DateAdded = DateAdded,
                LastPLayed = LastPLayed,
                PlayCount = PlayCount,
                DiscNumber = DiscNumber
            };

            return res;
        }