l3uddz / cloudplow

Automatic rclone remote uploader, with support for multiple remote/folder pairings. UnionFS Cleaner functionality: Deletion of UnionFS whiteout files and their corresponding files on rclone remotes. Automatic remote syncer: Sync between different remotes via a Scaleway server instance, that is created and destroyed at every sync.
GNU General Public License v3.0
338 stars 48 forks source link

Plex streams not being counted for throttling #86

Closed matchai closed 2 years ago

matchai commented 4 years ago

Describe the bug Cloudplow always logs that there are "0 playing stream(s)" despite there being actively playing streams.

This occurs despite the logs saying that the "Plex Media Server URL + Token were validated":

2020-06-08 12:56:08,950 - INFO       - cloudplow            - do_plex_monitor                - Plex Media Server URL + Token were validated. Sleeping for 15 seconds before checking Rclone RC URL.
2020-06-08 12:56:23,973 - INFO       - cloudplow            - do_plex_monitor                - Rclone RC URL was validated. Stream monitoring for Plex Media Server will now begin.

To Reproduce Steps to reproduce the behavior:

  1. Configure Cloudplow to run automatically
  2. Set plex.max_streams_before_throttle to 1
  3. Restart Cloudplow service and watch logs for the following message:
    2020-06-09 12:50:16,130 - INFO       - cloudplow            - do_plex_monitor                - There was 0 playing stream(s) on Plex Media Server it was already throttled to 1000M. Throttling will continue.
  4. Start playing a stream on Plex
  5. See the same messages continue to be logged

Expected behavior A clear and concise description of what you expected to happen.

Throttling begins to kick in at the increased thresholds, matching the number of Plex streams playing.

Logs

Despite there being active "playing" streams, they aren't being accounted for by Cloudplow:

