/// <summary> /// The get language codes. /// </summary> /// <param name="userLanguages"> /// The user languages. /// </param> /// <returns> /// The <see cref="IList"/>. /// </returns> public static List <string> GetLanguageCodes(StringCollection userLanguages) { // Translate to Iso Codes List <string> iso6392Codes = new List <string>(); foreach (var item in userLanguages) { string isoCode; if (LanguageUtilities.MapLanguages().TryGetValue(item, out isoCode)) { iso6392Codes.Add(isoCode); } } return(iso6392Codes); }
/// <summary> /// Generate the Command Line Arguments for the Subtitles Tab /// </summary> /// <param name="task"> /// The encode task. /// </param> /// <returns> /// A Cli Query as a string /// </returns> private static string SubtitlesQuery(EncodeTask task) { string query = string.Empty; if (task.SubtitleTracks.Count != 0) { // BitMap and CC's string subtitleTracks = String.Empty; string subtitleForced = String.Empty; string subtitleBurn = String.Empty; string subtitleDefault = String.Empty; // SRT string srtFile = String.Empty; string srtCodeset = String.Empty; string srtOffset = String.Empty; string srtLang = String.Empty; string srtDefault = String.Empty; int srtCount = 0; int subCount = 0; // Languages IDictionary <string, string> langMap = LanguageUtilities.MapLanguages(); foreach (SubtitleTrack item in task.SubtitleTracks) { string itemToAdd; if (item.IsSrtSubtitle) // We have an SRT file { srtCount++; // SRT track id. srtLang += srtLang == string.Empty ? langMap[item.SrtLang] : "," + langMap[item.SrtLang]; srtCodeset += srtCodeset == string.Empty ? item.SrtCharCode : "," + item.SrtCharCode; if (item.Default) { srtDefault = srtCount.ToString(); } itemToAdd = item.SrtPath; srtFile += srtFile == string.Empty ? itemToAdd : "," + itemToAdd; itemToAdd = item.SrtOffset.ToString(); srtOffset += srtOffset == string.Empty ? itemToAdd : "," + itemToAdd; } else // We have Bitmap or CC { subCount++; // Find --subtitle <string> if (item.SourceTrack.SubtitleType == SubtitleType.ForeignAudioSearch) { itemToAdd = "scan"; } else { string[] tempSub = item.Track.Split(' '); itemToAdd = tempSub[0]; } subtitleTracks += subtitleTracks == string.Empty ? itemToAdd : "," + itemToAdd; // Find --subtitle-forced if (item.Forced) { subtitleForced += subtitleForced == string.Empty ? subCount.ToString() : "," + subCount; } // Find --subtitle-burn if (item.Burned) { subtitleBurn = subCount.ToString(); } // Find --subtitle-default if (item.Default) { subtitleDefault = subCount.ToString(); } } } // Build The CLI Subtitles Query if (subtitleTracks != string.Empty) { query += " --subtitle " + subtitleTracks; if (subtitleForced != string.Empty) { query += " --subtitle-forced=" + subtitleForced; } if (subtitleBurn != string.Empty) { query += " --subtitle-burned=" + subtitleBurn; } if (subtitleDefault != string.Empty) { query += " --subtitle-default=" + subtitleDefault; } } if (srtFile != string.Empty) // SRTs { query += " --srt-file " + "\"" + srtFile + "\""; if (srtCodeset != string.Empty) { query += " --srt-codeset " + srtCodeset; } if (srtOffset != string.Empty) { query += " --srt-offset " + srtOffset; } if (srtLang != string.Empty) { query += " --srt-lang " + srtLang; } if (srtDefault != string.Empty) { query += " --srt-default=" + srtDefault; } } } return(query); }