OzymandiasTheGreat / mopidy-ytmusic

Mopidy extension for playling music/managing playlists in Youtube Music
Apache License 2.0
80 stars 28 forks source link

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

Open karl0ss opened 3 years ago

karl0ss commented 3 years ago

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 commented 3 years ago

Thanks I'll take a look.

impliedchaos commented 3 years ago

So I checked and this is actually a bug with PyTube which is what we use to break the signature obfuscation. https://github.com/pytube/pytube/issues/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 commented 2 years ago

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

impliedchaos commented 2 years ago

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 commented 2 years ago

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

tahnks for your great work.

zonywhoop commented 2 years ago

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 commented 2 years ago

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

simu commented 2 years ago

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 https://github.com/pytube/pytube/issues/1199 which suggests a small change in pytube.

Manually applying the suggested change in the regex (https://github.com/pytube/pytube/issues/1199#issuecomment-1016783092) in pytube's cipher.py resolved the issue for me for now with pytube-11.0.2 and mopidy-ytmusic 0.3.3

sprnza commented 2 years ago

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

sprnza commented 2 years ago

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

sprnza commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

Take a look at this issue: https://github.com/pytube/pytube/issues/1289 it solved the problem for me

ForumPlayer commented 2 years ago

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

worked here too

shameerariff commented 2 years ago

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

Worked

markgaze commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

Here's the new fix https://github.com/pytube/pytube/issues/1326#issuecomment-1144399816

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

mgoltzsche commented 1 year ago

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 commented 1 year ago

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