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

Episode Sorting Methods Return Empty Results #1493

Open
glenviewjeff opened this issue Jan 7, 2025 · 1 comment
Open

Episode Sorting Methods Return Empty Results #1493

glenviewjeff opened this issue Jan 7, 2025 · 1 comment

Comments

@glenviewjeff
Copy link

Describe the Bug

The episodes() method's sort parameter is not functioning as expected. When using either addedAt:desc or originallyAvailableAt:desc as sort parameters, the method returns an empty list, despite episodes being present and containing valid dates for both fields.

Code Snippets

from plexapi.server import PlexServer

# Connect to Plex server
plex = PlexServer('http://localhost:32400', 'TOKEN')
show = plex.library.section('TV Shows').get('This Week With George Stephanopoulos')

# These both return empty lists
episodes_by_added = show.episodes(sort="addedAt:desc")
episodes_by_air_date = show.episodes(sort="originallyAvailableAt:desc")

# Alternative sort syntax also returns empty list
episodes_alt_sort = show.episodes(sort="-addedAt")

Expected Behavior

  • The episodes() method should return a list of episodes sorted according to the specified sort parameter
  • For addedAt:desc, episodes should be sorted from newest to oldest based on their addition date
  • For originallyAvailableAt:desc, episodes should be sorted from newest to oldest based on their air date

Here's the output showing the issue:

Total number of episodes: 5
Episode list without sorting:
S2024E42 - Added: 2024-10-27 11:07:40, Aired: 2024-10-27 00:00:00
S2024E45 - Added: 2024-11-17 11:07:11, Aired: 2024-11-17 00:00:00
S2024E47 - Added: 2024-12-01 11:05:27, Aired: 2024-12-01 00:00:00
S2024E50 - Added: 2024-12-22 11:10:56, Aired: 2024-12-22 00:00:00
S2025E1 - Added: 2025-01-05 11:06:36, Aired: 2025-01-05 00:00:00

Using addedAt:desc sort:
Number of episodes returned: 0

Using originallyAvailableAt:desc sort:
Number of episodes returned: 0

Testing alternative sort syntax:
Number of episodes returned with alternative sort: 0

Additional Context

No response

Operating System and Version

Windows 11

Plex Media Server Version

1.41.3.9314-a0bfb8370

Python Version

3.11.3

PlexAPI Version

4.16.0

@JonnyWong16
Copy link
Collaborator

JonnyWong16 commented Jan 10, 2025

The episodes() method has never supported sorting.

If you want sorting use library search() instead.

from plexapi.server import PlexServer

# Connect to Plex server
plex = PlexServer('http://localhost:32400', 'TOKEN') 
tvshows = plex.library.section('TV Shows')

episodes_by_added = tvshows.searchEpisodes(
    filters={
        'show.title': 'This Week With George Stephanopoulos'
    },
    sort='addedAt:desc'
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants