mdhiggins / PlexAutoSkip

Automatically skip content in Plex
MIT License
198 stars 11 forks source link

Can’t get it to work on Android TV #48

Closed Deihmos closed 1 year ago

Deihmos commented 1 year ago

It works on IOS devices but on Android, I get a 404 Error. Is it not compatible? I’ll post logs as soon as possible.

mdhiggins commented 1 year ago

Works fine on iOS, make sure you have remote control enabled

image

Deihmos commented 1 year ago

It works on ios fine. My issue is it doesn't work on Android TV. I get a 404 error.

mdhiggins commented 1 year ago

Whoops I just woke up and misread that. Android doesn't have any equivalent remote setting (I don't think, but double check as there might be some variation) but it should be supported. Sometimes the Plex API on the Android player bugs out and a device restart gets it to behave.

x1ao4 commented 1 year ago

Whoops I just woke up and misread that. Android doesn't have any equivalent remote setting (I don't think, but double check as there might be some variation) but it should be supported. Sometimes the Plex API on the Android player bugs out and a device restart gets it to behave.

I also get a 404 Error on my Android TV, I tried restarting the server and the Android TV and Plex for Android, always a 404. Works fine on iOS.

Deihmos commented 1 year ago

It just doesn’t work on Android tv because there is no option to advertise as player. It works on Android tablet though. I see complaints on Plex forums so hopefully the option is added.

mdhiggins commented 1 year ago

Works fine on my nvidia shield, the option isn't there but it runs Plex companion by default. Seems to be inconsistently implemented on other android TV clients but lots of people have it working on firetv android clients as well

Deihmos commented 1 year ago

I have the Nvidia Shield Pro from 2019. Are you using the most up-to-date plex client on the shield?

mdhiggins commented 1 year ago

Just fired up my nvidia shield, working fine in my tests

2023-06-07 08:26:33 - __main__ - INFO - Seeking Plex for Android (TV) player playing 949 [11435] (Bob's Burgers s04e05 - Turkey in a Can) SHIELD Android TV|XXXXXXXXX-com-plexapp-android from 464 to 20000

I made sure I was running the latest version of plex before running this test (9.23.0.1746)

Running latest version of PAS

I can also confirm the plex player API is accessible by checking the resource XML output at http://10.0.1.95:32500/resources?token=[MYTOKEN] (my nvidia shield IP)

<MediaContainer size="1">
<Player product="Plex for Android (TV)" machineIdentifier="XXXXXXXXX-com-plexapp-android" platformVersion="11" deviceClass="stb" protocolVersion="1" title="SHIELD Android TV" platform="Android" protocolCapabilities="timeline,playback,mirror,playqueues,provider-playback"/>
</MediaContainer>

Edit: Its an Nvidia Shield Pro 2019

x1ao4 commented 1 year ago

http://tv.local.ip:32500/resources?token=xxxxxxxxxxxxxxxxxxxx <MediaContainer size="0">

http://iphone.local.ip:32500/resources?token=xxxxxxxxxxxxxxxxxxxx <MediaContainer size="2">

My TV gets 0, Any suggestions on what I should do?

mdhiggins commented 1 year ago

So I'm not sure but the fact that your TV is returning 0 (for your phone you should be able to expand that MediaContainer XML data and see the actual content, but size 2 means you have 2 sub entries in that xml tag) is the problem and why your API isn't working. Plex Companion is returning no valid data/resources and therefore won't respond to API commands.

Android TV is still listed as supported for Plex Companion so it should work, and the fact that you're getting a response on that address/port means that Plex Companion web service is at least running (otherwise you'd get no response) but you're getting no supported API functionality and its not reporting itself as a player

protocolCapabilities="timeline,playback,mirror,playqueues,provider-playback" is basically telling you what Plex Companion features are supported, PAS requires playback and to a lesser extent playqueues (for skip next stuff)

I have no idea why you and so many others apparently have broken Plex Companion features on Android TV though. I don't believe I've done anything special on my SHIELD. I also have lots of people with working Android TV setups too so its not everyone but ultimately this is a Plex issue with Plex Companion being broken or disabled somehow

You might want to "Clear Data", "Clear Cache" and then uninstall the plex app from your android device and reinstall for a clean start and see if that helps

If that fails you might need to ask the plex team, though be warned they removed plex companion from the web client when they got tired of fixing bugs in it instead :(

mdhiggins commented 1 year ago

And to answer your question about why port 32500 (from your deleted post), that's the Plex companion port on Android and iOS. Roku uses 8324 and The mac/windows clients use(d) 32700, the script pulls this data from your Plex server when its available automatically but its also documented in the Plex companion help docs and referenced inside the script in mediaWrapper.py

Deihmos commented 1 year ago

I got it working by resetting the Shield to factory settings. It didn't work when I reinstalled Plex and cleared the app data. I was getting before doing the factory reset. I 3 Nvidia Shields and an Android Smart TV. I have to reset all of them because it does not work on any.

Thanks for the help.

mdhiggins commented 1 year ago

Not sure what causes this issue but glad you found a solution, going to close this out

x1ao4 commented 1 year ago

My iPhone gets <MediaContainer size="2"> because I have Camera Roll Sharing enabled, so there is a Player and a Server.

Tried clearing the data and reinstalling Plex, Android TV still has <MediaContainer size="0">. Don't want to restore factory settings, so I'll leave it for now.

Can't access resource XML using the HTPC IP, but can via 127.0.0.1:32700 and get <MediaContainer size="0" content="plugins">, but it works fine. (The HTPC and the server are on the same Mac)

PlexAutoSkip actually detects play items and skip marks on Android TV, it just gets an error when performing the skip. Thanks for the reply, I'll try again some other time.

mdhiggins commented 1 year ago

@x1ao4 I was more or less referencing the fact that it has some content, the "0" is the problem.

The detection and skip marks is all coming from the server, everything until the moment it goes to actually make a change to the playback position only requires server based connections, but the final seek has to reach out to the client via the Plex Companion so that's not surprising at all

Its a bug on Plex's Android TV implementation unfortunately, if the API doesn't work the script has no viable way to manipulate the playback position

mdhiggins commented 1 year ago

Also the HTPC versions of plex operate differently and are proxied through the server so not surprising

I pushed a small update that does check if the client is reporting anything in the capabilities and will try to proxy through the server as an alternative if not, I'm not sure if these broken android players report anything or not but worth a shot as a workaround

b5571f8b7477010096597cbe17a9d1b2acae90cf

x1ao4 commented 1 year ago

Turns out that 127.0.0.1:32700 returns data from Plex for Mac, and 127.0.0.1:32700 will no longer accessible after closing Plex for Mac.

Also HTPC seems to be very unstable, and today HTPC could not be skipped again. As with the previous error report, it looks like HTPC is trying to connect to the server through the local IP and port 32500, the local IP with 32500 is not accessible, so it fails.

As you said HTPC is connected through proxy, I do seem to see proxying: True displayed when it was available before, and now it shows proxying: False, causing the error.

I tried your updated mediaWrapper.py and it doesn't seem to help. I just replaced the file, is that right?

Deihmos commented 1 year ago

Plex added a an option to turn on plex companion for the Android client. Now autoskips work on my Hisense google tv.

x1ao4 commented 1 year ago

Yes, Plex for Android 9.26.0.2526-beta is supported and ready to use. It does work now, thanks!