aboutsummaryrefslogtreecommitdiffstats
path: root/youtube/__init__.py
diff options
context:
space:
mode:
authorAstound <kirito@disroot.org>2024-01-22 05:59:11 +0800
committerAstound <kirito@disroot.org>2024-01-22 05:59:11 +0800
commit51a16937891ebb6d419ad21d0189182cb1197430 (patch)
tree59a87f94f9b22f7785db7d54c697abc83a99e1ac /youtube/__init__.py
parentca4a7356924450f21228e823b4bcc1416aea05d3 (diff)
downloadyt-local-51a16937891ebb6d419ad21d0189182cb1197430.tar.lz
yt-local-51a16937891ebb6d419ad21d0189182cb1197430.tar.xz
yt-local-51a16937891ebb6d419ad21d0189182cb1197430.zip
Fix comment count extraction due to 'K/M' postfixes
YouTube now displays 2K comments instead of 2359, for instance
Diffstat (limited to 'youtube/__init__.py')
-rw-r--r--youtube/__init__.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/youtube/__init__.py b/youtube/__init__.py
index b0e8761..64aed56 100644
--- a/youtube/__init__.py
+++ b/youtube/__init__.py
@@ -54,7 +54,10 @@ def commatize(num):
if num is None:
return ''
if isinstance(num, str):
- num = int(num)
+ try:
+ num = int(num)
+ except ValueError:
+ return num
return '{:,}'.format(num)