mdhiggins / PlexAutoSkip

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

Next doesn’t work #36

Closed tchirou closed 1 year ago

tchirou commented 1 year ago

Hi Plex media server and Plexautoskip are in docker containers on a Synology nas It skips intro and credits as intended However, if « next = True » in config, it works only in the first episode I am watching, then it doesn’t work anymore unless I stop the episode I tried « next = false » and it works on all episodes I tried with plex for iPhone, plex for android tv and plex for fire tv clients The log doesn’t give any error, just nothing after the autonext, unless I stop the episode and manually start it again Is it working as intended on your end ? Thanks a lot

mdhiggins commented 1 year ago

Working fine on my testing just now

INFO - Found new session 407 [1996] (Brooklyn Nine-Nine s02e02 - Chocolate Milk) *** viewOffset 1256000 mhiggins, sessions: 0
INFO - Found ended 407 [1996] (Brooklyn Nine-Nine s02e02 - Chocolate Milk) *** session that has reached the end of its duration 1299350 with viewOffset 1299000 with skip-next enabled, will skip to next
INFO - Found new session 408 [1997] (Brooklyn Nine-Nine s02e03 - The Jimmy Jab Games) *** viewOffset 0 mhiggins, sessions: 0
INFO - Found ended 408 [1997] (Brooklyn Nine-Nine s02e03 - The Jimmy Jab Games) *** session that has reached the end of its duration 1300092 with viewOffset 1300000 with skip-next enabled, will skip to next
INFO - Found new session 409 [1998] (Brooklyn Nine-Nine s02e04 - Halloween II) *** viewOffset 1000 mhiggins, sessions: 0

Post some logs, preferably debug logs

mdhiggins commented 1 year ago

I did find a small bug with certain players not reporting the final viewOffset correctly (they would report an offset slightly less than the duration). I had some tolerance adjusters to account for this and there is some rounding as well but I wasn't applying this tolerance in 1 place that might have resulted in some media never reporting as "ended" if the rounding wasn't enough to capture things when the player reports the wrong ending viewOffset, thus never triggering the final skip

Not sure if this is your issue, it wouldn't have anything to do with the first item working unless that was just a coincidence but I pushed an update that fixes this

tchirou commented 1 year ago

Config.ini and debug log First I tried with iPhone and it finally works Then I tried with the fire stick and it keeps not working after the first episode. I disabled the autoframerate switching in the plex client settings, just in case it was that but same result. Thanks a lot config.txt pas.txt

EDIT : just tried with plex for windows and it works too. I will try tonight with a true plex for android TV on the shield.

mdhiggins commented 1 year ago

What exactly isn't working on the Fire Stick? Its hard to tell from the logs cause it looks like its doing what it should but if you could be specific that would be helpful. Like, it gets to the end of the episode and loops back to the same episode is very different than it gets to the end and the "Up Next" screen appears but it doesn't skip etc

If you could describe the behavior or correlate what was happening with the log sample you sent me that would be helpful

Also, one thing that might help with the fire stick would be to increase the command delay

[Offsets]
command = 500

500 is the default but you might need a little more, try 1000

tchirou commented 1 year ago

I start an episode, intro is skipped, then credits are skipped, up next screen is bypassed, the next episode starts, intro is not skipped, credits are not skipped, up next screen isn’t bypassed and so on until I stop

It’s like Plexautoskip goes into a deep sleep once it creates the playqueue (last line of the log). It doesn’t find any new session.

Le lun. 20 févr. 2023 à 12:44, Michael Higgins @.***> a écrit :

What exactly isn't working on the Fire Stick? Its hard to tell from the logs cause it looks like its doing what it should but if you could be specific that would be helpful. Like, it gets to the end of the episode and loops back to the same episode is very different than it gets to the end and the "Up Next" screen appears but it doesn't skip etc

If you could describe the behavior or correlate what was happening with the log sample you sent me that would be helpful

Also, one thing that might help with the fire stick would be to increase the command delay

[Offsets] command = 500

500 is the default but you might need a little more, try 1000

— Reply to this email directly, view it on GitHub https://github.com/mdhiggins/PlexAutoSkip/issues/36#issuecomment-1436833022, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTPZ3DHZIPB2A6WFBG4G6LWYNKIZANCNFSM6AAAAAAVBGZ4P4 . You are receiving this because you authored the thread.Message ID: @.***>

mdhiggins commented 1 year ago

