xenova / chat-downloader

A simple tool used to retrieve chat messages from livestreams, videos, clips and past broadcasts. No authentication needed!
https://chat-downloader.readthedocs.io/
MIT License
902 stars 127 forks source link

Incomplete Parsing of Fundraising Donation Messages in Live Chat #227

Open repollo opened 11 months ago

repollo commented 11 months ago

Description:

Hello maintainers of chat-downloader,

Firstly, I'd like to express my appreciation for the incredible work on this library. I've been using the tool to parse live chat fundraising donation messages from YouTube and identified some issues in the extraction process.

Issue: The current parsing mechanism for the donation_announcement messages doesn't correctly extract all pertinent details, such as the donation amount and currency. This leads to the constructed output message lacking essential information about the donation.

Proposed Changes:

  1. Enhanced Handling of donation_details in _REMAPPING: Update the _REMAPPING dictionary to accurately capture donation_details:

    _REMAPPING = {
    ...
    'text': r('donation_details', _parse_runs, False),
    ...
    }
  2. Improved Parsing Logic in _parse_item: Modify the _parse_item function to better handle donation details:

    ...
    # After the remapping is done, now handle the custom logic for donations
    if 'donation_details' in info:
    donation_text = info['donation_details']['message']
    # Extract the donation amount using a split method
    match = donation_text.split('donated')
    if match:
        amount_text = match[-1].strip()
        dummy_load = {"simpleText": amount_text}
        currency_info = YouTubeChatDownloader._parse_currency(dummy_load)
        info['donation_details'] = currency_info
    ...

By implementing these changes, the parser should be able to extract all relevant details about the donation, making the output message more complete and informative.

I hope you consider integrating these adjustments into the main library. It would greatly enhance the capability and accuracy of the tool when parsing fundraising donation messages.

Thank you for your attention to this matter.

Warm regards, repollo

xenova commented 10 months ago

Thanks for this! @repollo would you like to open a PR (since you already seem to have found a fix). That would help a lot!

repollo commented 10 months ago

Do you have a specific preference of the key you would like to use? Any standardization on the matter? Right now I implemented with donation_details but that was for my use case. Let me know.