Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import re
- from collections import defaultdict
- from youtube_comment_downloader import YoutubeCommentDownloader
- downloader = YoutubeCommentDownloader()
- video_url = "https://www.youtube.com/watch?v=IKLKEGMfdRo"
- super_thanks_count = 0
- total_by_currency = defaultdict(float)
- currency_amount_pattern = re.compile(r"([^\d\s]+)\s?([\d,]+(?:\.\d{1,2})?)")
- print("🔍 Fetching all comments...\n")
- for count, comment in enumerate(downloader.get_comments_from_url(video_url, sort_by=1), start=1):
- if 'paid' in comment:
- super_thanks_count += 1
- author = comment.get('author', 'Unknown')
- text = comment.get('text', '')
- paid = comment['paid']
- match = currency_amount_pattern.search(paid)
- if match:
- currency = match.group(1)
- amount = float(match.group(2).replace(',', ''))
- total_by_currency[currency] += amount
- else:
- currency = "Unknown"
- amount = paid
- print(f"{count:04d}. 💸 Super Thanks from @{author}")
- print(f" Text: {text}")
- print(f" Currency: {currency}")
- print(f" Amount: {amount}\n")
- print("\n✅ Done.")
- print(f"💰 Total Super Thanks found: {super_thanks_count}")
- print("📊 Total Donation Breakdown by Currency:")
- for currency, total in total_by_currency.items():
- print(f" {currency} {total:,.2f}")
Advertisement
Add Comment
Please, Sign In to add comment