Guest User

Untitled

a guest
Mar 29th, 2025
176
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.38 KB | None | 0 0
  1. import re
  2. from collections import defaultdict
  3. from youtube_comment_downloader import YoutubeCommentDownloader
  4.  
  5. downloader = YoutubeCommentDownloader()
  6. video_url = "https://www.youtube.com/watch?v=IKLKEGMfdRo"
  7.  
  8. super_thanks_count = 0
  9. total_by_currency = defaultdict(float)
  10.  
  11. currency_amount_pattern = re.compile(r"([^\d\s]+)\s?([\d,]+(?:\.\d{1,2})?)")
  12.  
  13. print("🔍 Fetching all comments...\n")
  14.  
  15. for count, comment in enumerate(downloader.get_comments_from_url(video_url, sort_by=1), start=1):
  16.     if 'paid' in comment:
  17.         super_thanks_count += 1
  18.         author = comment.get('author', 'Unknown')
  19.         text = comment.get('text', '')
  20.         paid = comment['paid']
  21.  
  22.         match = currency_amount_pattern.search(paid)
  23.         if match:
  24.             currency = match.group(1)
  25.             amount = float(match.group(2).replace(',', ''))
  26.             total_by_currency[currency] += amount
  27.         else:
  28.             currency = "Unknown"
  29.             amount = paid
  30.  
  31.         print(f"{count:04d}. 💸 Super Thanks from @{author}")
  32.         print(f"     Text: {text}")
  33.         print(f"     Currency: {currency}")
  34.         print(f"     Amount: {amount}\n")
  35.  
  36. print("\n✅ Done.")
  37. print(f"💰 Total Super Thanks found: {super_thanks_count}")
  38. print("📊 Total Donation Breakdown by Currency:")
  39.  
  40. for currency, total in total_by_currency.items():
  41.     print(f"   {currency} {total:,.2f}")
  42.  
Advertisement
Add Comment
Please, Sign In to add comment