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

[BUG]AttributeError: 'NoneType' object has no attribute 'download' #12

Open
LizardfrogJAX opened this issue Oct 9, 2024 · 9 comments
Open

Comments

@LizardfrogJAX
Copy link

I am indeed on the latest version of pytube, I made sure about 100 times to make sure I was updated.

I was trying to use pytube for the midi converter youtubemidify and when I tried to boot it up for the first time I had the common "Get Throttling Error" I then fixed that and now I have this issue. I have absolutely no coding knowledge and I am just trying to use this to convert piano roll to midi. Someone who knows coding please help.

To Reproduce

The video or playlist url that is causing the error: https://www.youtube.com/watch?v=nzxEfWX8QSE
The issue is occurring in the pytube cipher.py file.
Expected behavior
I expected this to work as normally and for it all to work out..

Output

C:\Users\...>python youtube_midify.py https://www.youtube.com/watch?v=nzxEfWX8QSE
Downloading video...
Traceback (most recent call last):
  File "C:\Users\...\youtube_midify.py", line 181, in <module>
    convert(__url, __output, __start, __end, __keyboardHeight, __activationThreshold)
  File "C:\Users\...\youtube_midify.py", line 122, in convert
    yt.streams.get_by_itag(22).download('videos')
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'download'

System information

I'm on Python 3.11.9
I'm on the latest version of pytube and all the requirements.
I installed all the requirements one by one manually and then downloaded the script and fixed some slight things and then tried to transcribe that video.

@41pha1
Copy link
Owner

41pha1 commented Oct 10, 2024

out.zip
Hey thanks for letting me know, there seems to be an issue with pytube since youtubes api changes. I provided a way to convert manually downloaded mp4s and tested it with the video you provided the result is attached. Lemme know if you need further help, or if any of the slight fixes you mentioned are still relevant.

@LizardfrogJAX
Copy link
Author

out.zip

Hey thanks for letting me know, there seems to be an issue with pytube since youtubes api changes. I provided a way to convert manually downloaded mp4s and tested it with the video you provided the result is attached. Lemme know if you need further help, or if any of the slight fixes you mentioned are still relevant.

Thank you so much! This will help so much!

@LizardfrogJAX
Copy link
Author

out.zip Hey thanks for letting me know, there seems to be an issue with pytube since youtubes api changes. I provided a way to convert manually downloaded mp4s and tested it with the video you provided the result is attached. Lemme know if you need further help, or if any of the slight fixes you mentioned are still relevant.

I'm still having some trouble with this, I downloaded the .mp4 and I'm trying to run the script. Do I just put the .mp4 file's name where the url went or do I need to change something in the .py file? I have no coding knowledge so sorry for the inconvenience.

@41pha1
Copy link
Owner

41pha1 commented Oct 10, 2024

No worries, yea make sure to download it again or git pull to get the changes. Then you can simply relace the url with whatever the filename of the video is. If you execute from the same folder where the video is you can simply type the name. (in case it has some space or other special charcters you might need to provide the name like this: "video_name.mp4".

@LizardfrogJAX
Copy link
Author

Thanks! I'm still having the same problem though, whenever I try to run it it does this: C:\Users\multi>python youtube_midify.py video_file.mp4
Downloading video...
Traceback (most recent call last):
File "C:\Users...\youtube_midify.py", line 181, in
convert(__url, __output, __start, __end, _keyboardHeight, activationThreshold)
File "C:\Users...\youtube_midify.py", line 121, in convert
yt = YouTube(url)
^^^^^^^^^^^^
File "C:\Users...\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\pytube_main
.py", line 71, in init
self.video_id = extract.video_id(url)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users...\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\pytube\extract.py", line 133, in video_id
return regex_search(r"(?:v=|/)([0-9A-Za-z
-]{11}).*", url, group=1)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users...\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\pytube\helpers.py", line 129, in regex_search
raise RegexMatchError(caller="regex_search", pattern=pattern)
pytube.exceptions.RegexMatchError: regex_search: could not find match for (?:v=|/)([0-9A-Za-z
-]{11}).*

I named my file video_file and then ran this: python youtube_midify.py video_file.mp4

I also made sure that the video was in the same folder as the other files.

Thanks a ton for the help!

@41pha1
Copy link
Owner

41pha1 commented Oct 10, 2024

Are you sure you have the new version of the code?
The following lines should look like:
image

According to your error message it seems like you are still using the old version before the fix :) Just download the new version from github again and it should hopefully work for you.

@LizardfrogJAX
Copy link
Author

Yes I have that version.
image

@41pha1
Copy link
Owner

41pha1 commented Oct 10, 2024

Here

File "C:\Users...\youtube_midify.py", line 121, in convert
yt = YouTube(url)
^^^^^^^^^^^^

the yt = YouTube(url) is in line 121 which suggest you might have ran the old version somehow. This code should be in line 128 in the new version.

image

Here you can see the old code with the line in 121 and the new code with the same line in 128.

@LizardfrogJAX
Copy link
Author

I figured it out, because of onedrive the script won't run if it's in my downloads folder, I have to move it to appdata. I still had the old version in appdata so i deleted that and put in the new one. Thank you for your time! appreciate the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants