JuanBindez / pytubefix

Python3 library for downloading YouTube Videos.
http://pytubefix.rtfd.io/
MIT License
454 stars 67 forks source link

from pytubefix import Search This request has been detected as a bot, please try again or log in to view #174

Open abdwap opened 1 month ago

abdwap commented 1 month ago

uEeCl1KyXiI This request has been detected as a bot, please try again or log in to view

from pytubefix import Search results = Search("new") for video in results.videos: print(f'Title: {video.title}') print(f'URL: {video.watch_url}') print(f'Duration: {video.length} seg') print('---')

JanB1989 commented 1 month ago

Having the same issue even with a single request from a new ip (aws sagemaker instance).

felipeucelli commented 1 month ago

YouTube is working to prevent ad blockers and third-party apps, see #170.

abdwap commented 1 month ago

The problem can be solved by adding use_oauth=true or proxies=my_proxies

NannoSilver commented 1 month ago

I am logging the frequency my system is detected as BOT using the implementation of @felipeucelli at https://github.com/JuanBindez/pytubefix/pull/170

It is a concerning problem.

For now I am managing by using proxies. If is detected as BOT, then change IP with a different proxy and retry.

felipeucelli commented 1 month ago

Hi @NannoSilver, from my tests, most of the problems are related to cloud services, perhaps YouTube has implemented a list of IPs from well-known companies or it may also be monitoring the number of requests.

Maybe the PoToken request can get around this.

The yt-dlp is trying to solve this, but it has not yet been possible to generate the PoToken without using a browser or a VM.

benelliraul commented 4 weeks ago

I had a same problem, but only if I try the code from my pythonanywhere bash, the same code work ok from my own laptop

huihuiman commented 3 weeks ago

How to use a proxy and add fields to the certificate?

like this response = requests.get( "https://httpbin.org/get", proxies={ "http": "http://localhost:@proxy:8011/", "https": "http://localhost:@proxy:8011/", }, verify='/path/to/proxy-ca.crt )

GrandguyJS commented 3 weeks ago

If you don't find an answer soon, you could use selenium for searching.

TotalLag commented 2 weeks ago

@abdwap

The problem can be solved by adding use_oauth=true or proxies=my_proxies

Any way to access the cache? If running in serverless environment, the identity will always change so oauth is less useful. Looking for a way to save cached oauth to a shared filesystem.

shark-speare commented 1 week ago

@abdwap

The problem can be solved by adding use_oauth=true or proxies=my_proxies

what is my_proxies?

yannickErp commented 3 days ago

Proxies can be used like this:

proxy = '111.11.111.11:1234' #put proxy IP here
proxies = {
    "http": f"http://{proxy}/",
     "https": f"https://{proxy}/",
}
yt = YouTube(video_link, proxies=proxies)

I have yet to find usable proxies though so if someone finds some i would welcome a solution