Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ie/chaturbate] Extract from API and support impersonation #11555

Merged
merged 6 commits into from
Nov 16, 2024

Conversation

powergold1
Copy link
Contributor

@powergold1 powergold1 commented Nov 15, 2024

Description of your pull request and other information

Use the ajax api to get the stream URL instead of parsing the webpage. Using the API was suggested by @oifj34f34f in #10359
The API should be faster and simpler and also fixes the occasional 403 response mentioned in #6546 The API also allows easier extraction of the room status.

I've left the existing webpage-based extraction as a fallback.

Fixes #6546
Fixes #10359

Template

Before submitting a pull request make sure you have:

In order to be accepted and merged into yt-dlp each piece of code must be in public domain or released under Unlicense. Check all of the following options that apply:

  • I am the original author of this code and I am willing to release it under Unlicense
  • I am not the original author of this code but it is in public domain or released under Unlicense (provide reliable evidence)

What is the purpose of your pull request?

Use the ajax api to get the stream URL.  This also allows easier
extraction of the room status.

I left the existing webpage-based extraction as a fallback.
@bashonly bashonly added NSFW site-bug Issue with a specific website labels Nov 15, 2024
yt_dlp/extractor/chaturbate.py Outdated Show resolved Hide resolved
yt_dlp/extractor/chaturbate.py Outdated Show resolved Hide resolved
yt_dlp/extractor/chaturbate.py Outdated Show resolved Hide resolved
yt_dlp/extractor/chaturbate.py Outdated Show resolved Hide resolved
yt_dlp/extractor/chaturbate.py Outdated Show resolved Hide resolved
yt_dlp/extractor/chaturbate.py Outdated Show resolved Hide resolved
yt_dlp/extractor/chaturbate.py Outdated Show resolved Hide resolved
yt_dlp/extractor/chaturbate.py Outdated Show resolved Hide resolved
@bashonly bashonly added the pending-fixes PR has had changes requested label Nov 15, 2024
@hidden-individual
Copy link

hidden-individual commented Nov 15, 2024

Fixes #6546

I've applied the initial version of this PR and while at first things looked good I still hit 403: Forbidden like:

$ yt-dlp https://chaturbate.com/<room>/
[Chaturbate] Extracting URL: https://chaturbate.com/<room>/
[Chaturbate] deepsouly: Downloading JSON metadata
WARNING: [Chaturbate] Unable to download JSON metadata: HTTP Error 403: Forbidden
ERROR: 'bool' object has no attribute 'get'

I'll try to provide verbose output the next time it happens. Edit, didn't take long:

$ yt-dlp https://chaturbate.com/<room>/ -vU
[debug] Command-line config: ['https://chaturbate.com/<room>/', '-vU']
[debug] Encodings: locale UTF-8, fs utf-8, pref UTF-8, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version [email protected] from yt-dlp/yt-dlp [197d0b03b] (pip)
[debug] Python 3.12.7 (CPython x86_64 64bit) - Linux-6.11.7-x86_64-with-glibc2.40 (OpenSSL 3.3.2 3 Sep 2024, glibc 2.40)
[debug] exe versions: ffmpeg 7.1 (fdk,setts), ffprobe 7.1
[debug] Optional libraries: Cryptodome-3.21.0, brotlicffi-1.1.0.0, certifi-2024.08.30, mutagen-1.47.0, requests-2.32.3, sqlite3-3.47.0, urllib3-2.2.3, websockets-13.1
[debug] Proxy map: {}
[debug] Request Handlers: urllib, requests, websockets
[debug] Loaded 1838 extractors
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest
Latest version: [email protected] from yt-dlp/yt-dlp
yt-dlp is up to date ([email protected] from yt-dlp/yt-dlp)
[Chaturbate] Extracting URL: https://chaturbate.com/<room>/
[Chaturbate] <room>: Downloading JSON metadata
WARNING: [Chaturbate] Unable to download JSON metadata: HTTP Error 403: Forbidden
ERROR: 'bool' object has no attribute 'get'
Traceback (most recent call last):
  File "/usr/lib/python3.12/site-packages/yt_dlp/YoutubeDL.py", line 1625, in wrapper
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/yt_dlp/YoutubeDL.py", line 1760, in __extract_info
    ie_result = ie.extract(url)
                ^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/yt_dlp/extractor/common.py", line 742, in extract
    ie_result = self._real_extract(url)
                ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/yt_dlp/extractor/chaturbate.py", line 164, in _real_extract
    extraction = self._extract_from_api(video_id, tld)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/yt_dlp/extractor/chaturbate.py", line 62, in _extract_from_api
    status = response.get('room_status')
             ^^^^^^^^^^^^
AttributeError: 'bool' object has no attribute 'get'

@bashonly bashonly added pending-review PR needs a review and removed pending-fixes PR has had changes requested labels Nov 15, 2024
@bashonly bashonly self-assigned this Nov 16, 2024
@seproDev seproDev removed the pending-review PR needs a review label Nov 16, 2024
@bashonly bashonly changed the title [ie/Chaturbate] Use API to get the stream URL [ie/chaturbate] Extract from API and support impersonation Nov 16, 2024
@bashonly bashonly merged commit 720b3dc into yt-dlp:master Nov 16, 2024
6 checks passed
@h0m3rth0mps0n
Copy link

Is there an ETA of when this will be released?
Just started running into this issue today. Tried updating, but nothing available:

yt-dlp -U
Latest version: [email protected] from yt-dlp/yt-dlp
yt-dlp is up to date ([email protected] from yt-dlp/yt-dlp)

@bashonly
Copy link
Member

bashonly commented Nov 16, 2024

@h0m3rth0mps0n yt-dlp --update-to master

or wait 30 minutes and run yt-dlp --update-to nightly

vladisslav2011 pushed a commit to vladisslav2011/yt-dlp that referenced this pull request Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NSFW site-bug Issue with a specific website
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Chaturbate] Consider using the API Chaturbate Extractor Returns a 403 error
5 participants