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

Script completely breaks when using live TV #72

Closed
superboo07 opened this issue Nov 15, 2023 · 7 comments
Closed

Script completely breaks when using live TV #72

superboo07 opened this issue Nov 15, 2023 · 7 comments
Labels
enhancement New feature or request

Comments

@superboo07
Copy link

superboo07 commented Nov 15, 2023

It will stop taking in plays, and will forever display the previous one. Then it will continuously spit out this error

[15-11-2023 01:31:52 PM] [ERROR] [superboo07's friendly media server/95AC3] An unexpected error occured in the alert handler
Traceback (most recent call last):
  File "C:\Users\talls\OneDrive\Documents\discord-rich-presence-plex-master\services\PlexAlertListener.py", line 131, in handlePlexAlert
    libraryName: str = item.section().title
                       ^^^^^^^^^^^^^^
  File "C:\Users\talls\AppData\Local\Programs\Python\Python311\Lib\site-packages\plexapi\base.py", line 614, in section
    return self._server.library.sectionByID(self.librarySectionID)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\talls\AppData\Local\Programs\Python\Python311\Lib\site-packages\plexapi\library.py", line 84, in sectionByID
    raise NotFound('Invalid library sectionID: %s' % sectionID) from None
plexapi.exceptions.NotFound: Invalid library sectionID: None
[15-11-2023 01:31:52 PM] [DEBUG] [superboo07's friendly media server/95AC3] Request for list of clients to check connection: []
@phin05 phin05 added the enhancement New feature or request label Nov 15, 2023
@phin05
Copy link
Owner

phin05 commented Nov 15, 2023

That's an error in the Python-PlexAPI module, presumably because the version required and being used by this script is an older one that doesn't support live TV. There are some breaking changes in newer versions so I've avoided switching over, but I'll do it in a future update.

@phin05
Copy link
Owner

phin05 commented Feb 10, 2024

Could you try again using v2.6.0? That error shouldn't occur anymore but I'm pretty sure something else is going to break. I don't have access to any live TV so I can't test this.

@roombobcat
Copy link

roombobcat commented Feb 11, 2024

Could you try again using v2.6.0? That error shouldn't occur anymore but I'm pretty sure something else is going to break. I don't have access to any live TV so I can't test this.

Same issue here, just noticed the thread about this and wanted to report this issue with 2.6.0.

TypeError: unsupported operand type(s) for /: 'NoneType' and 'int'
[11-02-2024 01:47:24 PM] [DEBUG] [MediaVM] Received alert: {'sessionKey': '54', 'clientIdentifier': 'ps3stxxopqhplajd9bdtvles', 'guid': '', 'ratingKey': '6375', 'url': '', 'key': '/livetv/sessions/99bf09bb-7389-4dd9-9028-603ee3d0f4ca', 'viewOffset': 73000, 'state': 'paused', 'transcodeSession': 'vjl6u68uedojucly6r6car1s'}
[11-02-2024 01:47:24 PM] [DEBUG] [MediaVM] Searching sessions for session key 54
[11-02-2024 01:47:24 PM] [DEBUG] [MediaVM] <EpisodeSession:/livetv/sessions/99bf09bb-7389-4dd9-9028-603ee3d0f4ca:The-NFL-Today-s2024e06>, Session Key: 54, Usernames: ['roombobcat']
[11-02-2024 01:47:24 PM] [DEBUG] [MediaVM] Session found
[11-02-2024 01:47:24 PM] [DEBUG] [MediaVM] Username 'roombobcat' matches 'roombobcat', continuing
[11-02-2024 01:47:24 PM] [ERROR] [MediaVM] An unexpected error occured in the Plex alert handler
Traceback (most recent call last):
  File "/home/roombobcat/discord-rich-presence-plex/core/plex.py", line 148, in tryHandleAlert
    self.handleAlert(alert)
  File "/home/roombobcat/discord-rich-presence-plex/core/plex.py", line 222, in handleAlert
    stateStrings: list[str] = [] if config["display"]["hideTotalTime"] else [formatSeconds(item.duration / 1000)]
                                                                                           ~~~~~~~~~~~~~~^~~~~~
TypeError: unsupported operand type(s) for /: 'NoneType' and 'int'
[11-02-2024 01:47:25 PM] [DEBUG] [MediaVM] Received alert: {'sessionKey': '54', 'clientIdentifier': 'ps3stxxopqhplajd9bdtvles', 'guid': '', 'ratingKey': '6375', 'url': '', 'key': '/livetv/sessions/99bf09bb-7389-4dd9-9028-603ee3d0f4ca', 'viewOffset': 73000, 'state': 'paused', 'transcodeSession': 'vjl6u68uedojucly6r6car1s'}
[11-02-2024 01:47:25 PM] [DEBUG] [MediaVM] Nothing changed, ignoring
[11-02-2024 01:47:26 PM] [DEBUG] [MediaVM] Received alert: {'sessionKey': '54', 'clientIdentifier': 'ps3stxxopqhplajd9bdtvles', 'guid': '', 'ratingKey': '6375', 'url': '', 'key': '/livetv/sessions/99bf09bb-7389-4dd9-9028-603ee3d0f4ca', 'viewOffset': 73000, 'state': 'paused', 'transcodeSession': 'vjl6u68uedojucly6r6car1s'}
[11-02-2024 01:47:26 PM] [DEBUG] [MediaVM] Nothing changed, ignoring
[11-02-2024 01:47:27 PM] [DEBUG] [MediaVM] Received alert: {'sessionKey': '54', 'clientIdentifier': 'ps3stxxopqhplajd9bdtvles', 'guid': '', 'ratingKey': '6375', 'url': '', 'key': '/livetv/sessions/99bf09bb-7389-4dd9-9028-603ee3d0f4ca', 'viewOffset': 73000, 'state': 'stopped', 'transcodeSession': '99bf09bb-7389-4dd9-9028-603ee3d0f4ca'}

@phin05
Copy link
Owner

phin05 commented Feb 11, 2024

@roombobcat Could you modify /home/roombobcat/discord-rich-presence-plex/core/plex.py and add a line as below:

		if mediaType in ["movie", "episode", "clip"]: # line 221, already exists
			print(item.__dict__) # add this new line after line 221

Or, just replace the whole plex.py file with the one in this ZIP file.

Run the script again and post the new output which will appear before the error. (redact sensitive content, if any)

I can't test it myself and the API documentation is lacking so I need to see what properties item has to tweak the script to work accordingly.

@roombobcat
Copy link

@phin05

python main.py
[11-02-2024 02:37:48 PM] [INFO] Discord Rich Presence for Plex - v2.6.0
[11-02-2024 02:37:48 PM] [INFO] [MediaVM] Signing into Plex
[11-02-2024 02:37:49 PM] [INFO] [MediaVM] Signed in as Plex user 'roombobcat'
[11-02-2024 02:37:49 PM] [INFO] [MediaVM] Connecting to Plex Media Server 'MediaVM'
[11-02-2024 02:38:19 PM] [INFO] [MediaVM] Connected to Plex Media Server 'MediaVM'
[11-02-2024 02:38:19 PM] [INFO] [MediaVM] Listening for alerts from user 'roombobcat'
[11-02-2024 02:38:26 PM] [DEBUG] [MediaVM] Received alert: {'sessionKey': '57', 'clientIdentifier': 'ps3stxxopqhplajd9bdtvles', 'guid': '', 'ratingKey': '6378', 'url': '', 'key': '/livetv/sessions/49512cb7-3eb7-4808-b903-236c00164b43', 'viewOffset': 0, 'state': 'playing', 'transcodeSession': '49512cb7-3eb7-4808-b903-236c00164b43'}
[11-02-2024 02:38:26 PM] [DEBUG] [MediaVM] Searching sessions for session key 57
[11-02-2024 02:38:26 PM] [DEBUG] [MediaVM] <EpisodeSession:/livetv/sessions/49512cb7-3eb7-4808-b903-236c00164b43:The-NFL-Today-s2024e06>, Session Key: 57, Usernames: ['roombobcat']
[11-02-2024 02:38:26 PM] [DEBUG] [MediaVM] Session found
[11-02-2024 02:38:26 PM] [DEBUG] [MediaVM] Username 'roombobcat' matches 'roombobcat', continuing
{'_server': <PlexServer:http://plexserverIP>, '_data': <Element 'Video' at 0x7ff8279686d0>, '_initpath': '/livetv/sessions/49512cb7-3eb7-4808-b903-236c00164b43?checkFiles=1&includeAllConcerts=1&includeBandwidths=1&includeChapters=1&includeChildren=1&includeConcerts=1&includeExternalMedia=1&includeExtras=1&includeFields=thumbBlurHash%2CartBlurHash&includeGeolocation=1&includeLoudnessRamps=1&includeMarkers=1&includeOnDeck=1&includePopularLeaves=1&includePreferences=1&includeRelated=1&includeRelatedCount=1&includeReviews=1&includeStations=1', '_parent': <weakref at 0x7ff827919170; to 'PlexServer' at 0x7ff8283916a0>, '_details_key': '/livetv/sessions/49512cb7-3eb7-4808-b903-236c00164b43?checkFiles=1&includeAllConcerts=1&includeBandwidths=1&includeChapters=1&includeChildren=1&includeConcerts=1&includeExternalMedia=1&includeExtras=1&includeFields=thumbBlurHash%2CartBlurHash&includeGeolocation=1&includeLoudnessRamps=1&includeMarkers=1&includeOnDeck=1&includePopularLeaves=1&includePreferences=1&includeRelated=1&includeRelatedCount=1&includeReviews=1&includeStations=1', '_overwriteNone': True, '_autoReload': True, '_edits': None, 'addedAt': datetime.datetime(2024, 2, 11, 14, 38, 25), 'art': None, 'artBlurHash': None, 'fields': [], 'guid': 'plex://episode/65ba92ecf4dd4f1ef6cba4f3', 'key': '/livetv/sessions/49512cb7-3eb7-4808-b903-236c00164b43', 'lastRatedAt': None, 'lastViewedAt': datetime.datetime(2024, 2, 11, 13, 46, 38), 'librarySectionID': None, 'librarySectionKey': None, 'librarySectionTitle': None, 'listType': 'video', 'ratingKey': 6378, 'summary': '', 'thumb': None, 'thumbBlurHash': None, 'title': 'The NFL Today', 'titleSort': 'NFL Today', 'type': 'episode', 'updatedAt': None, 'userRating': None, 'viewCount': 0, 'playlistItemID': None, 'playQueueItemID': None, 'audienceRating': None, 'audienceRatingImage': None, 'chapters': [], 'chapterSource': None, 'collections': [], 'contentRating': None, 'directors': [], 'duration': None, 'grandparentArt': None, 'grandparentGuid': None, 'grandparentKey': None, 'grandparentRatingKey': None, 'grandparentTheme': None, 'grandparentThumb': 'https://metadata-static.plex.tv/a/gracenote/a15b5f1c562072ab3ada04cb4210a0f9.jpg', 'grandparentTitle': 'The NFL Today', 'guids': [], 'index': 6, 'labels': [], 'markers': [], 'media': [<Media:10108>], 'originallyAvailableAt': None, 'parentGuid': None, 'parentIndex': 2024, 'parentTitle': None, 'parentYear': None, 'producers': [], 'rating': None, 'ratings': [], 'roles': [], 'skipParent': False, 'viewOffset': 0, 'writers': [], 'year': 2024, '_parentKey': None, '_parentRatingKey': None, '_parentThumb': None}
[11-02-2024 02:38:26 PM] [ERROR] [MediaVM] An unexpected error occured in the Plex alert handler
Traceback (most recent call last):
  File "/home/roombobcat/discord-rich-presence-plex/core/plex.py", line 148, in tryHandleAlert
    self.handleAlert(alert)
  File "/home/roombobcat/discord-rich-presence-plex/core/plex.py", line 223, in handleAlert
    stateStrings: list[str] = [] if config["display"]["hideTotalTime"] else [formatSeconds(item.duration / 1000)]
                                                                                           ~~~~~~~~~~~~~~^~~~~~
TypeError: unsupported operand type(s) for /: 'NoneType' and 'int'
[11-02-2024 02:38:28 PM] [DEBUG] [MediaVM] Received alert: {'sessionKey': '57', 'clientIdentifier': 'ps3stxxopqhplajd9bdtvles', 'guid': '', 'ratingKey': '6378', 'url': '', 'key': '/livetv/sessions/49512cb7-3eb7-4808-b903-236c00164b43', 'viewOffset': 0, 'state': 'playing', 'transcodeSession': 'hqrtwtik5grhs80sezieyjq0'}
[11-02-2024 02:38:28 PM] [DEBUG] [MediaVM] Nothing changed, ignoring
[11-02-2024 02:38:29 PM] [DEBUG] [MediaVM] Received alert: {'sessionKey': '57', 'clientIdentifier': 'ps3stxxopqhplajd9bdtvles', 'guid': '', 'ratingKey': '6378', 'url': '', 'key': '/livetv/sessions/49512cb7-3eb7-4808-b903-236c00164b43', 'viewOffset': 1000, 'state': 'buffering', 'transcodeSession': 'hqrtwtik5grhs80sezieyjq0'}
[11-02-2024 02:38:29 PM] [DEBUG] [MediaVM] Searching sessions for session key 57
[11-02-2024 02:38:29 PM] [DEBUG] [MediaVM] <EpisodeSession:/livetv/sessions/49512cb7-3eb7-4808-b903-236c00164b43:The-NFL-Today-s2024e06>, Session Key: 57, Usernames: ['roombobcat']
[11-02-2024 02:38:29 PM] [DEBUG] [MediaVM] Session found
[11-02-2024 02:38:29 PM] [DEBUG] [MediaVM] Username 'roombobcat' matches 'roombobcat', continuing
{'_server': <PlexServer:http://plexserverIP>, '_data': <Element 'Video' at 0x7ff8279684f0>, '_initpath': '/livetv/sessions/49512cb7-3eb7-4808-b903-236c00164b43?checkFiles=1&includeAllConcerts=1&includeBandwidths=1&includeChapters=1&includeChildren=1&includeConcerts=1&includeExternalMedia=1&includeExtras=1&includeFields=thumbBlurHash%2CartBlurHash&includeGeolocation=1&includeLoudnessRamps=1&includeMarkers=1&includeOnDeck=1&includePopularLeaves=1&includePreferences=1&includeRelated=1&includeRelatedCount=1&includeReviews=1&includeStations=1', '_parent': <weakref at 0x7ff827918b30; to 'PlexServer' at 0x7ff8283916a0>, '_details_key': '/livetv/sessions/49512cb7-3eb7-4808-b903-236c00164b43?checkFiles=1&includeAllConcerts=1&includeBandwidths=1&includeChapters=1&includeChildren=1&includeConcerts=1&includeExternalMedia=1&includeExtras=1&includeFields=thumbBlurHash%2CartBlurHash&includeGeolocation=1&includeLoudnessRamps=1&includeMarkers=1&includeOnDeck=1&includePopularLeaves=1&includePreferences=1&includeRelated=1&includeRelatedCount=1&includeReviews=1&includeStations=1', '_overwriteNone': True, '_autoReload': True, '_edits': None, 'addedAt': datetime.datetime(2024, 2, 11, 14, 38, 25), 'art': None, 'artBlurHash': None, 'fields': [], 'guid': 'plex://episode/65ba92ecf4dd4f1ef6cba4f3', 'key': '/livetv/sessions/49512cb7-3eb7-4808-b903-236c00164b43', 'lastRatedAt': None, 'lastViewedAt': datetime.datetime(2024, 2, 11, 13, 46, 38), 'librarySectionID': None, 'librarySectionKey': None, 'librarySectionTitle': None, 'listType': 'video', 'ratingKey': 6378, 'summary': '', 'thumb': None, 'thumbBlurHash': None, 'title': 'The NFL Today', 'titleSort': 'NFL Today', 'type': 'episode', 'updatedAt': None, 'userRating': None, 'viewCount': 0, 'playlistItemID': None, 'playQueueItemID': None, 'audienceRating': None, 'audienceRatingImage': None, 'chapters': [], 'chapterSource': None, 'collections': [], 'contentRating': None, 'directors': [], 'duration': None, 'grandparentArt': None, 'grandparentGuid': None, 'grandparentKey': None, 'grandparentRatingKey': None, 'grandparentTheme': None, 'grandparentThumb': 'https://metadata-static.plex.tv/a/gracenote/a15b5f1c562072ab3ada04cb4210a0f9.jpg', 'grandparentTitle': 'The NFL Today', 'guids': [], 'index': 6, 'labels': [], 'markers': [], 'media': [<Media:10108>], 'originallyAvailableAt': None, 'parentGuid': None, 'parentIndex': 2024, 'parentTitle': None, 'parentYear': None, 'producers': [], 'rating': None, 'ratings': [], 'roles': [], 'skipParent': False, 'viewOffset': 0, 'writers': [], 'year': 2024, '_parentKey': None, '_parentRatingKey': None, '_parentThumb': None}
[11-02-2024 02:38:29 PM] [ERROR] [MediaVM] An unexpected error occured in the Plex alert handler
Traceback (most recent call last):
  File "/home/roombobcat/discord-rich-presence-plex/core/plex.py", line 148, in tryHandleAlert
    self.handleAlert(alert)
  File "/home/roombobcat/discord-rich-presence-plex/core/plex.py", line 223, in handleAlert
    stateStrings: list[str] = [] if config["display"]["hideTotalTime"] else [formatSeconds(item.duration / 1000)]
                                                                                           ~~~~~~~~~~~~~~^~~~~~
TypeError: unsupported operand type(s) for /: 'NoneType' and 'int'
[11-02-2024 02:38:29 PM] [DEBUG] [MediaVM] Received alert: {'sessionKey': '57', 'clientIdentifier': 'ps3stxxopqhplajd9bdtvles', 'guid': '', 'ratingKey': '6378', 'url': '', 'key': '/livetv/sessions/49512cb7-3eb7-4808-b903-236c00164b43', 'viewOffset': 1000, 'state': 'playing', 'transcodeSession': 'hqrtwtik5grhs80sezieyjq0'}
[11-02-2024 02:38:29 PM] [DEBUG] [MediaVM] Searching sessions for session key 57
[11-02-2024 02:38:29 PM] [DEBUG] [MediaVM] <EpisodeSession:/livetv/sessions/49512cb7-3eb7-4808-b903-236c00164b43:The-NFL-Today-s2024e06>, Session Key: 57, Usernames: ['roombobcat']
[11-02-2024 02:38:29 PM] [DEBUG] [MediaVM] Session found
[11-02-2024 02:38:29 PM] [DEBUG] [MediaVM] Username 'roombobcat' matches 'roombobcat', continuing
{'_server': <PlexServer:http://plexserverIP>, '_data': <Element 'Video' at 0x7ff827968720>, '_initpath': '/livetv/sessions/49512cb7-3eb7-4808-b903-236c00164b43?checkFiles=1&includeAllConcerts=1&includeBandwidths=1&includeChapters=1&includeChildren=1&includeConcerts=1&includeExternalMedia=1&includeExtras=1&includeFields=thumbBlurHash%2CartBlurHash&includeGeolocation=1&includeLoudnessRamps=1&includeMarkers=1&includeOnDeck=1&includePopularLeaves=1&includePreferences=1&includeRelated=1&includeRelatedCount=1&includeReviews=1&includeStations=1', '_parent': <weakref at 0x7ff8289de1b0; to 'PlexServer' at 0x7ff8283916a0>, '_details_key': '/livetv/sessions/49512cb7-3eb7-4808-b903-236c00164b43?checkFiles=1&includeAllConcerts=1&includeBandwidths=1&includeChapters=1&includeChildren=1&includeConcerts=1&includeExternalMedia=1&includeExtras=1&includeFields=thumbBlurHash%2CartBlurHash&includeGeolocation=1&includeLoudnessRamps=1&includeMarkers=1&includeOnDeck=1&includePopularLeaves=1&includePreferences=1&includeRelated=1&includeRelatedCount=1&includeReviews=1&includeStations=1', '_overwriteNone': True, '_autoReload': True, '_edits': None, 'addedAt': datetime.datetime(2024, 2, 11, 14, 38, 25), 'art': None, 'artBlurHash': None, 'fields': [], 'guid': 'plex://episode/65ba92ecf4dd4f1ef6cba4f3', 'key': '/livetv/sessions/49512cb7-3eb7-4808-b903-236c00164b43', 'lastRatedAt': None, 'lastViewedAt': datetime.datetime(2024, 2, 11, 13, 46, 38), 'librarySectionID': None, 'librarySectionKey': None, 'librarySectionTitle': None, 'listType': 'video', 'ratingKey': 6378, 'summary': '', 'thumb': None, 'thumbBlurHash': None, 'title': 'The NFL Today', 'titleSort': 'NFL Today', 'type': 'episode', 'updatedAt': None, 'userRating': None, 'viewCount': 0, 'playlistItemID': None, 'playQueueItemID': None, 'audienceRating': None, 'audienceRatingImage': None, 'chapters': [], 'chapterSource': None, 'collections': [], 'contentRating': None, 'directors': [], 'duration': None, 'grandparentArt': None, 'grandparentGuid': None, 'grandparentKey': None, 'grandparentRatingKey': None, 'grandparentTheme': None, 'grandparentThumb': 'https://metadata-static.plex.tv/a/gracenote/a15b5f1c562072ab3ada04cb4210a0f9.jpg', 'grandparentTitle': 'The NFL Today', 'guids': [], 'index': 6, 'labels': [], 'markers': [], 'media': [<Media:10108>], 'originallyAvailableAt': None, 'parentGuid': None, 'parentIndex': 2024, 'parentTitle': None, 'parentYear': None, 'producers': [], 'rating': None, 'ratings': [], 'roles': [], 'skipParent': False, 'viewOffset': 0, 'writers': [], 'year': 2024, '_parentKey': None, '_parentRatingKey': None, '_parentThumb': None}
[11-02-2024 02:38:29 PM] [ERROR] [MediaVM] An unexpected error occured in the Plex alert handler
Traceback (most recent call last):
  File "/home/roombobcat/discord-rich-presence-plex/core/plex.py", line 148, in tryHandleAlert
    self.handleAlert(alert)
  File "/home/roombobcat/discord-rich-presence-plex/core/plex.py", line 223, in handleAlert
    stateStrings: list[str] = [] if config["display"]["hideTotalTime"] else [formatSeconds(item.duration / 1000)]
                                                                                           ~~~~~~~~~~~~~~^~~~~~
TypeError: unsupported operand type(s) for /: 'NoneType' and 'int'
[11-02-2024 02:38:31 PM] [DEBUG] [MediaVM] Received alert: {'sessionKey': '57', 'clientIdentifier': 'ps3stxxopqhplajd9bdtvles', 'guid': '', 'ratingKey': '6378', 'url': '', 'key': '/livetv/sessions/49512cb7-3eb7-4808-b903-236c00164b43', 'viewOffset': 3000, 'state': 'playing', 'transcodeSession': 'hqrtwtik5grhs80sezieyjq0'}
[11-02-2024 02:38:31 PM] [DEBUG] [MediaVM] Nothing changed, ignoring
[11-02-2024 02:38:32 PM] [DEBUG] [MediaVM] Received alert: {'sessionKey': '57', 'clientIdentifier': 'ps3stxxopqhplajd9bdtvles', 'guid': '', 'ratingKey': '6378', 'url': '', 'key': '/livetv/sessions/49512cb7-3eb7-4808-b903-236c00164b43', 'viewOffset': 4000, 'state': 'stopped', 'transcodeSession': '49512cb7-3eb7-4808-b903-236c00164b43'}
^C[11-02-2024 02:38:34 PM] [INFO] [MediaVM] Stopped listening for alerts

@phin05
Copy link
Owner

phin05 commented Feb 13, 2024

Can you try v2.7.0 and check if the issue is fixed?

@roombobcat
Copy link

It works!!! Thanks for getting this implemented.

@phin05 phin05 closed this as completed Feb 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants