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

[YTMusicBackend-3] mopidy_ytmusic translate_uri error "'NoneType' object has no attribute 'get_signature'" #41

Open
karl0ss opened this issue Nov 22, 2021 · 22 comments
Assignees
Labels
bug Something isn't working

Comments

@karl0ss
Copy link

karl0ss commented Nov 22, 2021

Guessing the project I have been working on is now dead, as no one seems to respond here, and as of this morning I noticed that the plugin has started having issues any wont play what appears to be any premium music, when i play tracks from MyLikes, it will play stuff I have uploaded and at will play free music i liked from youtube, but will skip any music that is coming from Youtube Music premium, wont play any tracks from albums or anything like that, the error being reported it

Nov 22 16:47:56 diskPlayer mopidy[1654]: Exception in thread Thread-5:
Nov 22 16:47:56 diskPlayer mopidy[1654]: Traceback (most recent call last):
Nov 22 16:47:56 diskPlayer mopidy[1654]:   File "/usr/lib/python3.7/threading.py", line 917, in _bootstrap_inner
Nov 22 16:47:56 diskPlayer mopidy[1654]:     self.run()
Nov 22 16:47:56 diskPlayer mopidy[1654]:   File "/usr/local/lib/python3.7/dist-packages/mopidy_ytmusic/repeating_timer.py", line 18, in run
Nov 22 16:47:56 diskPlayer mopidy[1654]:     self._method()
Nov 22 16:47:56 diskPlayer mopidy[1654]:   File "/usr/local/lib/python3.7/dist-packages/mopidy_ytmusic/backend.py", line 99, in _refresh_youtube_player
Nov 22 16:47:56 diskPlayer mopidy[1654]:     self.playback.update_cipher(playerurl=url)
Nov 22 16:47:56 diskPlayer mopidy[1654]:   File "/usr/local/lib/python3.7/dist-packages/mopidy_ytmusic/playback.py", line 25, in update_cipher
Nov 22 16:47:56 diskPlayer mopidy[1654]:     self.PyTubeCipher = Cipher(js=response.text)
Nov 22 16:47:56 diskPlayer mopidy[1654]:   File "/usr/local/lib/python3.7/dist-packages/pytube/cipher.py", line 44, in __init__
Nov 22 16:47:56 diskPlayer mopidy[1654]:     self.throttling_array = get_throttling_function_array(js)
Nov 22 16:47:56 diskPlayer mopidy[1654]:   File "/usr/local/lib/python3.7/dist-packages/pytube/cipher.py", line 323, in get_throttling_function_array
Nov 22 16:47:56 diskPlayer mopidy[1654]:     str_array = throttling_array_split(array_raw)
Nov 22 16:47:56 diskPlayer mopidy[1654]:   File "/usr/local/lib/python3.7/dist-packages/pytube/parser.py", line 158, in throttling_array_split
Nov 22 16:47:56 diskPlayer mopidy[1654]:     match_start, match_end = match.span()
Nov 22 16:47:56 diskPlayer mopidy[1654]: AttributeError: 'NoneType' object has no attribute 'span'
Nov 22 16:47:56 diskPlayer mopidy[1654]: INFO     [Thread-4] mopidy_ytmusic YTMusic loaded 17 auto playlists sections
Nov 22 16:47:56 diskPlayer mopidy[1654]: INFO     [Thread-4] mopidy_ytmusic YTMusic Auto Playlists refreshed in 7.31s
Nov 22 16:48:17 diskPlayer mopidy[1654]: ERROR    [YTMusicBackend-3] mopidy_ytmusic translate_uri error "'NoneType' object has no attribute 'get_signature'"
Nov 22 16:48:17 diskPlayer mopidy[1654]: WARNING  [Core-10] mopidy.core.tracklist Track is not playable: ytmusic:track:zyP3qQK1J98

Like i say, the plugin has been working perfectly, i have run

sudo mopidyctl ytmusic reauth

And it updated my auth.json file with new details from when I set this up, rebooted and stuff, but no difference.

Really hope someone can help/fix

@impliedchaos
Copy link
Collaborator

Thanks I'll take a look.

@impliedchaos impliedchaos self-assigned this Nov 22, 2021
@impliedchaos impliedchaos added the bug Something isn't working label Nov 22, 2021
@impliedchaos
Copy link
Collaborator

So I checked and this is actually a bug with PyTube which is what we use to break the signature obfuscation. pytube/pytube#1163

They've already got pull requests submitted to fix this, so I'm just going to wait for them to make a new release, then I'll update our code to use the new version, and publish a new release as well. Probably won't take long.

@karl0ss
Copy link
Author

karl0ss commented Nov 24, 2021

@impliedchaos just to let you know, things seeeem to be working again today...

@impliedchaos
Copy link
Collaborator

Thanks, that's good to know. Google changes the javascript obfuscation function daily, and it seems like today's doesn't have the code that caused the previous breakage. So I'm still waiting on pytube to implement the fix. Hopefully soon so I can roll out the new release and keep this one from happening again.

@karl0ss
Copy link
Author

karl0ss commented Nov 24, 2021

