Beispiel #1
0
        public CTDBResponseMeta ParsedInput(string format, string data)
        {
            var lines = data.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
            // var artist = Regex.Match(lines[0], @"Artist: (.*)$", RegexOptions.IgnoreCase).Groups[1].Value;
            // var album = Regex.Match(lines[1], @"Album: (.*)$", RegexOptions.IgnoreCase).Groups[1].Value;
            var reg    = Regex.Replace(format, @"%(.*?)%", @"(?<$1>.*?)") + "$";
            var traks  = lines.ToList();
            var tracks = new CTDBResponseMetaTrack[traks.Count()];

            for (int i = 0; i < traks.Count(); i++)
            {
                var matches = Regex.Match(traks[i], reg).Groups;

                tracks[i] = new CTDBResponseMetaTrack()
                {
                };
                if (!String.IsNullOrEmpty(matches["title"].Value))
                {
                    tracks[i].name = matches["title"].Value;
                }
                if (!String.IsNullOrEmpty(matches["artist"].Value))
                {
                    tracks[i].artist = matches["artist"].Value;
                }
            }
            return(new CTDBResponseMeta()
            {
                track = tracks
            });
        }
Beispiel #2
0
 public CTDBResponseMetaTrack(CTDBResponseMetaTrack src)
 {
     this.name   = src.name;
     this.artist = src.artist;
     this.extra  = src.extra;
 }