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

Bot detection error #431

Open
kaifcodec opened this issue Jan 25, 2025 · 1 comment
Open

Bot detection error #431

kaifcodec opened this issue Jan 25, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@kaifcodec
Copy link

# 🛑 DO NOT REMOVE OR SKIP THIS ISSUE TEMPLATE 🛑
Issues with incomplete or missing information will be closed automatically.


🐞 Bug Description

Provide a clear and concise description of the bug.
Traceback (most recent call last):
File "/data/data/com.termux/files/usr/lib/python3.12/site-packages/pytubefix/main.py", line 758, in title
if 'title' in self.vid_info['videoDetails']:
~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
KeyError: 'videoDetails'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/data/data/com.termux/files/home/yt.py", line 7, in
print(yt.title)
^^^^^^^^
File "/data/data/com.termux/files/usr/lib/python3.12/site-packages/pytubefix/main.py", line 794, in title
self.check_availability()
File "/data/data/com.termux/files/usr/lib/python3.12/site-packages/pytubefix/main.py", line 396, in check_availability
raise exceptions.BotDetection(video_id=self.video_id)
pytubefix.exceptions.BotDetection: _g1_mG6Ru3M This request was detected as a bot. Use use_po_token=True or switch to WEB client to view. See more details at #209

🔢 Code Snippet

Include the minimal code snippet that reproduces the issue.

from pytubefix import YouTube
from pytubefix.cli import on_progress

url = "url"

yt = YouTube(url, on_progress_callback=on_progress)
print(yt.title)

ys = yt.streams.get_audio_only()
ys.download()

🎯 Expected Behavior

Describe what you expected to happen instead of the observed behavior.
I expected to download the audio correctly

📸 Screenshots or Logs


🖥️ Environment Details

Fill in the details below about your setup:

  • Operating System: [e.g., Windows 10, macOS Monterey]
  • Python Version: [e.g., 3.9.7]
  • Pytubefix Version: [e.g., 1.2.3]

📋 Additional Context

Add any additional information or context that might help us resolve the issue.


🚀 Next Steps

Once submitted, we will triage the issue. Make sure to respond to follow-up questions to keep the process smooth.

@kaifcodec kaifcodec added the bug Something isn't working label Jan 25, 2025
@GVCoder09
Copy link

GVCoder09 commented Jan 28, 2025

As a temporary solution, disable this check in the check_availability function (pytubefix/__main__.py class YouTube)

...
            elif status == 'LOGIN_REQUIRED':
                if reason == (
                        'Sign in to confirm your age'
                ):
                    raise exceptions.AgeRestrictedError(video_id=self.video_id)
                elif reason == (
                        'Sign in to confirm you’re not a bot'
                ):
                    return
                    raise exceptions.BotDetection(video_id=self.video_id)
                else:
                    raise exceptions.LoginRequired(
                        video_id=self.video_id, reason=reason)

Despite ignoring the error, the download continues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: waiting
Development

No branches or pull requests

2 participants