aboutsummaryrefslogtreecommitdiffstats
path: root/youtube/yt_data_extract/common.py
diff options
context:
space:
mode:
authorAstound <kirito@disroot.org>2024-01-22 06:29:42 +0800
committerAstound <kirito@disroot.org>2024-01-22 06:29:42 +0800
commit5f3b90ad45993f99bf2813ef2fefaa3a59a2694f (patch)
treea3ae5002a58935d691148bbb85d6d509a9d7c58c /youtube/yt_data_extract/common.py
parent2463af768579e3bc52f39cfdd55b163d797289bc (diff)
downloadyt-local-5f3b90ad45993f99bf2813ef2fefaa3a59a2694f.tar.lz
yt-local-5f3b90ad45993f99bf2813ef2fefaa3a59a2694f.tar.xz
yt-local-5f3b90ad45993f99bf2813ef2fefaa3a59a2694f.zip
Fix channel about tab
Diffstat (limited to 'youtube/yt_data_extract/common.py')
-rw-r--r--youtube/yt_data_extract/common.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/youtube/yt_data_extract/common.py b/youtube/yt_data_extract/common.py
index e7b31b7..7903db5 100644
--- a/youtube/yt_data_extract/common.py
+++ b/youtube/yt_data_extract/common.py
@@ -185,7 +185,7 @@ def extract_int(string, default=None, whole_word=True):
return default
def extract_approx_int(string):
- '''e.g. "15.1M" from "15.1M subscribers"'''
+ '''e.g. "15.1M" from "15.1M subscribers" or '4,353' from 4353'''
if not isinstance(string, str):
string = extract_str(string)
if not string:
@@ -193,7 +193,10 @@ def extract_approx_int(string):
match = re.search(r'\b(\d+(?:\.\d+)?[KMBTkmbt]?)\b', string.replace(',', ''))
if match is None:
return None
- return match.group(1)
+ result = match.group(1)
+ if re.fullmatch(r'\d+', result):
+ result = '{:,}'.format(int(result))
+ return result
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):