Huh that's bizarre. The script is still running right? A weird crash the logs fail to capture might look like that but probably not. If you look at your Plex activity screen on the Plex web UI does it show the new episode as playing or is it a ghost stream

tchirou commented 1 year ago

It plays the next video, just no more skipping. Plexautoskip container is still running. Nothing happens until I stop and start again. Once I start again the same episode (or another one, it doesn’t matter), skipping works again.

Its not new : I had noticed this problem a long Time ago on android tv when the kid was biging anime on Saturday mornings but never got around to publish an issue

Le lun. 20 févr. 2023 à 12:57, Michael Higgins @.***> a écrit :

Huh that's bizarre. The script is still running right? A weird crash the logs fail to capture might look like that but probably not. If you look at your Plex activity screen on the Plex web UI does it show the new episode as playing or is it a ghost stream

— Reply to this email directly, view it on GitHub https://github.com/mdhiggins/PlexAutoSkip/issues/36#issuecomment-1436859325, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTPZ3DWBIKK7PG2DESCIC3WYNL2HANCNFSM6AAAAAAVBGZ4P4 . You are receiving this because you authored the thread.Message ID: @.***>

mdhiggins commented 1 year ago

When you check the activity page can you also see if the user playing the stream changes when it stops working?

Does turning off skip next fix this issue?

tchirou commented 1 year ago

What activity page exactly ? Plex dashboard ?

Yes, like I wrote in the first post, if next = False, there is no issue (at least yesterday before the last update, I haven’t tried it again since).

mdhiggins commented 1 year ago

Yes Plex dashboard

mdhiggins commented 1 year ago

Two things come to mind that could potentially give you this behavior

