aboutsummaryrefslogtreecommitdiffstats
path: root/youtube/yt_data_extract/common.py
diff options
context:
space:
mode:
authorJames Taylor <user234683@users.noreply.github.com>2019-12-20 18:48:40 -0800
committerJames Taylor <user234683@users.noreply.github.com>2019-12-20 18:48:40 -0800
commita9f67d4630319b9644af5802e7a908abcf9449be (patch)
treefd0b70063dc25a37ec56edb7011ba937ff8a8a8e /youtube/yt_data_extract/common.py
parentc3321d31d0501f23f81a711ee8532ee4e0dc6978 (diff)
downloadyt-local-a9f67d4630319b9644af5802e7a908abcf9449be.tar.lz
yt-local-a9f67d4630319b9644af5802e7a908abcf9449be.tar.xz
yt-local-a9f67d4630319b9644af5802e7a908abcf9449be.zip
Fix regression: date extraction broken. Move constants to correct file in yt_data_extract
Diffstat (limited to 'youtube/yt_data_extract/common.py')
-rw-r--r--youtube/yt_data_extract/common.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/youtube/yt_data_extract/common.py b/youtube/yt_data_extract/common.py
index 4681a86..dfeae64 100644
--- a/youtube/yt_data_extract/common.py
+++ b/youtube/yt_data_extract/common.py
@@ -152,6 +152,7 @@ def extract_approx_int(string):
return None
return match.group(1)
+MONTH_ABBREVIATIONS = {'jan':'1', 'feb':'2', 'mar':'3', 'apr':'4', 'may':'5', 'jun':'6', 'jul':'7', 'aug':'8', 'sep':'9', 'oct':'10', 'nov':'11', 'dec':'12'}
def extract_date(date_text):
'''Input: "Mar 9, 2019". Output: "2019-3-9"'''
if date_text is None:
@@ -161,7 +162,7 @@ def extract_date(date_text):
parts = date_text.split()
if len(parts) >= 3:
month, day, year = parts[-3:]
- month = month_abbreviations.get(month[0:3]) # slicing in case they start writing out the full month name
+ month = MONTH_ABBREVIATIONS.get(month[0:3]) # slicing in case they start writing out the full month name
if month and (re.fullmatch(r'\d\d?', day) is not None) and (re.fullmatch(r'\d{4}', year) is not None):
return year + '-' + month + '-' + day