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

[BUG] socs.value missing from cookies #238

Open CanOfSocks opened 7 months ago

CanOfSocks commented 7 months ago

Basic information

Describe the bug

A clear and concise description of what the bug is.

Command/Code used

If running from the command line, provide the following:

  1. The command used (including the verbose tag, -v):
    chat_downloader -v -o /app/temp/temp.json --cookies "/app/cookies.txt" https://youtu.be/m78eqo-ApIk
  2. Output from the above command:
    [DEBUG] Python version: 3.12.0 (main, Nov 21 2023, 17:49:02) [GCC 12.2.0]
    [DEBUG] Program version: 0.2.8
    [DEBUG] Initialisation parameters: {'headers': None, 'cookies': '/app/cookies.txt', 'proxy': None}
    [DEBUG] Created YouTubeChatDownloader session.
    Traceback (most recent call last):
    File "/usr/local/bin/chat_downloader", line 8, in <module>
    sys.exit(main())
             ^^^^^^
    File "/usr/local/lib/python3.12/site-packages/chat_downloader/cli.py", line 194, in main
    run(**args.__dict__)
    File "/usr/local/lib/python3.12/site-packages/chat_downloader/chat_downloader.py", line 351, in run
    chat = downloader.get_chat(**chat_params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/local/lib/python3.12/site-packages/chat_downloader/chat_downloader.py", line 208, in get_chat
    self.create_session(site)
    File "/usr/local/lib/python3.12/site-packages/chat_downloader/chat_downloader.py", line 304, in create_session
    self.sessions[session_name] = chat_downloader_class(
                                  ^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/local/lib/python3.12/site-packages/chat_downloader/sites/youtube.py", line 62, in __init__
    self._initialize_consent()
    File "/usr/local/lib/python3.12/site-packages/chat_downloader/sites/youtube.py", line 1369, in _initialize_consent
    if socs and not socs.value.startswith('CAA'):  # not consented
                    ^^^^^^^^^^
    AttributeError: 'str' object has no attribute 'value'

Expected behavior

Adding cookies file does not seem to work with consent, with the string not seemingly working at all. SOCS cookies does appear to be within the cookies file being accessed.

Additional context/information

Cookies file (values replaces with random, but SOCS is there in the cookies). The export from the cookies.txt extension was edited by yt-dlp to produce the file below.

# Netscape HTTP Cookie File
# This file is generated by yt-dlp.  Do not edit.

.youtube.com    TRUE    /       FALSE   0       PREF    hl=en&tz=UTC
.youtube.com    TRUE    /       TRUE    0       SOCS    CAI
.youtube.com    TRUE    /       TRUE    0       YSC     ft54gh6ry7
.youtube.com    TRUE    /       TRUE    34578534645      VISITOR_INFO1_LIVE      dhgjhgjghjdgj
.youtube.com    TRUE    /       TRUE    654645654546      VISITOR_PRIVACY_METADATA        fgjhgfhjdgfhjdfg
.youtube.com    TRUE    /       TRUE    546546456      CONSENT PENDING+011
.youtube.com    TRUE    /       TRUE    546456456456      GPS     1