JuanBindez / pytubefix

Python3 library for downloading YouTube Videos.
https://pytubefix.readthedocs.io
MIT License
729 stars 101 forks source link

[Search] KeyError: 'onResponseReceivedCommands' #261

Closed felipeucelli closed 1 month ago

felipeucelli commented 1 month ago

:exclamation: DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE :exclamation:

lack of information will lead to closure of the issue


Describe the bug A clear and concise description of what the bug is.

PR #255 made some changes that break the search when passing a client to the contractor.

If no client is passed, it works, but this can break several features of the Search class.


code that was used that resulted in the bug

from pytubefix import Search

s = Search('music', client='MWEB')
print(s.videos)
s.get_next_results()
print(s.videos)

Expected behavior A clear and concise description of what you expected to happen.

get_next_results() performs pagination of the search results and fetches the next results.


Screenshots If applicable, add screenshots to help explain your problem.

Screenshot_20241003-084127~2


Desktop (please complete the following information):


Additional context Add any other context about the problem here.

JuanBindez commented 1 month ago

Do you have the rest of the code, because it says it is on line 15 but in the test code there is no line 15?

JuanBindez commented 1 month ago

I'll see here what it is

felipeucelli commented 1 month ago

I have some lines commented out, but I only sent the code needed for testing.

felipeucelli commented 1 month ago

I am developing a complete filter system, I will make the PR soon. When it's ready, I can submit the fix for this issue, but please leave it open in case someone else has the same issue.

JuanBindez commented 1 month ago

removing the client is working

>>> from pytubefix import Search
>>> 
>>> s = Search('music')
>>> 
>>> s.get_next_results()
>>> 
>>> for video in s.videos:
...     print(f'Title: {video.title}')
...     print(f'URL: {video.watch_url}')
...     print(f'Likes: {video.likes}')
...     print(f'Duration: {video.length} sec')
...     print('-' * 40)
... 
Title: The Weeknd – Timeless with Playboi Carti (Official Music Video)
URL: https://youtube.com/watch?v=5EpyN_6dqyk
Likes: 279662
Duration: 256 sec
----------------------------------------
Title: Top hits 2024 playlist  ~ Trending music 2024 ~ Best songs 2024 updated weekly (Playlist Hits)
URL: https://youtube.com/watch?v=U0ZoqmyGJo8
Likes: 27675
Duration: 3796 sec
----------------------------------------
Title: Ibiza Summer Mix 2024 🍓 Best Of Tropical Deep House Music Chill Out Mix 2023 🍓 Chillout Lounge
URL: https://youtube.com/watch?v=KJ-hOud6mwo
Likes: None
Duration: 12670 sec
----------------------------------------
Title: Mega Hits 2024 🌱 The Best Of Vocal Deep House Music Mix 2024 🌱 Summer Music Mix 2024 #136
URL: https://youtube.com/watch?v=BCbr55A7ECc
Likes: None
Duration: 13711 sec
----------------------------------------
Title: Ibiza Summer Mix 2024 🍓 Best Of Tropical Deep House Music Chill Out Mix 2023 🍓 Chillout Lounge
URL: https://youtube.com/watch?v=h8uGUlZoGJI
Likes: None
Duration: 0 sec
----------------------------------------
Title: Nazareth Greatest Hits Full Album - Best Songs Nazareth Playlist 2024
URL: https://youtube.com/watch?v=E31cNEyhBu8
Likes: None
Duration: 5072 sec
----------------------------------------
JuanBindez commented 1 month ago

the filter our friend made seems to be working too

>>> from pytubefix import Search
>>> 
>>> s = Search("Music", {"params": "EgIwAQ%3D%3D"})
>>> 
>>> last_nbm_results = 0
>>> while len(s.videos) != last_nbm_results:
...     for result in s.videos[last_nbm_results:]:
...         print(result.watch_url)
...     last_nbm_results = len(s.videos)
...     s.get_next_results()
... 
https://youtube.com/watch?v=qlLHaYK2yxs
https://youtube.com/watch?v=CSFXSRw4WV4
https://youtube.com/watch?v=0xrt4Rcfqv0
https://youtube.com/watch?v=CdbHAzNB1n0
https://youtube.com/watch?v=9FynEUYtJlE
https://youtube.com/watch?v=hEs-MEN3d78
https://youtube.com/watch?v=jCaug9SkKEI
https://youtube.com/watch?v=xjB0jUEA5ic
https://youtube.com/watch?v=XsfhYNH6O-8
https://youtube.com/watch?v=YybaXmRlnEA
https://youtube.com/watch?v=R0zwyX2La5w
https://youtube.com/watch?v=ZZ4A7kGKkE4
https://youtube.com/watch?v=SgWODB0W_QM
https://youtube.com/watch?v=AuzMyTHNFDw
https://youtube.com/watch?v=AFUl28YWVV4
https://youtube.com/watch?v=KGbMzi7UQig
https://youtube.com/watch?v=_BtXPQimVhg
https://youtube.com/watch?v=479UNr5N4UI
https://youtube.com/watch?v=YkNqkhbfZis
https://youtube.com/watch?v=oDMs_vCZlTo
https://youtube.com/watch?v=MMPe8Be-pM4
https://youtube.com/watch?v=UuGKqIjDWdI
https://youtube.com/watch?v=hjr4wfnVmpE
https://youtube.com/watch?v=DS2RkIhJXPY
https://youtube.com/watch?v=PvBPxatg7KA
https://youtube.com/watch?v=7OaicaR8UUQ
https://youtube.com/watch?v=vyFODiEkJXs
https://youtube.com/watch?v=_ADI33qQF4o
https://youtube.com/watch?v=EdHGrnuCEo4
https://youtube.com/watch?v=qSnGR0J2IXs
https://youtube.com/watch?v=PFHugj5zdag
https://youtube.com/watch?v=16kVQ_n3ZVw
https://youtube.com/watch?v=X4fMfs85OH4
https://youtube.com/watch?v=fFw15PLvqmg
https://youtube.com/watch?v=1sQQjEFFUA0
https://youtube.com/watch?v=1awzGG1omzY
https://youtube.com/watch?v=SeYsDvHdaeE
https://youtube.com/watch?v=PQCtUWsJPcE
https://youtube.com/watch?v=TXPySduB0BY
https://youtube.com/watch?v=RhEVE9HB28Y
JuanBindez commented 1 month ago

I understand, send it to the search branch