Created
December 26, 2023 18:38
-
-
Save jailuthra/0ebc2cb28cf49f831c435d9a57dbc121 to your computer and use it in GitHub Desktop.
Youtube Superchat Donation Total
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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