question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[FEATURE] Structured Superchat amount

See original GitHub issue

Is your feature request related to a problem? Please describe.

Currently, the Superchat amount is provided as string. To aggregate its data, it should cause parsing text. If YouTube provides structured data, it should be better passing as it.

Describe the solution you’d like

"¥1,000"

{amount: 1000, currency: "JPY"}

Describe alternatives you’ve considered

Additional context

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
xenovacommented, Feb 17, 2021

Thoughts on #67 before I merge?

Superchat messages with an amount attached are now parsed, returning a money dictionary containing:

  • text: text used for display purposes
  • amount: float value of money
  • currency: ISO 4217 currency code (e.g. USD)
  • currency_symbol: currency symbol (e.g. $)

As an example use-case:

from chat_downloader import ChatDownloader


totals = {
    'member_count': 0,
    'paid_message': {},
    'paid_sticker': {}
}

try:
    url = 'https://www.youtube.com/watch?v=LgYq0xORY3w'
    chat = ChatDownloader().get_chat(url, message_groups=['superchat'])

    for message in chat:
        print(chat.format(message))
        message_type = message.get('message_type')
        if message_type == 'membership_item':
            totals['member_count'] += 1
        else:
            money = message.get('money')
            if money:
                currency = money['currency']

                if currency not in totals[message_type]:
                    totals[message_type][currency] = 0

                totals[message_type][currency] += money['amount']
finally:
    print('\nMembers gained:', totals['member_count'], end='\n\n')
    for paid_type in ('paid_message', 'paid_sticker'):
        print(paid_type)
        for currency in totals[paid_type]:
            print('  {}: {:.2f}'.format(currency, totals[paid_type][currency]))
        print()

This sums up the amounts of different currencies and prints this information out (along with number of members who joined during a stream). Example output is as follows:

Members gained: 95

paid_message
  USD: 3533.87
  GBP: 276.86
  MXN: 180.00
  AUD: 210.45
  NOK: 95.00
  INR: 440.00
  HKD: 100.00
  HUF: 3393.00
  EUR: 30.46
  CAD: 206.75
  BRL: 5.00
  DKK: 135.00
  RUB: 1000.00
  BYN: 5.00
  NZD: 0.99
  RON: 5.00
  HRK: 5.00
  PEN: 6.90
  PHP: 2500.00

paid_sticker
  INR: 19.00
  GBP: 2.00
  USD: 14.97
  CAD: 4.99
2reactions
xenovacommented, Feb 15, 2021

I actually have plans to implement exactly that! 😃 https://github.com/xenova/chat-downloader/blob/643dc3bfea6d83a536fbf08dd6d67c04a67802de/chat_downloader/sites/youtube.py#L420

I wrote it to myself as a comment, but I will implement it as soon as possible.

Read more comments on GitHub >

github_iconTop Results From Across the Web

YouTube Super Chat: The Latest YouTube Feature for Creators
Creators can use YouTube Super Chat to monetize when they go live. ... The dollar amount isn't just a random donation figure.
Read more >
SuperChatEvents | YouTube Live Streaming API
The tier is based on the amount of money spent to purchase the message. It also determines the color used to highlight the...
Read more >
YouTube Rolls Out 'Super Chat' Feature To 19 Additional ...
Super Chats cost anywhere between $1 and $500 apiece (for a maximum comment duration of five hours), though there are limits as to...
Read more >
What is YouTube Super Chat and how does it work? - Pocket-lint
Creators currently get 70 per cent of the revenue sent via Super Chat and Super Stickers, with the remaining money going to YouTube....
Read more >
Where does the money of SuperChat go, to YouTube ... - Quora
YouTube takes a 30% cut from all the transactional revenue earned from your channel including super chats, memberships, thanks button etc. Also, it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found