One, is that for some reason the sessionKey is being reused (it should create a new one for each playback so this shouldn't be the case) and thus the old episode which gets marked as ignored after the skipNext fires and ends up blocking the new one. I haven't ever seen this happen but the script does ignore these silently so there wouldn't be anything in the logs.

If you wanted, you could add a small debug log line to investigate this

Add this line below to skipper.py at the following location self.log.debug("Ignoring session %s" % (pasIdentifier))

    def processAlert(self, data: dict) -> None:
        if data['type'] == 'playing':
            sessionKey = int(data['PlaySessionStateNotification'][0]['sessionKey'])
            clientIdentifier = data['PlaySessionStateNotification'][0]['clientIdentifier']
            pasIdentifier = MediaWrapper.getSessionClientIdentifier(sessionKey, clientIdentifier)

            if pasIdentifier in self.ignored:
                self.log.debug("Ignoring session %s" % (pasIdentifier))
                return

The other potential option is that for some reason when it makes the new PlayQueue and starts the episode that for some reason its not getting flagged as a LAN session. That you can tell from the Plex Dashboard as well, check and make sure it indicates its "Local"

tchirou commented 1 year ago

Yes, it says local

Weirdly enough, contrary to the Plex for iPhone, when the next file is auto played on plex for fire TV, it takes around 10 seconds for the dashboard to display the new activity. No matter what, if next is false, skipping still work so I don't know if it's related

I tried with plex for iPad and it doesn't work, I have a bunch of errors (log attached)

About modifying the py file :I use docker, I don't know how to make such modifications unfortunately

pas.log

mdhiggins commented 1 year ago

Looking at the logs it just looks like your iOS API just isn't working, I've had that happen on occasion and usually just force quitting the Plex app and reopening it will fix things

You could always bash into the container and make the edits but to make it easier on you, I updated the container just now and added a new environment variable PAS_VERBOSE

Set that to true and rebuild your container with the latest image pull and that should take care of enabling the extra logging

tchirou commented 1 year ago

Sorry, I am a noob Log is enclosed pas 2.log

tchirou commented 1 year ago

I rebooted the iPad, force quit plex but it still doesn't work Log attached pas 3.log Thanks a lot for your help!

mdhiggins commented 1 year ago

For log 2, looks like its failing to report a session and so that log line is throwing an exception, just pushed another small update to handle this

Rebuilding the container but you can set PAS_UPDATE environment variable to true which will update from github after each container restart without needing a fresh container pull, faster this way

Try running again and see if that adjustment can give some more info, seems like maybe getting somewhere cause session probably shouldn't be None

As for log 3 this is a totally separate issue. Just want to confirm on the iPad that you have Advertise as Player turned on (Settings > Remote Control > Advertise as Player)

tchirou commented 1 year ago

Spot on for iPad! Now it works!

Log enclosed for the fire stick, still doesn't work pas 4.log

mdhiggins commented 1 year ago

Glad the iPad is fixed lol

I still managed to leave behind a logging exception but we got enough info to see the problem!

Alert for 246-9fb3d36a60a2899f-com-plexapp-android with state playing viewOffset --- playQueueID 5333 location lan
Alert for 247-9fb3d36a60a2899f-com-plexapp-android with state playing viewOffset --- playQueueID 5334 location wan

See the difference? Same player, next session ID (+1) but Plex is marking it as a wan session, not local and therefore the script ignores it

Now, why it would do that, I have absolutely no idea. I did just push a new update however that increases the logging output to maybe provide some more insight. I also changed some stuff around, instead of building a new playqueue for the next episode I just remove the last episode from the current queue, refresh, and send that back to the player, maybe that will prevent this issue, update and give it a try

tchirou commented 1 year ago

Hi I tried after updating but still no luck

A bit of information My ISP modem is plugged in a netgear nighthawk router MR60, which has 2 mesh satellites The ISP modem is 192.168.4.1, the netgear router is 192.168.4.2 with a DMZ so everything goes to 192.168.4.2 The netgear manages a DCHP with 192.168.1.* Which is why the Fire stick ip adress is 192.168.1.20. The plex media server is at 192.168.1.18.

I really don't know why, when next = true, plex is seeing the wan subnet instead of the lan one, for the android clients

2 logs attached

1 is with the user Tchirou2, which is a plex home user pas 1.log

2 is with the user tchirou, which is the admin plex user pas 2.log

mdhiggins commented 1 year ago

So looks like Plex is getting confused by the double NAT and is then reporting the IP address that's playing the file as your router IP. I had a similar issue with unbound

https://dietpi.com/forum/t/cant-connect-to-plex-directly-due-to-unbound/5199/2

May not be relevant though

Just pushed a new update that reworks how the server handling of the new playqueue works, see if maybe that helps. It also might fix the user switching there as well

The other option that might help is adding your other subnet to the local IP addresses in your Plex server settings under Plex Server > Settings > Network > LAN Networks and try 192.168.1.1/24, 192.168.4.1/24

tchirou commented 1 year ago

There is no update on the container through docker-compose up -d Do you want me to just restart the container ? I will be able to try on site in 3 hours at home

Le mar. 21 févr. 2023 à 16:10, Michael Higgins @.***> a écrit :

So looks like Plex is getting confused by the double NAT and is then reporting the IP address that's playing the file as your router IP. I had a similar issue with unbound

https://dietpi.com/forum/t/cant-connect-to-plex-directly-due-to-unbound/5199/2

May not be relevant though

Just pushed a new update that reworks how the server handling of the new playqueue works, see if maybe that helps. It also might fix the user switching there as well

The other option that might help is adding your other subnet to the local IP addresses in your Plex server settings under Plex Server > Settings > Network > LAN Networks and try 192.168.1.1/24, 192.168.4.1/24

— Reply to this email directly, view it on GitHub https://github.com/mdhiggins/PlexAutoSkip/issues/36#issuecomment-1438649119, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTPZ3BJFXHBERYEPDNIU5DWYTLHHANCNFSM6AAAAAAVBGZ4P4 . You are receiving this because you authored the thread.Message ID: @.***>

mdhiggins commented 1 year ago

Set environment variable PAS_UPDATE to true and then just restart that'll update things

tchirou commented 1 year ago

Ok I will let you know tonight Thanks

Le mar. 21 févr. 2023 à 16:51, Michael Higgins @.***> a écrit :

Set environment variable PAS_UPDATE to true and then just restart that'll update things

— Reply to this email directly, view it on GitHub https://github.com/mdhiggins/PlexAutoSkip/issues/36#issuecomment-1438712509, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTPZ3ENE2VTOA75UW5RRP3WYTQA3ANCNFSM6AAAAAAVBGZ4P4 . You are receiving this because you authored the thread.Message ID: @.***>

tchirou commented 1 year ago

Unfortunately, still no luck

Fire TV log pas 5.log

Shield Android TV log pas 6.log

Philips Android TV log pas 7.log

tchirou commented 1 year ago

Works great on Apple TV though Definitely a android tv specific issue

narenarora commented 1 year ago

My apologies if I am butting in - I am using Plex on Roku. Skip Intro works fine. But "End Credits" and "Next" are not skipped. The Skip Intro kicks in a second or two too soon, but livable. Will check if I can change something in the config.ini to fix this.

Below is what I see in the log for the duration.

INFO - Found new session 24 [5826] (Two and a Half Men s07e14 - Crude and Uncalled For (1)) *** viewOffset 1255000 narenarora, sessions: 0
INFO - Found skippable marker intro for media 24 [5826] (Two and a Half Men s07e14 - Crude and Uncalled For (1)) *** with range 242429-269736 and viewOffset 242440
INFO - Seeking Plex for Roku player playing 24 [5826] (Two and a Half Men s07e14 - Crude and Uncalled For (1)) *** from 242444 to 269736
ERROR - BadRequest Error, see https://github.com/mdhiggins/PlexAutoSkip/wiki/Troubleshooting#badrequest-error
INFO - Seeking Plex for Roku player playing 24 [5826] (Two and a Half Men s07e14 - Crude and Uncalled For (1)) *** from 242445 to 269736
INFO - Found skippable marker credits for media 24 [5826] (Two and a Half Men s07e14 - Crude and Uncalled For (1)) *** with range 1259069-1287744 and viewOffset 1259284
ERROR - Exception, removing from cache to prevent false triggers, will be restored with next sync
Traceback (most recent call last):
  File "/usr/local/pas/resources/skipper.py", line 256, in skipPlayerTo
    pq = PlayQueue.get(self.server, mediaWrapper.playQueueID)
  File "/usr/local/pas/venv/lib/python3.9/site-packages/plexapi/playqueue.py", line 133, in get
    c = cls(server, data, initpath=path)
  File "/usr/local/pas/venv/lib/python3.9/site-packages/plexapi/base.py", line 57, in __init__
    self._loadData(data)
  File "/usr/local/pas/venv/lib/python3.9/site-packages/plexapi/playqueue.py", line 66, in _loadData
    self.selectedItem = self[self.playQueueSelectedItemOffset]
  File "/usr/local/pas/venv/lib/python3.9/site-packages/plexapi/playqueue.py", line 71, in __getitem__
    return self.items[key]
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/pas/resources/skipper.py", line 213, in _seekTo
    self.seekPlayerTo(mediaWrapper.player, mediaWrapper, targetOffset)
  File "/usr/local/pas/resources/skipper.py", line 232, in seekPlayerTo
    return self.skipPlayerTo(player, mediaWrapper)
  File "/usr/local/pas/resources/skipper.py", line 275, in skipPlayerTo
    self.log.warning("Seek target is the end but unable to get PlayQueue %d (%d) data from server, aborting to prevent extra skips or playback issues" % (mediaWrapper.playQueueID, mediaWrapper.media.playQueueItemID))
TypeError: %d format: a number is required, not NoneType
INFO - Found new session 27 [5827] (Two and a Half Men s07e15 - Aye, Aye, Captain Douche (2)) *** viewOffset 0 narenarora, sessions: 0
INFO - Found skippable marker credits for media 27 [5827] (Two and a Half Men s07e15 - Aye, Aye, Captain Douche (2)) *** with range 1298553-1324948 and viewOffset 1298966
ERROR - Exception, removing from cache to prevent false triggers, will be restored with next sync
Traceback (most recent call last):
  File "/usr/local/pas/resources/skipper.py", line 256, in skipPlayerTo
    pq = PlayQueue.get(self.server, mediaWrapper.playQueueID)
  File "/usr/local/pas/venv/lib/python3.9/site-packages/plexapi/playqueue.py", line 133, in get
    c = cls(server, data, initpath=path)
  File "/usr/local/pas/venv/lib/python3.9/site-packages/plexapi/base.py", line 57, in __init__
    self._loadData(data)
  File "/usr/local/pas/venv/lib/python3.9/site-packages/plexapi/playqueue.py", line 66, in _loadData
    self.selectedItem = self[self.playQueueSelectedItemOffset]
  File "/usr/local/pas/venv/lib/python3.9/site-packages/plexapi/playqueue.py", line 71, in __getitem__
    return self.items[key]
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/pas/resources/skipper.py", line 213, in _seekTo
    self.seekPlayerTo(mediaWrapper.player, mediaWrapper, targetOffset)
  File "/usr/local/pas/resources/skipper.py", line 232, in seekPlayerTo
    return self.skipPlayerTo(player, mediaWrapper)
  File "/usr/local/pas/resources/skipper.py", line 275, in skipPlayerTo
    self.log.warning("Seek target is the end but unable to get PlayQueue %d (%d) data from server, aborting to prevent extra skips or playback issues" % (mediaWrapper.playQueueID, mediaWrapper.media.playQueueItemID))
TypeError: %d format: a number is required, not NoneType

Do let me know if this should reported as a new issue.

mdhiggins commented 1 year ago

No need for a new issue. Please update the script the error you're getting has been fixed already and there was an update from today that adds better support for players that aren't returning a PlayQueue. As for credits, did you add "credits" to the tags? And there was a small bug with the offsets not working in certain scenarios so the intro going a few seconds too early may be from that. If not then you just need to adjust your offsets in config.ini

narenarora commented 1 year ago

Thank you. I have updated my docker container. Will report back. Regarding the credits, yes I have it included. Below is my config

[Security]
ignore-certs = False

[Skip]
mode = skip
tags = intro, commercial, advertisement, credits
types = movie, episode
ignored-libraries =
last-chapter = 0.0
unwatched = True
first-episode-series = Watched
first-episode-season = Always
next = True

[Offsets]
start = 3000
end = 1000
command = 500
tags = intro

[Volume]
low = 0
high = 100
mdhiggins commented 1 year ago

Had a chance to look at the logs closer, its detecting the credits fine but because you also have skip Next enabled its not bothering to skip to the end and its just trying to go next (as intended), that's not working because of the PlayQueue issue which should be fixed in the update

mdhiggins commented 1 year ago

@tchirou

Looks like some progress based on those logs, the user doesn't appear to be switching anymore so that's good, the IP issue still persists though

Did adding that 192.168.4.1/24 subnet to your local networks in the Plex setting have any impact?

I don't know if this would be a huge pain or not, but I've seen other people resolve this issue by just putting everything on the same subnet, so make ISP modem 192.168.1.1, netgear 192.168.1.2, other routers as follows at 192.168.1.3/4, and then just start your DHCP range after those IP addresses in the 192.168.1.5-255 range

narenarora commented 1 year ago

@mdhiggins I updated my docker and tried again. For the first episode played, the Skip Intro and Skip Credits worked okay. It however, did not skip the "Up Next" screen. For the next episode, at the Skip Intro part, it directly skipped to the end and took me to the "Up Next" screen for the next episode.

Below are the logs for the time period

INFO - Found skippable marker credits for media 68 [5830] (Two and a Half Men s07e18 - Ixnay on the Oggie Day) *** with range 1251807(+0)-1279786(+0) and viewOffset 1252779
INFO - Seeking Plex for Roku player playing 68 [5830] (Two and a Half Men s07e18 - Ixnay on the Oggie Day) *** from 1252781 to 1278321
ERROR - BadRequest Error, see https://github.com/mdhiggins/PlexAutoSkip/wiki/Troubleshooting#badrequest-error
INFO - Seeking Plex for Roku player playing 68 [5830] (Two and a Half Men s07e18 - Ixnay on the Oggie Day) *** from 1252782 to 1278321
INFO - Found new session 69 [5831] (Two and a Half Men s07e19 - Keith Moon Is Vomiting in His Grave) *** viewOffset 0 narenarora on Plex for Roku, sessions: 1
INFO - Session 68 [5830] (Two and a Half Men s07e18 - Ixnay on the Oggie Day) *** shares player (***) with new session 69 [5831] (Two and a Half Men s07e19 - Keith Moon Is Vomiting in His Grave) Jarvis Ultra|3e632f7c0d7708c86576e1e816d35173, deleting old session 68
INFO - Found skippable marker intro for media 69 [5831] (Two and a Half Men s07e19 - Keith Moon Is Vomiting in His Grave) *** with range 156978(+3000)-186285(+1000) and viewOffset 160083
INFO - Seeking Plex for Roku player playing 69 [5831] (Two and a Half Men s07e19 - Keith Moon Is Vomiting in His Grave) *** from 160085 to 187285
ERROR - BadRequest Error, see https://github.com/mdhiggins/PlexAutoSkip/wiki/Troubleshooting#badrequest-error
INFO - Seeking Plex for Roku player playing 69 [5831] (Two and a Half Men s07e19 - Keith Moon Is Vomiting in His Grave) *** from 160086 to 187285

I then hit my back button and went back to my Plex Home, which caused below errors in the log, I am assuming this can be ignored

INFO - Seeking Plex for Roku player playing 69 [5831] (Two and a Half Men s07e19 - Keith Moon Is Vomiting in His Grave) *** from 160086 to 187285
ERROR - getDataFromSessions Error
Traceback (most recent call last):
  File "/usr/local/pas/venv/lib/python3.10/site-packages/urllib3/connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
  File "/usr/local/pas/venv/lib/python3.10/site-packages/urllib3/connectionpool.py", line 449, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "/usr/local/pas/venv/lib/python3.10/site-packages/urllib3/connectionpool.py", line 444, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib/python3.10/http/client.py", line 1374, in getresponse
    response.begin()
  File "/usr/lib/python3.10/http/client.py", line 318, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.10/http/client.py", line 287, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/pas/venv/lib/python3.10/site-packages/requests/adapters.py", line 489, in send
    resp = conn.urlopen(
  File "/usr/local/pas/venv/lib/python3.10/site-packages/urllib3/connectionpool.py", line 787, in urlopen
    retries = retries.increment(
  File "/usr/local/pas/venv/lib/python3.10/site-packages/urllib3/util/retry.py", line 550, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/usr/local/pas/venv/lib/python3.10/site-packages/urllib3/packages/six.py", line 769, in reraise
    raise value.with_traceback(tb)
  File "/usr/local/pas/venv/lib/python3.10/site-packages/urllib3/connectionpool.py", line 703, in urlopen
    httplib_response = self._make_request(
  File "/usr/local/pas/venv/lib/python3.10/site-packages/urllib3/connectionpool.py", line 449, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "/usr/local/pas/venv/lib/python3.10/site-packages/urllib3/connectionpool.py", line 444, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/lib/python3.10/http/client.py", line 1374, in getresponse
    response.begin()
  File "/usr/lib/python3.10/http/client.py", line 318, in begin
    version, status, reason = self._read_status()
  File "/usr/lib/python3.10/http/client.py", line 287, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/pas/resources/skipper.py", line 96, in getMediaSession
    return next(iter([session for session in self.server.sessions() if session.sessionKey == sessionKey]), None)
  File "/usr/local/pas/venv/lib/python3.10/site-packages/plexapi/server.py", line 799, in sessions
    return self.fetchItems('/status/sessions')
  File "/usr/local/pas/venv/lib/python3.10/site-packages/plexapi/base.py", line 268, in fetchItems
    data = self._server.query(ekey, params=params)
  File "/usr/local/pas/venv/lib/python3.10/site-packages/plexapi/server.py", line 745, in query
    response = method(url, headers=headers, timeout=timeout, **kwargs)
  File "/usr/local/pas/venv/lib/python3.10/site-packages/requests/sessions.py", line 600, in get
    return self.request("GET", url, **kwargs)
  File "/usr/local/pas/venv/lib/python3.10/site-packages/requests/sessions.py", line 587, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/pas/venv/lib/python3.10/site-packages/requests/sessions.py", line 701, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/pas/venv/lib/python3.10/site-packages/requests/adapters.py", line 547, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
tchirou commented 1 year ago

@tchirou

Looks like some progress based on those logs, the user doesn't appear to be switching anymore so that's good, the IP issue still persists though

Did adding that 192.168.4.1/24 subnet to your local networks in the Plex setting have any impact?

I don't know if this would be a huge pain or not, but I've seen other people resolve this issue by just putting everything on the same subnet, so make ISP modem 192.168.1.1, netgear 192.168.1.2, other routers as follows at 192.168.1.3/4, and then just start your DHCP range after those IP addresses in the 192.168.1.5-255 range

Hi Honestly, it would be too much of a pain as I have a whole security and home automation system with more than 50 devices and a lot of settings/rules (this is why I use a better router than the old isp one). Waiting for the next countdown is not really a pain, it has becoming more of a challenge to intellectually solve the issue than a real problem Have you ever got feedback from users with android tv plex clients ? Is it working for them ? Thanks a lot for you help

mdhiggins commented 1 year ago

@tchirou Seems like it does work fine on Android TV I just think your specific networking setup is causing this issue on Android

Did this help?

Did adding that 192.168.4.1/24 subnet to your local networks in the Plex setting have any impact?

Shoot me a screenshot of what you have in that setting when you get a chance

@narenarora

Little tough to say what happened here, can you try again with that same episode and post the DEBUG logs? (See wiki on how to enable) and can you also send me the duration value from that episodes XML file (Plex Web > That Episode > Three Dot Button > Get Info > View XML > Ctrl + F "duration=")

I did just run a test on Roku and its all working fine (minus the BadRequest notice which is still ok)

The up next screen does appear for a second or so on Roku but then should be overwritten, pressing back or interrupting the UI at that point can potentially block the next request so that may have been why the subsequent errors showed up but the timing for that would have been very quick, like back button almost immediately after the screen appeared

INFO - Found new session 622 [40414] (Bob's Burgers s01e06 - Sheesh! Cab, Bob?) ROKU viewOffset 617000 mhiggins on Plex for Roku, sessions: 0
DEBUG - Updating session 622 [40414] (Bob's Burgers s01e06 - Sheesh! Cab, Bob?) ROKU [paused] viewOffset 619000, old 619857, diff -857ms (2s since last update)
DEBUG - Updating session 622 [40414] (Bob's Burgers s01e06 - Sheesh! Cab, Bob?) ROKU [buffering] viewOffset 1260000, old 619000, diff 641000ms (9s since last update)
DEBUG - Updating session 622 [40414] (Bob's Burgers s01e06 - Sheesh! Cab, Bob?) ROKU [playing] viewOffset 1260000, old 1260000, diff 0ms (1s since last update)
INFO - Found skippable marker credits for media 622 [40414] (Bob's Burgers s01e06 - Sheesh! Cab, Bob?) ROKU with range 1268576(+0)-1300640(+0) and viewOffset 1268954
DEBUG - Deleting session 622 [40414] (Bob's Burgers s01e06 - Sheesh! Cab, Bob?) ROKU, sessions: 0
DEBUG - Ignoring session 622 [40414] (Bob's Burgers s01e06 - Sheesh! Cab, Bob?) ROKU mhiggins, ignored: 1
DEBUG - Creating new PlayQueue 43406 with start item <Episode:40415:Bob's-Burgers-s01e07>
ERROR - BadRequest Error, see https://github.com/mdhiggins/PlexAutoSkip/wiki/Troubleshooting#badrequest-error
DEBUG - Modifying client for direct connection using baseURL http://10.0.1.235:8324 for player Living Room (None)
DEBUG - Ignoring session 622 [40414] (Bob's Burgers s01e06 - Sheesh! Cab, Bob?) ROKU mhiggins, ignored: 2
DEBUG - Creating new PlayQueue 43407 with start item <Episode:40415:Bob's-Burgers-s01e07>
INFO - Found new session 623 [40415] (Bob's Burgers s01e07 - Bed & Breakfast) ROKU viewOffset 0 mhiggins on Plex for Roku, sessions: 0
DEBUG - Updating session 623 [40415] (Bob's Burgers s01e07 - Bed & Breakfast) ROKU [stopped] viewOffset 2000, old 4295, diff -2295ms (4s since last update)
tchirou commented 1 year ago

Unfortunately it didn’t help E4DE0022-3533-4CF5-81B8-74A0D3A46C01 If it’s just me, then it’s not that big a deal, I will wait for the up next countdown Thanks a lot for your help

narenarora commented 1 year ago

TL;DR : After a fresh pull for latest docker image - and a clean restart of both PAS and Plex, Skip Intro and Skip Credits is working fine. I still have to wait through the Up Next screen. Honestly, I can live with it if this is just an odd issue.

Details: After the latest docker pull last night, had a weird issue where Plex and PAS weren't playing well together. At the Skip Intro, it would skip to next episode directly. Or, it would get stuck at the Up Next screen, and disable my control altogether. Meaning, Up Next was no longer counting down, it would just sit there with the "play" button, and me hitting "OK" or "play" on the roku remote would do nothing. I always had to go back to the Plex home screen and play next episode from there. So I modified my config next = False and restarted the container. Ever since, Skip Intro and End Credits seem to work okay, but Up Next wont. I even flipped the config to next = True , but the Up Next doesn't skip.

Below is a log from just now where Skip Intro and End Credits worked, Up Next didn't

INFO - Found new session 101 [5808] (Two and a Half Men s08e13 - Skunk, Dog Crap and Ketchup) *** viewOffset 0 narenarora on Plex for Roku, sessions: 0
INFO - Found skippable marker intro for media 101 [5808] (Two and a Half Men s08e13 - Skunk, Dog Crap and Ketchup) *** with range 253418(+3000)-280744(+1000) and viewOffset 256741
INFO - Seeking Plex for Roku player playing 101 [5808] (Two and a Half Men s08e13 - Skunk, Dog Crap and Ketchup) *** from 256743 to 281744
ERROR - BadRequest Error, see https://github.com/mdhiggins/PlexAutoSkip/wiki/Troubleshooting#badrequest-error
INFO - Seeking Plex for Roku player playing 101 [5808] (Two and a Half Men s08e13 - Skunk, Dog Crap and Ketchup) *** from 256745 to 281744
INFO - Found skippable marker credits for media 101 [5808] (Two and a Half Men s08e13 - Skunk, Dog Crap and Ketchup) *** with range 1249886(+0)-1277652(+0) and viewOffset 1250143
ERROR - Unable to create new PlayQueue for 101 [5808] (Two and a Half Men s08e13 - Skunk, Dog Crap and Ketchup) ***
Traceback (most recent call last):
  File "/usr/local/pas/resources/skipper.py", line 277, in skipPlayerTo
    current = PlayQueue.get(self.server, mediaWrapper.playQueueID)
  File "/usr/local/pas/venv/lib/python3.10/site-packages/plexapi/playqueue.py", line 133, in get
    c = cls(server, data, initpath=path)
  File "/usr/local/pas/venv/lib/python3.10/site-packages/plexapi/base.py", line 57, in __init__
    self._loadData(data)
  File "/usr/local/pas/venv/lib/python3.10/site-packages/plexapi/playqueue.py", line 66, in _loadData
    self.selectedItem = self[self.playQueueSelectedItemOffset]
  File "/usr/local/pas/venv/lib/python3.10/site-packages/plexapi/playqueue.py", line 71, in __getitem__
    return self.items[key]
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/pas/resources/skipper.py", line 291, in skipPlayerTo
    pq = PlayQueue.create(server, episodes, episodes[episodes.index(mediaWrapper.media) + 1])
  File "/usr/local/pas/venv/lib/python3.10/site-packages/plexapi/playqueue.py", line 190, in create
    c = cls(server, data, initpath=path)
  File "/usr/local/pas/venv/lib/python3.10/site-packages/plexapi/base.py", line 57, in __init__
    self._loadData(data)
  File "/usr/local/pas/venv/lib/python3.10/site-packages/plexapi/playqueue.py", line 66, in _loadData
    self.selectedItem = self[self.playQueueSelectedItemOffset]
  File "/usr/local/pas/venv/lib/python3.10/site-packages/plexapi/playqueue.py", line 71, in __getitem__
    return self.items[key]
IndexError: list index out of range
WARNING - No available PlayQueue data 365 (None), using seekTo to go to media end
INFO - Found new session 103 [5809] (Two and a Half Men s08e14 - Lookin' for Japanese Subs) *** viewOffset 0 narenarora on Plex for Roku, sessions: 0

Requested duration info for the same episode as above logs (s08e13) : duration="1277652"

I will try the DEBUG option and get back to you.

narenarora commented 1 year ago

I unexpectedly noticed a pattern for the issues I mentioned above where it gets stuck on the Up Next screen and the "OK" or "play" buttons don't work. That seems to be happening for the below cases :

Don't see it happening for any of the other episodes. Below is the logs for the above cases

pas_logs.txt

mdhiggins commented 1 year ago

Hm that's an interesting error. The first exception is to be expected, that's the normal PlayQueue failure that happens on lots of players but the second exception is Plex failing to create a new PlayQueue because the episode that's selected (the next episode) is somehow not actually in the list which really shouldn't be the case. Are you seeing this on shows with fewer episodes? I wonder if Plex last a limit to the number of items in a PlayQueue and is windowing it in a way that the episode it supposed to start on is getting truncated

mdhiggins commented 1 year ago

I'm not home currently so I can't test his code switch but I made some small changes, if you want to swap in this skipper.py file and see if it changes anything in the mean time feel free. I basically manually sort the list of episodes and window the list to ensure the selected episode is in the middle

skipper.py.zip

narenarora commented 1 year ago

Thank you for changes, but that didn't help. And I also started seeing the same behavior with random episodes now, not just ones at the edge. And this is both, with and without your above provided code. Now, I am starting to think it's a weird issue only affecting me.

mdhiggins commented 1 year ago

It seems like it's a weird Plex problem. Making a play queue shouldn't result in an error where the episode isn't in the queue that was just created. I wonder if updating or running a database repair or something on your Plex server might yield some improvement. Maybe run the library optimize feature and see if it changes anything. I haven't been able to reproduce this.