Add comprehensive YouTube language codes arrays for transcript downloader

This commit is contained in:
2026-04-07 12:12:20 -04:00
parent c3051c1c12
commit d07b46561a

35
language_codes.py Normal file
View File

@@ -0,0 +1,35 @@
#!/usr/bin/env python3
"""Global array of all 2-letter language codes supported by YouTube"""
# Complete list of 2-letter language codes supported by YouTube
YOUTUBE_LANGUAGE_CODES = [
"af", "sq", "am", "ar", "hy", "az", "eu", "be", "bn", "bs", "bg", "ca", "ceb", "zh", "zh-Hant",
"co", "hr", "cs", "da", "nl", "en", "eo", "et", "fi", "fr", "fy", "gl", "ka", "de", "el", "gu",
"ht", "ha", "haw", "iw", "hi", "hmn", "hu", "is", "ig", "id", "ga", "it", "ja", "jw", "kn", "kk",
"km", "rw", "ko", "ku", "ky", "lo", "la", "lv", "lt", "lb", "mk", "mg", "ms", "ml", "mt", "mi",
"mr", "mn", "my", "ne", "no", "ny", "or", "ps", "fa", "pl", "pt", "pa", "ro", "ru", "sm", "gd",
"sr", "st", "sn", "sd", "si", "sk", "sl", "so", "es", "su", "sw", "sv", "tl", "tg", "ta", "tt",
"te", "th", "tr", "tk", "uk", "ur", "ug", "uz", "vi", "cy", "fy", "xh", "yi", "yo", "zu"
]
# Alternative: More focused list of commonly used languages for fallback
COMMON_FALLBACK_LANGUAGES = [
"en", "en-US", "en-GB", # English variants
"de", "fr", "es", "it", "pt", # Major European languages
"ru", "ja", "ko", "zh", "zh-Hant", # Major Asian languages
"ar", "hi", "bn", "pa", # Major world languages
"tr", "nl", "pl", "sv", "da", "fi", "no", # Nordic/Scandinavian
"cs", "sk", "hu", "ro", "bg", "hr", "sl", "pl", "lt", "lv", "et" # Eastern European
]
ENGLISH_LANGUAGES = ['en', 'en-US', 'en-GB']
# This can be used as the list of allowed fallback languages
ALLOWED_FALLBACK_LANGUAGES = COMMON_FALLBACK_LANGUAGES
if __name__ == "__main__":
print("YouTube Language Codes:")
print(f"Total codes: {len(YOUTUBE_LANGUAGE_CODES)}")
print("First 10:", YOUTUBE_LANGUAGE_CODES[:10])
print()
print("Common fallback languages:")
print(f"Total fallback codes: {len(ALLOWED_FALLBACK_LANGUAGES)}")
print("Fallback codes:", ALLOWED_FALLBACK_LANGUAGES)