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

Update media type attributes #630

Merged
merged 28 commits into from
Dec 31, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
497ceae
Add Style media tag
JonnyWong16 Dec 23, 2020
50633d3
Update audio attributes
JonnyWong16 Dec 23, 2020
1c59429
Update video attributes
JonnyWong16 Dec 23, 2020
cf56d9a
Update photo attributes
JonnyWong16 Dec 24, 2020
99c4475
Update library.Collection attributes
JonnyWong16 Dec 23, 2020
22bfeb0
Update test_audio index is integer
JonnyWong16 Dec 24, 2020
41342b4
Replace use of etag with class
JonnyWong16 Dec 24, 2020
7f1e2ca
Update LibrarySection doc strings
JonnyWong16 Dec 24, 2020
d433c0b
Update locations doc strings for consistency
JonnyWong16 Dec 24, 2020
6f5cae2
More etag relacement with classes
JonnyWong16 Dec 24, 2020
2acb75f
Update all methods used to get an object's children
JonnyWong16 Dec 24, 2020
8206dfb
Fix flake8
JonnyWong16 Dec 24, 2020
3430c24
Make sure key defaults to blank string so fix #50 works
JonnyWong16 Dec 24, 2020
f41be90
More doc string clean up
JonnyWong16 Dec 24, 2020
b7f813a
Add Playlist attributes doc string
JonnyWong16 Dec 24, 2020
949d37b
Update listAttrs doc string
JonnyWong16 Dec 24, 2020
c1a1d16
Add Playlist.item() method
JonnyWong16 Dec 24, 2020
33b725d
Update tests
JonnyWong16 Dec 24, 2020
5df7572
Fix flake8
JonnyWong16 Dec 24, 2020
9916297
Fix tests
JonnyWong16 Dec 24, 2020
1ce9710
Fix typo in library totalSize doc string
JonnyWong16 Dec 24, 2020
478bf9e
Fix video season index test
JonnyWong16 Dec 24, 2020
2765bee
Fix audio tracks key
JonnyWong16 Dec 24, 2020
810c556
Fix playlist tests
JonnyWong16 Dec 24, 2020
5b78f6b
Merge branch 'master' into feature/media_attributes
JonnyWong16 Dec 30, 2020
f2e7e89
Fix a test in navigation
Hellowlol Dec 30, 2020
3526b8c
Allow specials.
Hellowlol Dec 30, 2020
ebdaede
Fix getting season=0 or episode=0
JonnyWong16 Dec 30, 2020
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
9 changes: 5 additions & 4 deletions plexapi/video.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
from urllib.parse import quote_plus, urlencode

from plexapi import media, utils, settings, library
from plexapi import library, media, settings, utils
from plexapi.base import Playable, PlexPartialObject
from plexapi.exceptions import BadRequest, NotFound

Expand Down Expand Up @@ -500,10 +500,11 @@ def season(self, title=None, season=None):
:exc:`~plexapi.exceptions.BadRequest`: If title or season parameter is missing.
"""
key = '/library/metadata/%s/children' % self.ratingKey
if title:
if title and not isinstance(title, int):
return self.fetchItem(key, Season, title__iexact=title)
elif season:
return self.fetchItem(key, Season, index=season)
elif season or isinstance(title, int):
JonnyWong16 marked this conversation as resolved.
Show resolved Hide resolved
idx = season or title
return self.fetchItem(key, Season, index=idx)
raise BadRequest('Missing argument: title or season is required')

def seasons(self, **kwargs):
Expand Down
59 changes: 29 additions & 30 deletions tests/test_myplex.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,20 +129,19 @@ def test_myplex_inviteFriend_remove(account, plex, mocker):
secs = plex.library.sections()

ids = account._getSectionIds(plex.machineIdentifier, secs)
with mocker.patch.object(account, "_getSectionIds", return_value=ids):
with utils.callable_http_patch():

account.inviteFriend(
inv_user,
plex,
secs,
allowSync=True,
allowCameraUpload=True,
allowChannels=False,
filterMovies=vid_filter,
filterTelevision=vid_filter,
filterMusic={"label": ["foo"]},
)
mocker.patch.object(account, "_getSectionIds", return_value=ids)
with utils.callable_http_patch():
account.inviteFriend(
inv_user,
plex,
secs,
allowSync=True,
allowCameraUpload=True,
allowChannels=False,
filterMovies=vid_filter,
filterTelevision=vid_filter,
filterMusic={"label": ["foo"]},
)

assert inv_user not in [u.title for u in account.users()]

Expand All @@ -157,22 +156,22 @@ def test_myplex_updateFriend(account, plex, mocker, shared_username):
user = account.user(shared_username)

ids = account._getSectionIds(plex.machineIdentifier, secs)
with mocker.patch.object(account, "_getSectionIds", return_value=ids):
with mocker.patch.object(account, "user", return_value=user):
with utils.callable_http_patch():

account.updateFriend(
shared_username,
plex,
secs,
allowSync=True,
removeSections=True,
allowCameraUpload=True,
allowChannels=False,
filterMovies=vid_filter,
filterTelevision=vid_filter,
filterMusic={"label": ["foo"]},
)
mocker.patch.object(account, "_getSectionIds", return_value=ids)
mocker.patch.object(account, "user", return_value=user)
with utils.callable_http_patch():

account.updateFriend(
shared_username,
plex,
secs,
allowSync=True,
removeSections=True,
allowCameraUpload=True,
allowChannels=False,
filterMovies=vid_filter,
filterTelevision=vid_filter,
filterMusic={"label": ["foo"]},
)


def test_myplex_createExistingUser(account, plex, shared_username):
Expand Down
1 change: 1 addition & 0 deletions tests/test_navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ def test_navigate_around_show(account, plex):
episode = show.episode("Pilot")
assert "Season 1" in [s.title for s in seasons], "Unable to list season:"
assert "Pilot" in [e.title for e in episodes], "Unable to list episode:"
assert show.season(season=1) == season
assert show.season(1) == season
assert show.episode("Pilot") == episode, "Unable to get show episode:"
assert season.episode("Pilot") == episode, "Unable to get season episode:"
Expand Down