From 3936310e7e9bbd5194bc07403f775c4a50dfb16b Mon Sep 17 00:00:00 2001 From: James Taylor Date: Sat, 21 Dec 2019 11:58:02 -0800 Subject: Fix extract_approx_int. Fixes incorrect subscriber count on channels. It wasn't working because decimals such as 15.1M weren't considered, so it was extracting "1M" --- youtube/yt_data_extract/common.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'youtube') diff --git a/youtube/yt_data_extract/common.py b/youtube/yt_data_extract/common.py index dfeae64..221b523 100644 --- a/youtube/yt_data_extract/common.py +++ b/youtube/yt_data_extract/common.py @@ -142,12 +142,12 @@ def extract_int(string, default=None): return default def extract_approx_int(string): - '''e.g. "15M" from "15M subscribers"''' + '''e.g. "15.1M" from "15.1M subscribers"''' if not isinstance(string, str): string = extract_str(string) if not string: return None - match = re.search(r'(\d+[KMBTkmbt])', string.replace(',', '')) + match = re.search(r'(\d+(?:\.\d+)?[KMBTkmbt])', string.replace(',', '')) if match is None: return None return match.group(1) -- cgit v1.2.3