예제 #1
0
        private string GetCodecName(KnownCodec codec)
        {
            string name        = string.Empty;
            var    cultureInfo = LanguageCodeHelper.LangCodeToCultureInfo(codec.TrackEntry.Language);

            if (cultureInfo != null)
            {
                //langCode = cultureInfo.TwoLetterISOLanguageName;
                if (string.IsNullOrEmpty(codec.TrackEntry.Name))
                {
                    name = string.Format("{0}", cultureInfo.NativeName);
                }
                else
                {
                    name = string.Format("{0} - {1}", cultureInfo.NativeName, codec.TrackEntry.Name);
                }
            }
            else
            {
                //langCode = codec.TrackEntry.Language;
                if (string.IsNullOrEmpty(codec.TrackEntry.Name))
                {
                    name = string.Format("{0}", LanguageCodeHelper.UNKOWN_LANGUAGE);
                }
                else
                {
                    name = string.Format("{0} - {1}", LanguageCodeHelper.UNKOWN_LANGUAGE, codec.TrackEntry.Name);
                }
            }
            return(name);
        }
예제 #2
0
        private string GetSubtitleName(SubtitleInfomation subtitleInfomation)
        {
            string nativeName = string.Empty;
            string engName    = string.Empty;

            if (!string.IsNullOrEmpty(subtitleInfomation.language))
            {
                System.Globalization.CultureInfo cultureInfo = null;

                try
                {
                    if (subtitleInfomation.language.Length == 2 || (subtitleInfomation.language.Length == 5 && subtitleInfomation.language.ElementAt(2) == '-'))
                    {
                        cultureInfo = new System.Globalization.CultureInfo(subtitleInfomation.language);
                    }
                    else if (subtitleInfomation.language.Length == 3)
                    {
                        cultureInfo = LanguageCodeHelper.LangCodeToCultureInfo(subtitleInfomation.language);
                    }

                    if (cultureInfo != null)
                    {
                        nativeName = cultureInfo.NativeName;
                        engName    = cultureInfo.EnglishName;
                    }
                }
                catch (Exception) { }
            }

            if (!string.IsNullOrEmpty(subtitleInfomation.title))
            {
                if (string.IsNullOrEmpty(nativeName))
                {
                    nativeName = subtitleInfomation.title;
                }
                else
                {
                    string[] titles = subtitleInfomation.title.Split(new char[] { ':' });

                    if (titles.Length >= 1)
                    {
                        nativeName += " : ";
                        if (titles[0] != engName && titles[0] != nativeName)
                        {
                            nativeName += subtitleInfomation.title;
                        }
                        else if (titles.Length >= 2 && !string.IsNullOrEmpty(titles[1]))
                        {
                            nativeName += titles[1];
                        }
                    }
                }
            }

            if (string.IsNullOrEmpty(nativeName))
            {
                nativeName = LanguageCodeHelper.UNKOWN_LANGUAGE;
            }

            return(nativeName);
        }