JuanBindez / pytubefix

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

Multithreading to download multiples videos from YouTube Channels #154

Closed sleepingcat4 closed 3 months ago

sleepingcat4 commented 3 months ago

I am downloading YouTube channels with has 150K videos and if I hammer the YouTube for too long, YouTube limits my download speed. I have more than 1 Gigabytes per second speed. But, it becomes painfully slow after a certain period.

is there any solution to overcome this? I was thinking if there was a way where I could use all my 200 Threads same time to download 200 videos using the Channel download function of Pytubefix, that'll be amazing.

JuanBindez commented 3 months ago

I believe in my opinion that it will be practically impossible to do this, because the YouTube infrastructure must be interpreting it as a denial of service attack, they could be blocking IPs and limiting the transfer rate, this is very difficult if you have few IPs.

sleepingcat4 commented 3 months ago

@JuanBindez What's the estimated download limit without being interpreted as DDOS for one IP?

JuanBindez commented 3 months ago

I've never tested it with YouTube but detection mechanisms, generally depending on the stream, block it quickly.

sleepingcat4 commented 3 months ago

@JuanBindez I had earlier used multithreading but 16 threads at a time to download videos. and Once 400 threads but that time I had the individual links of the videos. so I used per thread one video.

Btw is there a way to extract all the video links of a channel?

JuanBindez commented 3 months ago

@JuanBindez I had earlier used multithreading but 16 threads at a time to download videos. and Once 400 threads but that time I had the individual links of the videos. so I used per thread one video.

Btw is there a way to extract all the video links of a channel?

>>> from pytubefix import Channel
>>> 
>>> channel_url = 'https://www.youtube.com/@ProgrammingKnowledge'
>>> 
>>> channel = Channel(channel_url)
>>> 
>>> for video in channel.videos:
...     print(video.watch_url)
... 
https://youtube.com/watch?v=7nwRESnXCpM
https://youtube.com/watch?v=8gc5z3aKc6k
https://youtube.com/watch?v=mtqTnGAAHw0
https://youtube.com/watch?v=Co5DMRh9RjE
https://youtube.com/watch?v=ndc8oDSNZzQ
https://youtube.com/watch?v=igc2zsOKPJs
https://youtube.com/watch?v=6wB7Kl_hxMc
https://youtube.com/watch?v=2LglWkwo_vY
https://youtube.com/watch?v=V70gziBFxzM
https://youtube.com/watch?v=tdkjCZ03Aj4