Skip to content

Instantly share code, notes, and snippets.

@jailuthra
Created December 26, 2023 18:38
Show Gist options
  • Save jailuthra/0ebc2cb28cf49f831c435d9a57dbc121 to your computer and use it in GitHub Desktop.
Save jailuthra/0ebc2cb28cf49f831c435d9a57dbc121 to your computer and use it in GitHub Desktop.
Youtube Superchat Donation Total
import json
from pprint import pprint
# use yt-dlp to get the json for any video using command:
# yt-dlp --sub-langs all --write-subs --skip-download <url>
with open('ip.json') as f:
m = {}
for line in f.readlines():
d = json.loads(line)
try:
key = d['clickTrackingParams']
val = d['replayChatItemAction']['actions'][0]['addChatItemAction']['item']['liveChatPaidMessageRenderer']['purchaseAmountText']['simpleText']
m[key] = val
except:
continue
sum = {'INR': 0, 'USD': 0, 'CAD': 0, 'GBP':0}
for val in m.values():
if val[0] == '₹':
sum['INR'] += float(val[1:])
elif val[:3] == "CA$":
sum['CAD'] += float(val[3:])
elif val[0] == '$':
sum['USD'] += float(val[1:])
elif val[0] == '£':
sum['GBP'] += float(val[1:])
conversion = {'INR': 1, 'USD': 83.16, 'GBP': 105.69, 'CAD': 62.95}
print(sum)
inrsum = 0
for key in sum.keys():
inrsum += sum[key] * conversion[key]
print(inrsum)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment