Move COMMON_ENGLISH_WORDS set from youtube_transcript_downloader.py to language_codes.py as a shared constant. This improves code organization and reusability, allowing other modules to reference the same word list for English language detection
48 lines
2.7 KiB
Python
48 lines
2.7 KiB
Python
#!/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
|
|
COMMON_ENGLISH_WORDS = {
|
|
'the', 'be', 'to', 'of', 'and', 'a', 'in', 'that', 'have', 'i',
|
|
'it', 'for', 'not', 'on', 'with', 'he', 'as', 'you', 'do', 'at',
|
|
'this', 'but', 'his', 'by', 'from', 'they', 'we', 'say', 'her',
|
|
'she', 'or', 'an', 'will', 'my', 'one', 'all', 'would', 'there',
|
|
'their', 'what', 'so', 'up', 'out', 'if', 'about', 'who', 'get',
|
|
'which', 'go', 'me', 'when', 'make', 'can', 'like', 'time', 'no',
|
|
'just', 'him', 'know', 'take', 'people', 'into', 'year', 'your',
|
|
'good', 'some', 'could', 'them', 'see', 'other', 'than', 'then',
|
|
'now', 'look', 'only', 'come', 'its', 'over', 'think', 'also',
|
|
'back', 'after', 'use', 'two', 'how', 'our', 'work', 'first', 'well',
|
|
'way', 'even', 'new', 'want', 'because', 'any', 'these', 'give', 'day'
|
|
}
|
|
|
|
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) |