diff options
author | James Taylor <user234683@users.noreply.github.com> | 2019-12-21 11:58:02 -0800 |
---|---|---|
committer | James Taylor <user234683@users.noreply.github.com> | 2019-12-21 15:44:03 -0800 |
commit | 3936310e7e9bbd5194bc07403f775c4a50dfb16b (patch) | |
tree | 38b8f7ec9a733e411f889c121aa0ac5948ce98c3 | |
parent | 66746d0ca8f65ecb8b36ceab0389a6b503d4632b (diff) | |
download | yt-local-3936310e7e9bbd5194bc07403f775c4a50dfb16b.tar.lz yt-local-3936310e7e9bbd5194bc07403f775c4a50dfb16b.tar.xz yt-local-3936310e7e9bbd5194bc07403f775c4a50dfb16b.zip |
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"
-rw-r--r-- | youtube/yt_data_extract/common.py | 4 |
1 files changed, 2 insertions, 2 deletions
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) |