Ok, thanks for the update, I will let you know if anything changes again here in this thread.

tahnks for your great work.

@zonywhoop
Copy link

zonywhoop commented Dec 22, 2021

FYI pytube version 11.0.2 is now out and appears to fix this issue along with an issue that was preventing me from playing any music at all. I would just receive the below error:

Dec 22 18:58:32 dabox mopidy[326566]: WARNING [Core-11] mopidy.core.tracklist Track is not playable: ytmusic:track:5LScCxHS8k8
Dec 22 18:58:32 dabox mopidy[326566]: ERROR [YTMusicBackend-3] mopidy_ytmusic translate_uri error "'NoneType' object has no attribute 'get_signature'"

I ran the following to fix upgrade:
pip3 install -U pytube

@impliedchaos
Copy link
Collaborator

Thanks! I'll update to require this latest pytube version and push out a new release.

@simu
Copy link

simu commented Jan 20, 2022

I'm getting NoneType object has no attribute 'get_signature' errors again with the current obfuscation (I personally noticed songs no longer playing starting today, 2022-01-20, approx 12:00 UTC). I found pytube/pytube#1199 which suggests a small change in pytube.

Manually applying the suggested change in the regex (pytube/pytube#1199 (comment)) in pytube's cipher.py resolved the issue for me for now with pytube-11.0.2 and mopidy-ytmusic 0.3.3

@sprnza
Copy link

sprnza commented Feb 4, 2022

I've applied the suggested change and it had been working for some time but now it's broken again

@sprnza
Copy link

sprnza commented Feb 4, 2022

I've also applied a change mentioned here. The error is gone, but playlist is not being populated

@sprnza
Copy link

sprnza commented Feb 4, 2022

This is the correct fix I suppose, but it still doesn't work with it.

Upd: it does work actually I wasn't able to add some particular playlist but another one has started working.

So basically workaround is:

sudo pip uninstall pytube
sudo pip install git+https://github.com/glubsy/pytube@nfunc_regex_patch

@fsjoao
Copy link

fsjoao commented Feb 7, 2022

This is the correct fix I suppose, but it still doesn't work with it.

Upd: it does work actually I wasn't able to add some particular playlist but another one has started working.

So basically workaround is:

sudo pip uninstall pytube
sudo pip install git+https://github.com/glubsy/pytube@nfunc_regex_patch

it works for me, tks bro!

@shameerariff
Copy link

Hi there, I am unable to install pytube@nfunc_regex_patch
WARNING: Discarding git+https://github.com/glubsy/pytube@nfunc_regex_patch. Command errored out with exit status 1: git checkout -q nfunc_regex_patch Check the logs for full command output
ERROR: Command errored out with exit status 1: git checkout -q nfunc_regex_patch Check the logs for full command output.
I even tried upgraded the pytube to the latest, still I am having the same problem.

@Nick1296
Copy link

Take a look at this issue: pytube/pytube#1289
it solved the problem for me

@ForumPlayer
Copy link

Take a look at this issue: pytube/pytube#1289 it solved the problem for me

worked here too

@shameerariff
Copy link

Take a look at this issue: pytube/pytube#1289 it solved the problem for me

Worked

@markgaze
Copy link

Doing the following fixed it for me 🙂

sudo pip uninstall pytube
sudo pip install git+https://github.com/pytube/pytube@master

(because the branch that was originally used in @sprnza's has now been merged)

@ForumPlayer
Copy link

Take a look at this issue: pytube/pytube#1289 it solved the problem for me

This worked for some time, but broke again yesterday :P

@rebernet
Copy link

rebernet commented Jun 3, 2022

Take a look at this issue: pytube/pytube#1289 it solved the problem for me

This worked for some time, but broke again yesterday :P

same here.

@OzymandiasTheGreat
Copy link
Owner

OzymandiasTheGreat commented Jun 4, 2022

Here's the new fix pytube/pytube#1326 (comment)

I really hope pytube updates with these new fixes soon, because editing sources is getting tiresome.

@mgoltzsche
Copy link

mgoltzsche commented May 10, 2023

Same problem here with pytube 12.1.3.
When I use the latest pytube version 15.0.0 directly (the CLI), the problem does not appear and I can download tracks.
However, mopidy-ytmusic still requires pytube<13 and therefore gets disabled when mopidy starts and the requirement is not met.

I wonder if this is due to my environment since other issues about other problems were created later within this repo, indicating other people don't have the pytube incompatibility problem somehow, do they?

@mgoltzsche
Copy link

So how does this work for anyone? I even patched mopidy-ytmusic to use pytube 15.0.0 but it still fails, logging the error:

ERROR    2023-09-02 18:11:39,850 [31:YTMusicBackend-11 (_actor_loop)] mopidy_ytmusic
  translate_uri error "'NoneType' object has no attribute 'get_signature'"
WARNING  2023-09-02 18:11:39,850 [31:Core-14 (_actor_loop)] mopidy.core.tracklist
  Track is not playable: ytmusic:track:Vft7l0L8PpM

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
None yet
Development

No branches or pull requests