/// <summary>
        /// Parse the CLI input to an Audio Track object
        /// </summary>
        /// <param name="output">
        /// The output.
        /// </param>
        /// <returns>
        /// An Audio Track obkect
        /// </returns>
        public static Audio Parse(StringReader output)
        {
            string audioTrack = output.ReadLine();
            Match m = Regex.Match(audioTrack, @"^    \+ ([0-9]*), ([A-Za-z0-9,\s]*) \((.*)\) \((.*)\)");
            Match track = Regex.Match(audioTrack, @"^    \+ ([0-9]*), ([A-Za-z0-9,\s]*) \((.*)\)"); // ID and Language
            Match iso639_2 = Regex.Match(audioTrack, @"iso639-2: ([a-zA-Z]*)\)");
            Match samplerate = Regex.Match(audioTrack, @"([0-9]*)Hz");
            Match bitrate = Regex.Match(audioTrack, @"([0-9]*)bps");

            string subformat = m.Groups[4].Value.Trim().Contains("iso639") ? null : m.Groups[4].Value;
            string samplerateVal = samplerate.Success ? samplerate.Groups[0].Value.Replace("Hz", string.Empty).Trim() : "0";
            string bitrateVal = bitrate.Success ? bitrate.Groups[0].Value.Replace("bps", string.Empty).Trim() : "0";

            if (track.Success)
            {
                Audio thisTrack = new Audio
                {
                    TrackNumber = int.Parse(track.Groups[1].Value.Trim()),
                    Language = track.Groups[2].Value,
                    Format = m.Groups[3].Value,
                    Description = subformat,
                    SampleRate = int.Parse(samplerateVal),
                    Bitrate = int.Parse(bitrateVal),
                    LanguageCode = iso639_2.Value.Replace("iso639-2: ", string.Empty).Replace(")", string.Empty)
                };
                return thisTrack;
            }

            return null;
        }
Esempio n. 2
0
 /// <summary>
 /// Check if a track already exists
 /// </summary>
 /// <param name="sourceTrack">
 /// The source track.
 /// </param>
 /// <returns>
 /// True if it does
 /// </returns>
 private bool TrackExists(Audio sourceTrack)
 {
     foreach (AudioTrack currentTrack in this.AudioTracks)
     {
         if (currentTrack.Track.HasValue && currentTrack.Track.Value == sourceTrack.TrackNumber)
         {
             return true;
         }
     }
     return false;
 }
Esempio n. 3
0
 /// <summary>
 /// Add the specified source track, or the first track in the SourceTracks collection if available.
 /// </summary>
 /// <param name="sourceTrack">
 /// The source track.
 /// </param>
 private void Add(Audio sourceTrack)
 {
     if (this.SourceTracks != null)
     {
         Audio track = sourceTrack ?? this.SourceTracks.FirstOrDefault();
         if (track != null)
         {
             this.Task.AudioTracks.Add(new AudioTrack { ScannedTrack = track });
         }
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AudioTrack"/> class.
 /// Copy Constructor
 /// </summary>
 /// <param name="track">
 /// The track.
 /// </param>
 public AudioTrack(AudioTrack track)
 {
     this.bitrate = track.Bitrate;
     this.drc = track.DRC;
     this.encoder = track.Encoder;
     this.gain = track.Gain;
     this.mixDown = track.MixDown;
     this.sampleRate = track.SampleRate;
     this.scannedTrack = new Audio();
     this.trackName = track.TrackName;
 }
Esempio n. 5
0
 /// <summary>
 /// Add the specified source track, or the first track in the SourceTracks collection if available.
 /// </summary>
 /// <param name="sourceTrack">
 /// The source track.
 /// </param>
 private void Add(Audio sourceTrack)
 {
     if (this.SourceTracks != null)
     {
         Audio track = sourceTrack ?? this.GetPreferredAudioTrack();
         if (track != null)
         {
             this.Task.AudioTracks.Add(new AudioTrack { ScannedTrack = track });
         }
     }
 }
Esempio n. 6
0
        /// <summary>
        /// Checks to see if we can skip over the given source audio track.
        /// True when the user has set "Add only one per language" feature AND the language is contained in the track list.
        /// </summary>
        /// <param name="sourceTrack">
        /// The source track.
        /// </param>
        /// <returns>
        /// True when the user has set "Add only one per language" feature AND the language is contained in the track list
        /// </returns>
        private bool CanSkipSourceTrack(Audio sourceTrack)
        {
            bool addOnlyOnePerLanguage = this.UserSettingService.GetUserSetting<bool>(UserSettingConstants.AddOnlyOneAudioPerLanguage);
            bool sourceTrackLanguageFound = this.Task.AudioTracks.Any(audioTrack => audioTrack.ScannedTrack != null && sourceTrack.Language == audioTrack.ScannedTrack.Language);
            if (addOnlyOnePerLanguage && sourceTrackLanguageFound)
            {
                return true; // This track can be skipped.
            }

            return false;
        }
 /// <summary>
 /// The equals.
 /// </summary>
 /// <param name="other">
 /// The other.
 /// </param>
 /// <returns>
 /// The System.Boolean.
 /// </returns>
 public bool Equals(Audio other)
 {
     if (ReferenceEquals(null, other))
     {
         return false;
     }
     if (ReferenceEquals(this, other))
     {
         return true;
     }
     return other.TrackNumber == this.TrackNumber && object.Equals(other.Language, this.Language) && object.Equals(other.LanguageCode, this.LanguageCode) && object.Equals(other.Format, this.Format);
 }