2020-06-09 23:38:02,183 - DEBUG      - plex                 - get_streams                    - Server responded with status_code=200, content: b'{"MediaContainer":{"size":3,"Metadata":[{"addedAt":"1591490585","art":"/library/metadata/1205/art/1591664610","chapterSource":"media","contentRating":"TV-MA","duration":"1802600","grandparentArt":"/library/metadata/1205/art/1591664610","grandparentGuid":"com.plexapp.agents.thetvdb://76203?lang=en","grandparentRatingKey":"1205","grandparentTheme":"/library/metadata/1205/theme/1591664610","grandparentThumb":"/library/metadata/1205/thumb/1591664610","grandparentTitle":"Curb Your Enthusiasm","guid":"com.plexapp.agents.thetvdb://76203/2/3?lang=en","index":"3","key":"/library/metadata/1226","librarySectionID":"2","originallyAvailableAt":"2001-10-07","parentGuid":"com.plexapp.agents.thetvdb://76203/2?lang=en","parentIndex":"2","parentRatingKey":"1218","parentThumb":"/library/metadata/1218/thumb/1591664610","parentTitle":"Season 2","rating":"8.0","ratingKey":"1226","sessionKey":"47","summary":"When Larry and Cheryl attend the premiere of a movie written by a handicapped friend, Cliff Cobb, Larry offends a Jewish neighbor, alienates Cliff (as well as the memory of his salad-inventing grandfather) and sends misguided romantic overtures to Cliff\\'s wife, Shelly. Later, the Davids experience the \\"            "trick\\"            " side of Halloween when Larry refuses to give candy to two uncostumed teenagers. Having failed to get a bracelet for his wife on her birthday, Larry makes amends with the perfect gift on a romantic morning, but then Jeff arrives to play a round of golf. In the end, Larry gets revenge on a jewish neighbor and his teenage daughters, by arriving at his home with the orchestra that he used for Cheryl\\'s birthday, as they played the tune that offended this neighbor.","thumb":"/library/metadata/1226/thumb/1591664608","title":"Trick or Treat","type":"episode","updatedAt":"1591664608","viewOffset":"241000","year":"2001","Media":[{"aspectRatio":"1.78","audioChannels":"2","audioCodec":"eac3","bitrate":"13876","container":"mkv","duration":"1802600","height":"1080","id":"1231","videoCodec":"h264","videoFrameRate":"NTSC","videoProfile":"high","videoResolution":"1080","width":"1920","selected":true,"Part":[{"container":"mkv","duration":"1802600","file":"/data/TV/Curb Your Enthusiasm (1999)/Season 02/Curb Your Enthusiasm - S02E03 [WEBDL-1080p H264 EAC3 2.0]-AJP69.mkv","id":"1924","key":"/library/parts/1924/1504006642/file.mkv","size":"3126534806","videoProfile":"high","decision":"directplay","selected":true,"Stream":[{"bitDepth":"8","bitrate":"13876","chromaLocation":"left","chromaSubsampling":"4:2:0","codec":"h264","codedHeight":"1088","codedWidth":"1920","colorPrimaries":"bt709","colorRange":"tv","colorSpace":"bt709","colorTrc":"bt709","default":"1","displayTitle":"1080p (H.264)","frameRate":"29.970","hasScalingMatrix":"0","height":"1080","id":"7530","index":"0","level":"40","profile":"high","refFrames":"4","scanType":"progressive","streamType":"1","width":"1920","location":"direct"},{"audioChannelLayout":"stereo","bitrate":"224","channels":"2","codec":"eac3","default":"1","displayTitle":"English (EAC3 Stereo)","id":"7531","index":"1","language":"English","languageCode":"eng","samplingRate":"48000","selected":"1","streamType":"2","location":"direct"}]}]}],"Writer":[{"id":"1853","tag":"Larry David"}],"User":{"id":"","thumb":"","title":""},"Player":{"address":"","device":"","machineIdentifier":"","model":"standalone","platform":"windows","platformVersion":"10.0.18363","product":"Plex for Windows","remotePublicAddress":"","state":"paused","title":"","vendor":"","version":"1.12.1.1253-c29aa096","local":true,"relayed":false,"secure":false,"userID":0},"Session":{"id":"49w8z92rds8j8ptpugu3jcr6","bandwidth":29140,"location":"lan"}},{"addedAt":"1590690937","art":"/library/metadata/895/art/1590762184","chapterSource":"media","contentRating":"TV-14","duration":"1435031","grandparentArt":"/library/metadata/895/art/1590762184","grandparentGuid":"com.plexapp.agents.thetvdb://267440?lang=en","grandparentKey":"/library/metadata/895","grandparentRatingKey":"895","grandparentTheme":"/library/metadata/895/theme/1590762184","grandparentThumb":"/library/metadata/895/thumb/1590762184","grandparentTitle":"Attack on Titan","guid":"com.plexapp.agents.thetvdb://267440/3/3?lang=en","index":"3","key":"/library/metadata/899","lastViewedAt":"1591760087","librarySectionID":"2","librarySectionKey":"/library/sections/2","librarySectionTitle":"TV Shows","originallyAvailableAt":"2018-08-06","parentGuid":"com.plexapp.agents.thetvdb://267440/3?lang=en","parentIndex":"3","parentKey":"/library/metadata/896","parentRatingKey":"896","parentThumb":"/library/metadata/896/thumb/1590762184","parentTitle":"Season 3","ratingKey":"899","sessionKey":"53","summary":"Historia and Erwin look back on their past, revealing a shady government with a hidden agenda and inspiration for an uprising.","thumb":"/library/metadata/899/thumb/1590762183","title":"Old Story","type":"episode","updatedAt":"1590762183","viewOffset":"90000","year":"2018","Media":[{"id":"861","videoProfile":"high 10","audioChannels":"2","audioCodec":"aac","bitrate":"38890","container":"mp4","duration":"1435031","height":"1080","optimizedForStreaming":"1","protocol":"dash","videoCodec":"h264","videoFrameRate":"24p","videoResolution":"1080p","width":"1920","selected":true,"Part":[{"id":"1533","videoProfile":"high 10","bitrate":"38890","container":"mp4","duration":"1435031","height":"1080","optimizedForStreaming":"1","protocol":"dash","width":"1920","decision":"transcode","selected":true,"Stream":[{"bitrate":"38634","chromaLocation":"left","codec":"h264","codedHeight":"1088","codedWidth":"1920","colorPrimaries":"bt709","colorTrc":"bt709","default":"1","displayTitle":"1080p (H.264 High 10)","frameRate":"23.975999999999999","height":"1080","id":"6227","language":"\\xe6\\x97\\xa5\\xe6\\x9c\\xac\\xe8\\xaa\\x9e","languageCode":"jpn","streamType":"1","width":"1920","decision":"transcode","location":"segments-video"},{"bitrate":"256","bitrateMode":"cbr","channels":"2","codec":"aac","default":"1","displayTitle":"\\xe6\\x97\\xa5\\xe6\\x9c\\xac\\xe8\\xaa\\x9e (FLAC Stereo)","id":"6228","language":"\\xe6\\x97\\xa5\\xe6\\x9c\\xac\\xe8\\xaa\\x9e","languageCode":"jpn","selected":"1","streamType":"2","decision":"transcode","location":"segments-audio"},{"burn":"1","default":"1","displayTitle":"English (ASS)","id":"6229","language":"English","languageCode":"eng","selected":"1","streamType":"3","decision":"burn","location":"segments-video"}]}]}],"Writer":[{"filter":"writer=1200","id":"1200","tag":"Hiroyuki Morita"},{"filter":"writer=1198","id":"1198","tag":"Yasuko Kobayashi"}],"User":{"id":"","thumb":"","title":""},"Player":{"address":"","device":"OSX","machineIdentifier":"","model":"bundled","platform":"Chrome","platformVersion":"81.0","product":"Plex Web","profile":"Web","remotePublicAddress":"135.19.62.102","state":"playing","title":"Chrome","vendor":"","version":"4.30.2","local":true,"relayed":false,"secure":false,"userID":0},"Session":{"id":"ddky85qs12tcs7c3qvf5afva","bandwidth":40835,"location":"lan"}},{"addedAt":"1590690937","art":"/library/metadata/895/art/1590762184","chapterSource":"media","contentRating":"TV-14","duration":"1435031","grandparentArt":"/library/metadata/895/art/1590762184","grandparentGuid":"com.plexapp.agents.thetvdb://267440?lang=en","grandparentKey":"/library/metadata/895","grandparentRatingKey":"895","grandparentTheme":"/library/metadata/895/theme/1590762184","grandparentThumb":"/library/metadata/895/thumb/1590762184","grandparentTitle":"Attack on Titan","guid":"com.plexapp.agents.thetvdb://267440/3/3?lang=en","index":"3","key":"/library/metadata/899","lastViewedAt":"1591760113","librarySectionID":"2","librarySectionKey":"/library/sections/2","librarySectionTitle":"TV Shows","originallyAvailableAt":"2018-08-06","parentGuid":"com.plexapp.agents.thetvdb://267440/3?lang=en","parentIndex":"3","parentKey":"/library/metadata/896","parentRatingKey":"896","parentThumb":"/library/metadata/896/thumb/1590762184","parentTitle":"Season 3","ratingKey":"899","sessionKey":"55","summary":"Historia and Erwin look back on their past, revealing a shady government with a hidden agenda and inspiration for an uprising.","thumb":"/library/metadata/899/thumb/1590762183","title":"Old Story","type":"episode","updatedAt":"1590762183","viewOffset":"90000","year":"2018","Media":[{"id":"861","videoProfile":"high 10","audioChannels":"2","audioCodec":"aac","bitrate":"9429","container":"mp4","duration":"1435031","height":"1080","optimizedForStreaming":"1","protocol":"dash","videoCodec":"h264","videoFrameRate":"24p","videoResolution":"1080p","width":"1920","selected":true,"Part":[{"id":"1533","videoProfile":"high 10","bitrate":"9429","container":"mp4","duration":"1435031","height":"1080","optimizedForStreaming":"1","protocol":"dash","width":"1920","decision":"transcode","selected":true,"Stream":[{"bitrate":"9299","chromaLocation":"left","codec":"h264","codedHeight":"1088","codedWidth":"1920","colorPrimaries":"bt709","colorTrc":"bt709","default":"1","displayTitle":"1080p (H.264 High 10)","frameRate":"23.975999999999999","height":"1080","id":"6227","language":"\\xe6\\x97\\xa5\\xe6\\x9c\\xac\\xe8\\xaa\\x9e","languageCode":"jpn","streamType":"1","width":"1920","decision":"transcode","location":"segments-video"},{"bitrate":"130","bitrateMode":"cbr","channels":"2","codec":"aac","default":"1","displayTitle":"\\xe6\\x97\\xa5\\xe6\\x9c\\xac\\xe8\\xaa\\x9e (FLAC Stereo)","id":"6228","language":"\\xe6\\x97\\xa5\\xe6\\x9c\\xac\\xe8\\xaa\\x9e","languageCode":"jpn","selected":"1","streamType":"2","decision":"transcode","location":"segments-audio"},{"burn":"1","default":"1","displayTitle":"English (ASS)","id":"6229","language":"English","languageCode":"eng","selected":"1","streamType":"3","decision":"burn","location":"segments-video"}]}]}],"Writer":[{"filter":"writer=1200","id":"1200","tag":"Hiroyuki Morita"},{"filter":"writer=1198","id":"1198","tag":"Yasuko Kobayashi"}],"User":{"id":"","thumb":"","title":""},"Player":{"address":"","device":"OSX","machineIdentifier":"","model":"bundled","platform":"Chrome","platformVersion":"81.0","product":"Plex Web","profile":"Web","remotePublicAddress":"","state":"paused","title":"Chrome","vendor":"","version":"4.30.2","local":true,"relayed":false,"secure":false,"userID":0},"Session":{"id":"pc7odepci5c2nl3h55fcle1c","bandwidth":9901,"location":"lan"},"TranscodeSession":{"key":"/transcode/sessions/gxypyuhjz9lw8evewm207opj","throttled":false,"complete":false,"progress":"38.299999237060547","size":-22,"speed":"3.9000000953674316","duration":1435031,"remaining":226,"context":"streaming","sourceVideoCodec":"h264","sourceAudioCodec":"flac","videoDecision":"transcode","audioDecision":"transcode","subtitleDecision":"burn","protocol":"dash","container":"mp4","videoCodec":"h264","audioCodec":"aac","audioChannels":2,"transcodeHwRequested":false,"timeStamp":"1591760115.6037188","maxOffsetAvailable":"549.00734067400708","minOffsetAvailable":"95.970970153808594"}}]}}'
2020-06-09 23:38:02,186 - INFO       - cloudplow            - do_plex_monitor                - There was 0 playing stream(s) on Plex Media Server it was already throttled to 1000M. Throttling will continue.

System Information

matchai commented 4 years ago

It looks like this is certainly caused by #76. Unfortunately, the disk I/O caused by cloudplow uploads is directly affecting my ability to run Plex streams. I would love to see the ability to configure the local check.

saltydk commented 2 years ago

Merged.