Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ def detect_color_image(file, thumb_size=150, MSE_cutoff=22, adjust_color_bias=Tr
if adjust_color_bias:
bias = ImageStat.Stat(thumb).mean[:3]
bias = [b - sum(bias) / 3 for b in bias]
for pixel in thumb.getdata():
for pixel in thumb.get_flattened_data():
Copy link

Copilot AI Feb 14, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method get_flattened_data() does not exist in the Pillow (PIL) library. The correct method is getdata(), which returns a sequence of pixel values. This change will cause a runtime AttributeError when the function is called. The original code using thumb.getdata() was correct and should be reverted.

Suggested change
for pixel in thumb.get_flattened_data():
for pixel in thumb.getdata():

Copilot uses AI. Check for mistakes.
mu = sum(pixel) / 3
sse += sum(
(pixel[i] - mu - bias[i]) * (pixel[i] - mu - bias[i]) for i in [0, 1, 2]
Expand Down
19 changes: 12 additions & 7 deletions tests/test_myplex.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import pytest
from plexapi.exceptions import BadRequest, NotFound, Unauthorized
from plexapi.myplex import MyPlexAccount, MyPlexInvite, MyPlexJWTLogin
from plexapi.utils import createMyPlexDevice
from plexapi.myplex import MyPlexAccount, MyPlexInvite, MyPlexPinLogin, MyPlexJWTLogin
from plexapi.utils import generateUUID

from . import conftest as utils
from .payloads import MYPLEX_INVITE
Expand Down Expand Up @@ -371,14 +371,19 @@ def test_myplex_ping(account):

def test_myplex_jwt_login(account, tmp_path, monkeypatch):
# Create a new MyPlexDevice for JWT tests
device = createMyPlexDevice(account=account)
clientIdentifier = generateUUID()
headers = {'X-Plex-Client-Identifier': clientIdentifier}
pinlogin = MyPlexPinLogin(headers=headers)
pinlogin.run()
account.link(pinlogin.pin)
pinlogin.waitForLogin()

privkey = tmp_path / 'private.key'
pubkey = tmp_path / 'public.key'

jwtlogin = MyPlexJWTLogin(
headers={'X-Plex-Client-Identifier': device.clientIdentifier},
token=device.token,
headers=headers,
token=pinlogin.token,
scopes=['username', 'email', 'friendly_name']
)
jwtlogin.generateKeypair(keyfiles=(privkey, pubkey), overwrite=True)
Expand All @@ -391,7 +396,7 @@ def test_myplex_jwt_login(account, tmp_path, monkeypatch):
assert new_account.username == account.username

jwtlogin = MyPlexJWTLogin(
headers={'X-Plex-Client-Identifier': device.clientIdentifier},
headers=headers,
jwtToken=jwtToken,
keypair=(privkey, pubkey),
scopes=['username', 'email', 'friendly_name']
Expand All @@ -411,4 +416,4 @@ def test_myplex_jwt_login(account, tmp_path, monkeypatch):
with pytest.raises(jwt.InvalidSignatureError):
jwtlogin.decodePlexJWT()

device.delete()
account.device(clientId=clientIdentifier).delete()
1 change: 1 addition & 0 deletions tests/test_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ def test_video_Movie_upload_select_remove_subtitle(movie, subtitle):
pass


@pytest.mark.xfail(reason="Plex's OpenSubtitles times out occasionally")
def test_video_Movie_on_demand_subtitles(movie, account):
movie_subtitles = movie.subtitleStreams()
subtitles = movie.searchSubtitles()
Expand Down