aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/utils.py
diff options
context:
space:
mode:
authorSergey M․ <dstftw@gmail.com>2016-09-14 23:13:55 +0700
committerSergey M․ <dstftw@gmail.com>2016-09-14 23:59:38 +0700
commitf6717dec8abe7c0d34e704732b53665a9415fa2e (patch)
treef0fdffc8864a9ebc9304a545ed66a8f7ca2ca4fd /youtube_dl/utils.py
parenta942d6cb48994c5ff14ccef8773fb086a5544970 (diff)
downloadyoutube-dl-f6717dec8abe7c0d34e704732b53665a9415fa2e.tar.xz
[utils] Improve month_by_name and add tests
Diffstat (limited to 'youtube_dl/utils.py')
-rw-r--r--youtube_dl/utils.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py
index 623ced625..a4ef15908 100644
--- a/youtube_dl/utils.py
+++ b/youtube_dl/utils.py
@@ -91,9 +91,12 @@ ENGLISH_MONTH_NAMES = [
'January', 'February', 'March', 'April', 'May', 'June',
'July', 'August', 'September', 'October', 'November', 'December']
-FRENCH_MONTH_NAMES = [
- 'janvier', 'fevrier', 'mars', 'avril', 'mai', 'juin',
- 'juillet', 'aout', 'septembre', 'octobre', 'novembre', 'decembre']
+MONTH_NAMES = {
+ 'en': ENGLISH_MONTH_NAMES,
+ 'fr': [
+ 'janvier', 'fevrier', 'mars', 'avril', 'mai', 'juin',
+ 'juillet', 'aout', 'septembre', 'octobre', 'novembre', 'decembre'],
+}
KNOWN_EXTENSIONS = (
'mp4', 'm4a', 'm4p', 'm4b', 'm4r', 'm4v', 'aac',
@@ -1594,13 +1597,10 @@ def parse_count(s):
def month_by_name(name, lang='en'):
""" Return the number of a month by (locale-independently) English name """
- name_list = ENGLISH_MONTH_NAMES
-
- if lang == 'fr':
- name_list = FRENCH_MONTH_NAMES
+ month_names = MONTH_NAMES.get(lang, MONTH_NAMES['en'])
try:
- return name_list.index(name) + 1
+ return month_names.index(name) + 1
except ValueError:
return None