diff --git a/fly.toml b/fly.toml index 39b8e89..f48e908 100644 --- a/fly.toml +++ b/fly.toml @@ -2,7 +2,7 @@ app = 'plexio' primary_region = 'iad' [build] - image = 'ghcr.io/vanchaxy/plexio:0.1.6' + image = 'ghcr.io/vanchaxy/plexio:0.1.7' [env] CACHE_TYPE = 'redis' diff --git a/frontend/package-lock.json b/frontend/package-lock.json index d6e4777..99023c4 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -1,12 +1,12 @@ { "name": "frontend", - "version": "0.1.5", + "version": "0.1.7", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "frontend", - "version": "0.1.5", + "version": "0.1.7", "dependencies": { "@hookform/resolvers": "^3.3.4", "@radix-ui/react-accordion": "^1.2.1", diff --git a/frontend/package.json b/frontend/package.json index ea53e2f..a559748 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,7 +1,7 @@ { "name": "frontend", "private": true, - "version": "0.1.6", + "version": "0.1.7", "type": "module", "scripts": { "dev": "vite --host", diff --git a/plexio/__init__.py b/plexio/__init__.py index 2fb2513..124e462 100644 --- a/plexio/__init__.py +++ b/plexio/__init__.py @@ -1 +1 @@ -__version__ = '0.1.6' +__version__ = '0.1.7' diff --git a/plexio/plex/media_server_api.py b/plexio/plex/media_server_api.py index 9ead61d..5916f94 100644 --- a/plexio/plex/media_server_api.py +++ b/plexio/plex/media_server_api.py @@ -11,6 +11,38 @@ from plexio.plex.utils import get_json from plexio.settings import settings +SORT_OPTIONS = { + 'Title': 'title', + 'Title (desc)': 'title:desc', + 'Year': 'year', + 'Year (desc)': 'year:desc', + 'Release Date': 'originallyAvailableAt', + 'Release Date (desc)': 'originallyAvailableAt:desc', + 'Critic Rating': 'rating', + 'Critic Rating (desc)': 'rating:desc', + 'Audience Rating': 'audienceRating', + 'Audience Rating (desc)': 'audienceRating:desc', + 'Rating': 'userRating', + 'Rating (desc)': 'userRating:desc', + 'Content Rating': 'contentRating', + 'Content Rating (desc)': 'contentRating:desc', + 'Duration': 'duration', + 'Duration (desc)': 'duration:desc', + 'Progress': 'viewOffset', + 'Progress (desc)': 'viewOffset:desc', + 'Plays': 'viewCount', + 'Plays (desc)': 'viewCount:desc', + 'Date Added': 'addedAt', + 'Date Added (desc)': 'addedAt:desc', + 'Date Viewed': 'lastViewedAt', + 'Date Viewed (desc)': 'lastViewedAt:desc', + 'ResolutionSelected': 'mediaHeight', + 'ResolutionSelected (desc)': 'mediaHeight:desc', + 'Bitrate': 'mediaBitrate', + 'Bitrate (desc)': 'mediaBitrate:desc', + 'Randomly': 'random', +} + async def check_server_connection( *, @@ -41,6 +73,7 @@ async def get_section_media( section_id: str, skip: int, search: str, + sort: str, ) -> list[PlexMediaMeta]: params = { 'includeGuids': 1, @@ -50,6 +83,8 @@ async def get_section_media( } if search: params['title'] = search + if sort: + params['sort'] = SORT_OPTIONS[sort] json = await get_json( client=client, url=url / 'library/sections' / section_id / 'all', diff --git a/plexio/routers/addon.py b/plexio/routers/addon.py index 13a55be..6bdad5d 100644 --- a/plexio/routers/addon.py +++ b/plexio/routers/addon.py @@ -24,6 +24,7 @@ ) from plexio.models.utils import plexio_id_to_guid from plexio.plex.media_server_api import ( + SORT_OPTIONS, get_all_episodes, get_media, get_section_media, @@ -59,6 +60,7 @@ async def get_manifest( extra=[ {'name': 'skip', 'isRequired': False}, {'name': 'search', 'isRequired': False}, + {'name': 'sort', 'options': list(SORT_OPTIONS.keys())}, ], ), ) @@ -96,11 +98,7 @@ async def get_manifest( response_model_exclude_none=True, ) @router.get( - '/{installation_id}/{base64_cfg}/catalog/{stremio_type}/{catalog_id}/skip={skip}.json', - response_model_exclude_none=True, -) -@router.get( - '/{installation_id}/{base64_cfg}/catalog/{stremio_type}/{catalog_id}/search={search}.json', + '/{installation_id}/{base64_cfg}/catalog/{stremio_type}/{catalog_id}/{extra}.json', response_model_exclude_none=True, ) async def get_catalog( @@ -108,16 +106,17 @@ async def get_catalog( configuration: Annotated[AddonConfiguration, Depends(get_addon_configuration)], stremio_type: StremioMediaType, catalog_id: str, - skip: int = 0, - search: str = '', + extra: str = '', ) -> StremioCatalog: + extras = dict(e.split('=') for e in extra.split('&') if e) media = await get_section_media( client=http, url=configuration.discovery_url, token=configuration.access_token, section_id=catalog_id, - search=search, - skip=skip, + search=extras.get('search', ''), + skip=extras.get('skip', 0), + sort=extras.get('sort', 'Title'), ) return StremioCatalog( metas=[m.to_stremio_meta_review(configuration) for m in media],