├── .editorconfig ├── .gitattributes ├── .github ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── PULL_REQUEST_TEMPLATE.md ├── SECURITY.md ├── dependabot.yml └── workflows │ ├── codeql-analysis.yml │ ├── dotnet.yml │ ├── pre-release.yml │ └── release.yml ├── .gitignore ├── .idea └── .idea.Plex.Api │ └── .idea │ ├── .gitignore │ ├── .name │ ├── encodings.xml │ ├── indexLayout.xml │ └── vcs.xml ├── Images ├── Banner.png ├── Hero.png └── Icon.png ├── Key.snk ├── LICENSE.md ├── Plex.Api.sln ├── README.md ├── SECURITY.md ├── Samples ├── .DS_Store ├── PlexBlazorServerOAuthExample │ ├── .gitignore │ ├── App.razor │ ├── Controllers │ │ └── PlexLoginController.cs │ ├── Pages │ │ ├── Error.cshtml │ │ ├── Error.cshtml.cs │ │ ├── Index.razor │ │ └── _Host.cshtml │ ├── PlexBlazorServerOAuthExample.csproj │ ├── Program.cs │ ├── Properties │ │ └── launchSettings.json │ ├── Services │ │ └── Plex │ │ │ └── OAuthService.cs │ ├── Shared │ │ ├── MainLayout.razor │ │ ├── MainLayout.razor.css │ │ ├── NavMenu.razor │ │ └── NavMenu.razor.css │ ├── Startup.cs │ ├── _Imports.razor │ ├── appsettings.Development.json │ ├── appsettings.json │ └── wwwroot │ │ └── css │ │ ├── bootstrap │ │ ├── bootstrap.min.css │ │ └── bootstrap.min.css.map │ │ ├── open-iconic │ │ ├── FONT-LICENSE │ │ ├── ICON-LICENSE │ │ ├── README.md │ │ └── font │ │ │ ├── css │ │ │ └── open-iconic-bootstrap.min.css │ │ │ └── fonts │ │ │ ├── open-iconic.eot │ │ │ ├── open-iconic.otf │ │ │ ├── open-iconic.svg │ │ │ ├── open-iconic.ttf │ │ │ └── open-iconic.woff │ │ └── site.css └── PlexPlaylistSplitter │ ├── .editorconfig │ ├── PlexPlaylistSplitter.csproj │ ├── Program.cs │ ├── Properties │ └── launchSettings.json │ ├── SplitOptions.cs │ ├── Worker.cs │ ├── appsettings.Development.json │ └── appsettings.json ├── Source ├── Plex.Library │ ├── ApiModels │ │ ├── Accounts │ │ │ └── PlexAccount.cs │ │ ├── Libraries │ │ │ ├── Filters │ │ │ │ ├── FilterFieldModel.cs │ │ │ │ ├── FilterModel.cs │ │ │ │ └── InvalidOperatorException.cs │ │ │ ├── LibraryBase.cs │ │ │ ├── LibraryFilterMapper.cs │ │ │ ├── MovieLibrary.cs │ │ │ ├── MusicLibrary.cs │ │ │ ├── PhotoLibrary.cs │ │ │ └── ShowLibrary.cs │ │ └── Servers │ │ │ └── Server.cs │ ├── Automapper │ │ ├── CollectionModelMapper.cs │ │ ├── LibraryModelMapper.cs │ │ ├── ObjectMapper.cs │ │ ├── PlexAccountModelMapper.cs │ │ └── PlexServerModelMapper.cs │ ├── Factories │ │ ├── IPlexFactory.cs │ │ └── PlexFactory.cs │ └── Plex.Library.csproj └── Plex.ServerApi │ ├── Api │ ├── ApiRequest.cs │ ├── ApiRequestBuilder.cs │ ├── ApiService.cs │ ├── IApiService.cs │ ├── IPlexRequestsHttpClient.cs │ └── PlexRequestsHttpClient.cs │ ├── ClientOptions.cs │ ├── Clients │ ├── ClientUtilities.cs │ ├── Interfaces │ │ ├── IPlexAccountClient.cs │ │ ├── IPlexLibraryClient.cs │ │ └── IPlexServerClient.cs │ ├── PlexAccountClient.cs │ ├── PlexLibraryClient.cs │ └── PlexServerClient.cs │ ├── Enums │ ├── MetadataType.cs │ ├── SearchType.cs │ └── SessionMediaType.cs │ ├── Helpers │ ├── BooleanValueConverter.cs │ ├── DoubleValueConverter.cs │ ├── FilterHelper.cs │ ├── IntValueConverter.cs │ ├── LongValueConverter.cs │ ├── StringHelpers.cs │ └── UriHelper.cs │ ├── Models │ ├── PlexAdd │ │ ├── AddUserError.cs │ │ ├── PlexAdd.cs │ │ ├── PlexAddWrapper.cs │ │ ├── Section.cs │ │ └── SharedServer.cs │ ├── User.cs │ └── UserRole.cs │ ├── Plex.ServerApi.csproj │ └── PlexModels │ ├── Account │ ├── AccountServer.cs │ ├── AccountServerContainer.cs │ ├── Announcements │ │ ├── Announcement.cs │ │ └── AnnouncementContainer.cs │ ├── Device.cs │ ├── Discover │ │ ├── DiscoverSearchContainer.cs │ │ ├── DiscoverSearchResult.cs │ │ └── DiscoverSearchResultMetadata.cs │ ├── Friend.cs │ ├── PlexAccount.cs │ ├── Profile.cs │ ├── Resources │ │ ├── Resource.cs │ │ └── ResourceConnection.cs │ ├── Service.cs │ ├── SharedItems │ │ ├── SharedItem.cs │ │ ├── SharedItemAddModel.cs │ │ ├── SharedItemContainer.cs │ │ └── SharedItemOwner.cs │ ├── Subscription.cs │ ├── User │ │ ├── HomeUser.cs │ │ ├── PlexUserRequest.cs │ │ ├── UserContainer.cs │ │ └── UserSharedServer.cs │ └── Watchlist │ │ ├── WatchlistContainer.cs │ │ ├── WatchlistDirectory.cs │ │ ├── WatchlistFilter.cs │ │ ├── WatchlistMetadata.cs │ │ ├── WatchlistMetadataContainer.cs │ │ ├── WatchlistMetadataImage.cs │ │ ├── WatchlistSort.cs │ │ ├── WatchlistType.cs │ │ ├── WatchlistUserState.cs │ │ └── WatchlistUserStateContainer.cs │ ├── Audio │ ├── Album.cs │ ├── Artist.cs │ └── AudioBase.cs │ ├── Folders │ ├── Folder.cs │ └── FolderContainer.cs │ ├── GenericWrapper.cs │ ├── Hubs │ ├── Hub.cs │ └── HubMediaContainer.cs │ ├── Library │ ├── Collections │ │ ├── Collection.cs │ │ ├── CollectionContainer.cs │ │ └── CollectionModel.cs │ ├── Library.cs │ ├── LibraryContainer.cs │ ├── LibraryFilter.cs │ ├── LibraryLocation.cs │ ├── Operator.cs │ └── Search │ │ ├── FieldMeta.cs │ │ ├── FieldMetaType.cs │ │ ├── FieldType.cs │ │ ├── Filter.cs │ │ ├── FilterContainer.cs │ │ ├── FilterField.cs │ │ ├── FilterFieldContainer.cs │ │ ├── FilterOperator.cs │ │ ├── FilterRequest.cs │ │ ├── FilterSort.cs │ │ ├── FilterValue.cs │ │ └── FilterValueContainer.cs │ ├── Media │ ├── Chapter.cs │ ├── Collection.cs │ ├── Country.cs │ ├── Director.cs │ ├── Extras.cs │ ├── Genre.cs │ ├── MediaContainer.cs │ ├── MediaField.cs │ ├── MediaFieldType.cs │ ├── MediaFilter.cs │ ├── MediaMeta.cs │ ├── MediaOperator.cs │ ├── MediaPart.cs │ ├── MediaRole.cs │ ├── MediaSort.cs │ ├── MediaType.cs │ ├── Medium.cs │ ├── Metadata.cs │ ├── MetadataField.cs │ ├── Preference.cs │ ├── Producer.cs │ ├── Review.cs │ ├── ScrapingId.cs │ ├── Setting.cs │ ├── Similar.cs │ ├── Stream.cs │ └── Writer.cs │ ├── OAuth │ ├── Location.cs │ └── OAuthPin.cs │ ├── PlayQueues │ └── PlayQueueContainer.cs │ ├── Providers │ ├── Feature.cs │ ├── FeatureDirectory.cs │ ├── FeatureDirectoryPivot.cs │ ├── Provider.cs │ └── ProviderContainer.cs │ └── Server │ ├── Activities │ ├── Activity.cs │ ├── ActivityContainer.cs │ └── ActivityContext.cs │ ├── Clients │ ├── ClientMediaContainer.cs │ └── ClientServer.cs │ ├── Devices │ ├── Device.cs │ └── DeviceContainer.cs │ ├── History │ ├── HistoryMediaContainer.cs │ └── HistoryMetadata.cs │ ├── Playlists │ ├── Medium.cs │ ├── Metadata.cs │ ├── Part.cs │ ├── Player.cs │ ├── PlaylistContainer.cs │ ├── Session.cs │ ├── Stream.cs │ ├── TranscodeSession.cs │ ├── User.cs │ └── Writer.cs │ ├── PlexServer.cs │ ├── PlexServerContainer.cs │ ├── PlexServerDirectory.cs │ ├── Sessions │ ├── Medium.cs │ ├── Part.cs │ ├── Player.cs │ ├── Session.cs │ ├── SessionContainer.cs │ ├── SessionMetadata.cs │ ├── Stream.cs │ ├── TranscodeSession.cs │ ├── User.cs │ └── Writer.cs │ ├── Statistics │ ├── StatisticContainer.cs │ └── StatisticsResource.cs │ ├── Transcoders │ ├── TranscodeContainer.cs │ └── TranscodeSession.cs │ ├── TransientTokenContainer.cs │ └── Updates │ ├── Release.cs │ └── UpdateContainer.cs ├── Tests ├── .editorconfig ├── Plex.Library.Test │ ├── Plex.Library.Test.csproj │ ├── PlexFixture.cs │ ├── TestConfiguration.cs │ └── Tests │ │ ├── AccountTest.cs │ │ ├── LibraryTest.cs │ │ └── ServerTest.cs ├── Plex.ServerApi.Test │ ├── Plex.ServerApi.Test.csproj │ ├── PlexFixture.cs │ ├── TestConfiguration.cs │ └── Tests │ │ ├── AccountTest.cs │ │ ├── LibraryBaseTest.cs │ │ ├── MediaTest.cs │ │ ├── MovieLibraryTest.cs │ │ ├── MusicLibraryTest.cs │ │ ├── PhotoLibraryTest.cs │ │ ├── ServerTest.cs │ │ └── TvLibraryTest.cs └── Plex.WebApi.IntegrationTest │ ├── Constants │ └── GraphQlQuery.cs │ ├── CustomWebApplicationFactory.cs │ ├── HealthCheckTest.cs │ ├── HttpClientExtensions.cs │ ├── Models │ ├── GraphQLError.cs │ ├── GraphQLErrorExtensions.cs │ ├── GraphQLErrorLocation.cs │ └── GraphQLResponse.cs │ ├── Plex.WebApi.IntegrationTest.csproj │ ├── Properties │ └── launchSettings.json │ ├── QueryTest.cs │ └── xunit.runner.json └── global.json /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################### 2 | # Git Line Endings # 3 | ############################### 4 | 5 | # Set default behavior to automatically normalize line endings. 6 | * text=auto 7 | 8 | # Force batch scripts to always use CRLF line endings so that if a repo is accessed 9 | # in Windows via a file share from Linux, the scripts will work. 10 | *.{cmd,[cC][mM][dD]} text eol=crlf 11 | *.{bat,[bB][aA][tT]} text eol=crlf 12 | 13 | # Force bash scripts to always use LF line endings so that if a repo is accessed 14 | # in Unix via a file share from Windows, the scripts will work. 15 | *.sh text eol=lf 16 | 17 | ############################### 18 | # Git Large File System (LFS) # 19 | ############################### 20 | 21 | -------------------------------------------------------------------------------- /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # All contributions, however small are valued! 2 | 3 | # Steps to contribute 4 | 5 | If you want to make a small change, go ahead and raise a pull request, otherwise follow these steps: 6 | 7 | 1. View the [Issues](https://github.com/Username/Project/issues) page to see a To-Do list of things to be implemented. 8 | 2. Raise an issue or comment on an existing issue with what you want to contribute if one does not already exist. 9 | 3. When you get the go ahead, follow the coding guidelines and raise a pull request. 10 | 4. Include a link to the issue in your pull request. 11 | 12 | # Coding Guidelines 13 | 14 | - Projects use StyleCop and .editorconfig to produce style warnings. Please fix all warnings in any code you submit. 15 | - Write unit tests for any code written. 16 | 17 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 7 | -------------------------------------------------------------------------------- /.github/SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | This project supports only the latest version with security updates. However, we'll do our best to help and answer questions about older versions. 6 | 7 | ## Reporting a Vulnerability 8 | 9 | Contact [kevin@kineticmedia.net|@jensenkd] to report a security vulnerability. You will be thanked! 10 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "nuget" # See documentation for possible values 9 | directory: "/" # Location of package manifests 10 | schedule: 11 | interval: "daily" 12 | -------------------------------------------------------------------------------- /.github/workflows/dotnet.yml: -------------------------------------------------------------------------------- 1 | name: ".NET Build" 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v2 16 | - name: Setup .NET 17 | uses: actions/setup-dotnet@v1 18 | with: 19 | dotnet-version: 7.0.400 20 | - name: Restore dependencies 21 | run: dotnet restore 22 | - name: Build 23 | run: dotnet build --no-restore 24 | -------------------------------------------------------------------------------- /.github/workflows/pre-release.yml: -------------------------------------------------------------------------------- 1 | name: "Nuget Pre-Release" 2 | 3 | on: 4 | push: 5 | tags: 6 | - "v[0-9]+.[0-9]+.[0-9]+-preview[0-9][0-9][0-9]" 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | timeout-minutes: 15 11 | steps: 12 | - name: Checkout 13 | uses: actions/checkout@v2 14 | - name: Set VERSION variable from tag 15 | run: echo "VERSION=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_ENV 16 | - name: Pack 17 | run: dotnet pack ./Source/Plex.Library/Plex.Library.csproj --configuration Release /p:Version=${VERSION} --output . 18 | - name: Push to Github Packages 19 | run: dotnet nuget push Plex.Api.${VERSION}.nupkg -s https://nuget.pkg.github.com/jensenkd/index.json -k ${GITHUB_TOKEN} 20 | - name: Push to Nuget.Org 21 | run: dotnet nuget push Plex.Api.${VERSION}.nupkg -s https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_KEY }} 22 | env: 23 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 24 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: "Nuget Release" 2 | 3 | on: 4 | push: 5 | tags: 6 | - "v[0-9]+.[0-9]+.[0-9]+" 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | timeout-minutes: 15 11 | steps: 12 | - name: Checkout 13 | uses: actions/checkout@v2 14 | - name: Verify commit exists in origin/master 15 | run: | 16 | git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/* 17 | git branch --remote --contains | grep origin/master 18 | - name: Set VERSION variable from tag 19 | run: echo "VERSION=${GITHUB_REF/refs\/tags\/v/}" >> $GITHUB_ENV 20 | - name: Build 21 | run: dotnet build --configuration Release /p:Version=${VERSION} 22 | - name: Pack 23 | run: dotnet pack --configuration Release /p:Version=${VERSION} --no-build --output . 24 | - name: Push to Github Packages 25 | run: dotnet nuget push Plex.Api.${VERSION}.nupkg -s https://nuget.pkg.github.com/jensenkd/index.json -k ${GITHUB_TOKEN} 26 | - name: Push to Nuget.Org 27 | run: dotnet nuget push Plex.Api.${VERSION}.nupkg -s https://api.nuget.org/v3/index.json -k ${{ secrets.NUGET_KEY }} 28 | env: 29 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 30 | -------------------------------------------------------------------------------- /.idea/.idea.Plex.Api/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Rider ignored files 5 | /.idea.Plex.Api.iml 6 | /modules.xml 7 | /projectSettingsUpdater.xml 8 | /contentModel.xml 9 | # Datasource local storage ignored files 10 | /dataSources/ 11 | /dataSources.local.xml 12 | # Editor-based HTTP Client requests 13 | /httpRequests/ 14 | -------------------------------------------------------------------------------- /.idea/.idea.Plex.Api/.idea/.name: -------------------------------------------------------------------------------- 1 | Plex.Api -------------------------------------------------------------------------------- /.idea/.idea.Plex.Api/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /.idea/.idea.Plex.Api/.idea/indexLayout.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/.idea.Plex.Api/.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Images/Banner.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jensenkd/plex-api/c2e35f2ad918ceb6dd6b6aabbd049bc8c6282fcf/Images/Banner.png -------------------------------------------------------------------------------- /Images/Hero.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jensenkd/plex-api/c2e35f2ad918ceb6dd6b6aabbd049bc8c6282fcf/Images/Hero.png -------------------------------------------------------------------------------- /Images/Icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jensenkd/plex-api/c2e35f2ad918ceb6dd6b6aabbd049bc8c6282fcf/Images/Icon.png -------------------------------------------------------------------------------- /Key.snk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jensenkd/plex-api/c2e35f2ad918ceb6dd6b6aabbd049bc8c6282fcf/Key.snk -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Project Author 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /Samples/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jensenkd/plex-api/c2e35f2ad918ceb6dd6b6aabbd049bc8c6282fcf/Samples/.DS_Store -------------------------------------------------------------------------------- /Samples/PlexBlazorServerOAuthExample/App.razor: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Sorry, there's nothing at this address.

8 |
9 |
10 |
11 | -------------------------------------------------------------------------------- /Samples/PlexBlazorServerOAuthExample/Controllers/PlexLoginController.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Microsoft.AspNetCore.Routing; 3 | using Plex.ServerApi.Clients.Interfaces; 4 | using PlexBlazorServerOAuthExample.Services.Plex; 5 | using System; 6 | using System.Threading.Tasks; 7 | 8 | namespace PlexBlazorServerOAuthExample.Controllers 9 | { 10 | [Route("api/[controller]")] 11 | public class PlexLoginController : Controller 12 | { 13 | private readonly OAuthService _oAuthService; 14 | private readonly IPlexAccountClient _plexClient; 15 | 16 | public PlexLoginController(OAuthService oAuthService, IPlexAccountClient plexClient) 17 | { 18 | _oAuthService = oAuthService; 19 | _plexClient = plexClient; 20 | } 21 | 22 | [HttpGet] 23 | public async Task IndexAsync() 24 | { 25 | var returnPath = Request.Scheme + "://" + Request.Host + Request.Path + "/PlexReturn"; 26 | var oAuthUrl = await _plexClient.CreateOAuthPinAsync(returnPath); 27 | _oAuthService.OAuthID = oAuthUrl.Id; 28 | return Redirect(oAuthUrl.Url); 29 | } 30 | 31 | [HttpGet] 32 | [Route("PlexReturn")] 33 | public async Task PlexReturn() 34 | { 35 | var test = this.Request.Query; 36 | 37 | var oAuthId = _oAuthService.OAuthID.ToString(); 38 | var oAuthPin = await _plexClient.GetAuthTokenFromOAuthPinAsync(oAuthId); 39 | 40 | if (string.IsNullOrEmpty(oAuthPin.AuthToken)) 41 | { 42 | return Content(@"

Plex login failed, unable to obtain an authentication token.

","text/html"); 43 | } 44 | 45 | _oAuthService.PlexKey = oAuthPin.AuthToken; 46 | 47 | await _oAuthService.Login(oAuthPin.AuthToken); 48 | 49 | return Content(@"", "text/html"); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Samples/PlexBlazorServerOAuthExample/Pages/Error.cshtml: -------------------------------------------------------------------------------- 1 | @page 2 | @model PlexBlazorServerOAuthExample.Pages.ErrorModel 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Error 11 | 12 | 13 | 14 | 15 | 16 |
17 |
18 |

Error.

19 |

An error occurred while processing your request.

20 | 21 | @if (Model.ShowRequestId) 22 | { 23 |

24 | Request ID: @Model.RequestId 25 |

26 | } 27 | 28 |

Development Mode

29 |

30 | Swapping to the Development environment displays detailed information about the error that occurred. 31 |

32 |

33 | The Development environment shouldn't be enabled for deployed applications. 34 | It can result in displaying sensitive information from exceptions to end users. 35 | For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development 36 | and restarting the app. 37 |

38 |
39 |
40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /Samples/PlexBlazorServerOAuthExample/Pages/Error.cshtml.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Mvc; 2 | using Microsoft.AspNetCore.Mvc.RazorPages; 3 | using Microsoft.Extensions.Logging; 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Diagnostics; 7 | using System.Linq; 8 | using System.Threading.Tasks; 9 | 10 | namespace PlexBlazorServerOAuthExample.Pages 11 | { 12 | [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] 13 | [IgnoreAntiforgeryToken] 14 | public class ErrorModel : PageModel 15 | { 16 | public string RequestId { get; set; } 17 | 18 | public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); 19 | 20 | private readonly ILogger _logger; 21 | 22 | public ErrorModel(ILogger logger) 23 | { 24 | _logger = logger; 25 | } 26 | 27 | public void OnGet() 28 | { 29 | RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Samples/PlexBlazorServerOAuthExample/Pages/Index.razor: -------------------------------------------------------------------------------- 1 | @page "/" 2 | 3 | @using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage 4 | 5 | @inject ProtectedLocalStorage BrowserStorage 6 | @inject ILogger Logger 7 | 8 | 9 |
10 |

Plex OAuth Example!

11 |

This is a simple example of the Plex.Api OAuth flow in Blazor Server.

12 |
13 | @if (string.IsNullOrEmpty(PlexKey)) 14 | { 15 |

You are currently not logged in, please click the login button below to initiate the login workflow.

16 | Login 17 | } 18 |
19 | 20 | 21 | 22 | @code { 23 | string PlexKey = ""; 24 | 25 | protected override async Task OnInitializedAsync() 26 | { 27 | Services.Plex.OAuthService.LoginEvent += NewLogin; 28 | await base.OnInitializedAsync(); 29 | } 30 | protected override async Task OnAfterRenderAsync(bool firstRender) 31 | { 32 | if (firstRender) 33 | { 34 | ProtectedBrowserStorageResult result; 35 | 36 | try 37 | { 38 | result = await BrowserStorage.GetAsync("PlexKey"); 39 | } 40 | catch (Exception ex) 41 | { 42 | //Encryption doesn't match local storage, remove it to prevent future errors 43 | Logger.LogWarning($"Encryption doesn't match local storage\r\n{ex}"); 44 | await BrowserStorage.DeleteAsync("PlexKey"); 45 | return; 46 | } 47 | 48 | if (result.Success) 49 | { 50 | PlexKey = result.Value; 51 | await Changed(); 52 | } 53 | } 54 | 55 | await base.OnAfterRenderAsync(firstRender); 56 | } 57 | 58 | async Task NewLogin(string plexKey) 59 | { 60 | PlexKey = plexKey; 61 | await BrowserStorage.SetAsync("PlexKey", plexKey); 62 | await Changed(); 63 | } 64 | 65 | async Task Changed() 66 | { 67 | await InvokeAsync(() => { StateHasChanged(); }); 68 | } 69 | 70 | } -------------------------------------------------------------------------------- /Samples/PlexBlazorServerOAuthExample/Pages/_Host.cshtml: -------------------------------------------------------------------------------- 1 | @page "/" 2 | @namespace PlexBlazorServerOAuthExample.Pages 3 | @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers 4 | @{ 5 | Layout = null; 6 | } 7 | 8 | 9 | 10 | 11 | 12 | 13 | PlexBlazorServerOAuthExample 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | An error has occurred. This application may no longer respond until reloaded. 25 | 26 | 27 | An unhandled exception has occurred. See browser dev tools for details. 28 | 29 | Reload 30 | 🗙 31 |
32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /Samples/PlexBlazorServerOAuthExample/PlexBlazorServerOAuthExample.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net7.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /Samples/PlexBlazorServerOAuthExample/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Hosting; 2 | using Microsoft.Extensions.Configuration; 3 | using Microsoft.Extensions.Hosting; 4 | using Microsoft.Extensions.Logging; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Threading.Tasks; 9 | 10 | namespace PlexBlazorServerOAuthExample 11 | { 12 | public class Program 13 | { 14 | public static void Main(string[] args) 15 | { 16 | CreateHostBuilder(args).Build().Run(); 17 | } 18 | 19 | public static IHostBuilder CreateHostBuilder(string[] args) => 20 | Host.CreateDefaultBuilder(args) 21 | .ConfigureWebHostDefaults(webBuilder => 22 | { 23 | webBuilder.UseStartup(); 24 | }); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Samples/PlexBlazorServerOAuthExample/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:49522", 7 | "sslPort": 44374 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "PlexBlazorServerOAuthExample": { 19 | "commandName": "Project", 20 | "dotnetRunMessages": "true", 21 | "launchBrowser": true, 22 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 23 | "environmentVariables": { 24 | "ASPNETCORE_ENVIRONMENT": "Development" 25 | } 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Samples/PlexBlazorServerOAuthExample/Services/Plex/OAuthService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading.Tasks; 3 | 4 | namespace PlexBlazorServerOAuthExample.Services.Plex 5 | { 6 | public class OAuthService 7 | { 8 | public int OAuthID { get; set; } 9 | public string PlexKey { get; set; } 10 | public static event Func LoginEvent; 11 | 12 | public async Task Login(string PlexKey) 13 | { 14 | await (LoginEvent?.Invoke(PlexKey) ?? Task.CompletedTask); 15 | } 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Samples/PlexBlazorServerOAuthExample/Shared/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | 3 |
4 | 7 | 8 |
9 |
10 | About 11 |
12 | 13 |
14 | @Body 15 |
16 |
17 |
18 | -------------------------------------------------------------------------------- /Samples/PlexBlazorServerOAuthExample/Shared/MainLayout.razor.css: -------------------------------------------------------------------------------- 1 | .page { 2 | position: relative; 3 | display: flex; 4 | flex-direction: column; 5 | } 6 | 7 | .main { 8 | flex: 1; 9 | } 10 | 11 | .sidebar { 12 | background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%); 13 | } 14 | 15 | .top-row { 16 | background-color: #f7f7f7; 17 | border-bottom: 1px solid #d6d5d5; 18 | justify-content: flex-end; 19 | height: 3.5rem; 20 | display: flex; 21 | align-items: center; 22 | } 23 | 24 | .top-row ::deep a, .top-row .btn-link { 25 | white-space: nowrap; 26 | margin-left: 1.5rem; 27 | } 28 | 29 | .top-row a:first-child { 30 | overflow: hidden; 31 | text-overflow: ellipsis; 32 | } 33 | 34 | @media (max-width: 640.98px) { 35 | .top-row:not(.auth) { 36 | display: none; 37 | } 38 | 39 | .top-row.auth { 40 | justify-content: space-between; 41 | } 42 | 43 | .top-row a, .top-row .btn-link { 44 | margin-left: 0; 45 | } 46 | } 47 | 48 | @media (min-width: 641px) { 49 | .page { 50 | flex-direction: row; 51 | } 52 | 53 | .sidebar { 54 | width: 250px; 55 | height: 100vh; 56 | position: sticky; 57 | top: 0; 58 | } 59 | 60 | .top-row { 61 | position: sticky; 62 | top: 0; 63 | z-index: 1; 64 | } 65 | 66 | .main > div { 67 | padding-left: 2rem !important; 68 | padding-right: 1.5rem !important; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /Samples/PlexBlazorServerOAuthExample/Shared/NavMenu.razor: -------------------------------------------------------------------------------- 1 |  7 | 8 |
9 | 16 |
17 | 18 | @code { 19 | private bool collapseNavMenu = true; 20 | 21 | private string NavMenuCssClass => collapseNavMenu ? "collapse" : null; 22 | 23 | private void ToggleNavMenu() 24 | { 25 | collapseNavMenu = !collapseNavMenu; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Samples/PlexBlazorServerOAuthExample/Shared/NavMenu.razor.css: -------------------------------------------------------------------------------- 1 | .navbar-toggler { 2 | background-color: rgba(255, 255, 255, 0.1); 3 | } 4 | 5 | .top-row { 6 | height: 3.5rem; 7 | background-color: rgba(0,0,0,0.4); 8 | } 9 | 10 | .navbar-brand { 11 | font-size: 1.1rem; 12 | } 13 | 14 | .oi { 15 | width: 2rem; 16 | font-size: 1.1rem; 17 | vertical-align: text-top; 18 | top: -2px; 19 | } 20 | 21 | .nav-item { 22 | font-size: 0.9rem; 23 | padding-bottom: 0.5rem; 24 | } 25 | 26 | .nav-item:first-of-type { 27 | padding-top: 1rem; 28 | } 29 | 30 | .nav-item:last-of-type { 31 | padding-bottom: 1rem; 32 | } 33 | 34 | .nav-item ::deep a { 35 | color: #d7d7d7; 36 | border-radius: 4px; 37 | height: 3rem; 38 | display: flex; 39 | align-items: center; 40 | line-height: 3rem; 41 | } 42 | 43 | .nav-item ::deep a.active { 44 | background-color: rgba(255,255,255,0.25); 45 | color: white; 46 | } 47 | 48 | .nav-item ::deep a:hover { 49 | background-color: rgba(255,255,255,0.1); 50 | color: white; 51 | } 52 | 53 | @media (min-width: 641px) { 54 | .navbar-toggler { 55 | display: none; 56 | } 57 | 58 | .collapse { 59 | /* Never collapse the sidebar for wide screens */ 60 | display: block; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Samples/PlexBlazorServerOAuthExample/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using Microsoft.AspNetCore.Authorization 3 | @using Microsoft.AspNetCore.Components.Authorization 4 | @using Microsoft.AspNetCore.Components.Forms 5 | @using Microsoft.AspNetCore.Components.Routing 6 | @using Microsoft.AspNetCore.Components.Web 7 | @using Microsoft.AspNetCore.Components.Web.Virtualization 8 | @using Microsoft.JSInterop 9 | @using PlexBlazorServerOAuthExample 10 | @using PlexBlazorServerOAuthExample.Shared 11 | @using Microsoft.Extensions.Logging -------------------------------------------------------------------------------- /Samples/PlexBlazorServerOAuthExample/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "DetailedErrors": true, 3 | "Logging": { 4 | "LogLevel": { 5 | "Default": "Information", 6 | "Microsoft": "Warning", 7 | "Microsoft.Hosting.Lifetime": "Information" 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Samples/PlexBlazorServerOAuthExample/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft": "Warning", 6 | "Microsoft.Hosting.Lifetime": "Information" 7 | } 8 | }, 9 | "AllowedHosts": "*" 10 | } 11 | -------------------------------------------------------------------------------- /Samples/PlexBlazorServerOAuthExample/wwwroot/css/open-iconic/ICON-LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Waybury 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /Samples/PlexBlazorServerOAuthExample/wwwroot/css/open-iconic/font/fonts/open-iconic.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jensenkd/plex-api/c2e35f2ad918ceb6dd6b6aabbd049bc8c6282fcf/Samples/PlexBlazorServerOAuthExample/wwwroot/css/open-iconic/font/fonts/open-iconic.eot -------------------------------------------------------------------------------- /Samples/PlexBlazorServerOAuthExample/wwwroot/css/open-iconic/font/fonts/open-iconic.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jensenkd/plex-api/c2e35f2ad918ceb6dd6b6aabbd049bc8c6282fcf/Samples/PlexBlazorServerOAuthExample/wwwroot/css/open-iconic/font/fonts/open-iconic.otf -------------------------------------------------------------------------------- /Samples/PlexBlazorServerOAuthExample/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jensenkd/plex-api/c2e35f2ad918ceb6dd6b6aabbd049bc8c6282fcf/Samples/PlexBlazorServerOAuthExample/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf -------------------------------------------------------------------------------- /Samples/PlexBlazorServerOAuthExample/wwwroot/css/open-iconic/font/fonts/open-iconic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jensenkd/plex-api/c2e35f2ad918ceb6dd6b6aabbd049bc8c6282fcf/Samples/PlexBlazorServerOAuthExample/wwwroot/css/open-iconic/font/fonts/open-iconic.woff -------------------------------------------------------------------------------- /Samples/PlexBlazorServerOAuthExample/wwwroot/css/site.css: -------------------------------------------------------------------------------- 1 | @import url('open-iconic/font/css/open-iconic-bootstrap.min.css'); 2 | 3 | html, body { 4 | font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; 5 | } 6 | 7 | a, .btn-link { 8 | color: #0366d6; 9 | } 10 | 11 | .btn-primary { 12 | color: #fff; 13 | background-color: #1b6ec2; 14 | border-color: #1861ac; 15 | } 16 | 17 | .content { 18 | padding-top: 1.1rem; 19 | } 20 | 21 | .valid.modified:not([type=checkbox]) { 22 | outline: 1px solid #26b050; 23 | } 24 | 25 | .invalid { 26 | outline: 1px solid red; 27 | } 28 | 29 | .validation-message { 30 | color: red; 31 | } 32 | 33 | #blazor-error-ui { 34 | background: lightyellow; 35 | bottom: 0; 36 | box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); 37 | display: none; 38 | left: 0; 39 | padding: 0.6rem 1.25rem 0.7rem 1.25rem; 40 | position: fixed; 41 | width: 100%; 42 | z-index: 1000; 43 | } 44 | 45 | #blazor-error-ui .dismiss { 46 | cursor: pointer; 47 | position: absolute; 48 | right: 0.75rem; 49 | top: 0.5rem; 50 | } 51 | -------------------------------------------------------------------------------- /Samples/PlexPlaylistSplitter/.editorconfig: -------------------------------------------------------------------------------- 1 | [*.cs] 2 | 3 | # IDE0065: Misplaced using directive 4 | csharp_using_directive_placement = outside_namespace 5 | 6 | # IDE0160: Convert to block scoped namespace 7 | csharp_style_namespace_declarations = file_scoped 8 | 9 | # IDE1006: Naming Styles 10 | dotnet_diagnostic.IDE1006.severity = none 11 | 12 | # IDE0009: Member access should be qualified. 13 | dotnet_style_qualification_for_field = false 14 | 15 | # CA1848: Use the LoggerMessage delegates 16 | dotnet_diagnostic.CA1848.severity = silent 17 | 18 | # IDE0009: Member access should be qualified. 19 | dotnet_style_qualification_for_method = false 20 | -------------------------------------------------------------------------------- /Samples/PlexPlaylistSplitter/PlexPlaylistSplitter.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net7.0 5 | enable 6 | enable 7 | dotnet-PlexPlaylistSplitter-8637DC77-BB07-4799-B88A-5A0CF8A80891 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Samples/PlexPlaylistSplitter/Program.cs: -------------------------------------------------------------------------------- 1 | using Plex.Api.Factories; 2 | using Plex.Library.Factories; 3 | using Plex.ServerApi; 4 | using Plex.ServerApi.Api; 5 | using Plex.ServerApi.Clients; 6 | using Plex.ServerApi.Clients.Interfaces; 7 | using PlexPlaylistSplitter; 8 | 9 | var host = Host.CreateDefaultBuilder(args) 10 | .ConfigureServices((hostContext, services) => 11 | { 12 | services.AddHostedService(); 13 | // Create Client Options 14 | var apiOptions = new ClientOptions 15 | { 16 | Product = "API_UnitTests", 17 | DeviceName = "API_UnitTests", 18 | ClientId = "MyClientId", 19 | Platform = "Web", 20 | Version = "v1" 21 | }; 22 | 23 | // Setup Dependency Injection 24 | services.AddSingleton(apiOptions); 25 | services.AddTransient(); 26 | services.AddTransient(); 27 | services.AddTransient(); 28 | services.AddTransient(); 29 | services.AddTransient(); 30 | services.AddTransient(); 31 | services.Configure(hostContext.Configuration); 32 | 33 | 34 | }) 35 | .Build(); 36 | 37 | await host.RunAsync(); 38 | -------------------------------------------------------------------------------- /Samples/PlexPlaylistSplitter/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "PlexPlaylistSplitter": { 4 | "commandName": "Project", 5 | "dotnetRunMessages": true, 6 | "environmentVariables": { 7 | "DOTNET_ENVIRONMENT": "Development" 8 | } 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Samples/PlexPlaylistSplitter/SplitOptions.cs: -------------------------------------------------------------------------------- 1 | namespace PlexPlaylistSplitter; 2 | 3 | public class SplitOptions 4 | { 5 | public string? PlexToken { get; set; } 6 | 7 | public string? PlexUsername { get; set; } 8 | 9 | public string? PlexPassword { get; set; } 10 | 11 | public string? PlexServerName { get; set; } 12 | 13 | public string? PlaylistName { get; set; } 14 | 15 | public bool SortPlaylist { get; set; } = true; 16 | 17 | public int SplitCount { get; set; } = 250; 18 | 19 | public int ChunkSize { get; set; } = 25; 20 | 21 | public string PlaylistType { get; set; } = "audio"; 22 | 23 | public string? ServerHostOverride { get; set; } 24 | 25 | public int? ServerPortOverride { get; set; } 26 | } 27 | -------------------------------------------------------------------------------- /Samples/PlexPlaylistSplitter/appsettings.Development.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.Hosting.Lifetime": "Information" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Samples/PlexPlaylistSplitter/appsettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "Logging": { 3 | "LogLevel": { 4 | "Default": "Information", 5 | "Microsoft.Hosting.Lifetime": "Information" 6 | } 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Source/Plex.Library/ApiModels/Libraries/Filters/FilterFieldModel.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.Library.ApiModels.Libraries.Filters 2 | { 3 | using System.Collections.Generic; 4 | using ServerApi.PlexModels.Library.Search; 5 | 6 | /// 7 | /// Filter Field 8 | /// 9 | public class FilterFieldModel 10 | { 11 | /// 12 | /// Title of Filter Field (Ex: Genre) 13 | /// 14 | public string Title { get; set; } 15 | 16 | /// 17 | /// Url key (Ex: /library/sections/1/genre) 18 | /// 19 | public string UriKey { get; set; } 20 | 21 | /// 22 | /// Filter Field Type (Ex: tag, string, integer) 23 | /// 24 | public string Type { get; set; } 25 | 26 | /// 27 | /// Filter Field Key (Ex: genre, year) 28 | /// 29 | public string FieldKey { get; set; } 30 | 31 | /// 32 | /// Operators available for this field 33 | /// 34 | public List Operators { get; set; } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Source/Plex.Library/ApiModels/Libraries/Filters/FilterModel.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.Library.ApiModels.Libraries.Filters 2 | { 3 | using System.Collections.Generic; 4 | using ServerApi.PlexModels.Library.Search; 5 | 6 | /// 7 | /// 8 | public class FilterModel 9 | { 10 | /// 11 | /// Type of Filter (Ex: movie, folder) 12 | /// 13 | public string Type { get; set; } 14 | 15 | /// 16 | /// Url key (ex: /library/sections/1/all?type=1) 17 | /// 18 | public string Key { get; set; } 19 | 20 | /// 21 | /// Title for Filter (Ex: Movie, Folder) 22 | /// 23 | public string Title { get; set; } 24 | 25 | /// 26 | /// Filter is Active (true/false) 27 | /// 28 | public bool Active { get; set; } 29 | 30 | /// 31 | /// Filter Fields 32 | /// 33 | public List FilterFields { get; set; } = new(); 34 | 35 | public List FilterSorts { get; set; } = new(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Source/Plex.Library/ApiModels/Libraries/Filters/InvalidOperatorException.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.Library.ApiModels.Libraries.Filters 2 | { 3 | using System; 4 | using ServerApi.PlexModels.Library; 5 | using ServerApi.PlexModels.Library.Search; 6 | 7 | [Serializable] 8 | internal class InvalidOperatorException : Exception 9 | { 10 | public InvalidOperatorException() 11 | { 12 | } 13 | 14 | public InvalidOperatorException(Operator op, FilterField field) 15 | : base($"{op} is not a valid Operator for {field.Title}") 16 | { 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Source/Plex.Library/ApiModels/Libraries/PhotoLibrary.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.Library.ApiModels.Libraries 2 | { 3 | using ServerApi.Clients.Interfaces; 4 | using Servers; 5 | 6 | public class PhotoLibrary : LibraryBase 7 | { 8 | public PhotoLibrary(IPlexServerClient plexServerClient, IPlexLibraryClient plexLibraryClient, Server server) 9 | : base(plexServerClient, plexLibraryClient, server) 10 | { 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Source/Plex.Library/Automapper/CollectionModelMapper.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.Library.Automapper 2 | { 3 | using ApiModels.Libraries; 4 | using AutoMapper; 5 | using ServerApi.PlexModels.Library.Collections; 6 | using Collection = ServerApi.PlexModels.Library.Collections.Collection; 7 | 8 | /// 9 | /// 10 | /// 11 | public class CollectionModelMapper : Profile 12 | { 13 | /// 14 | /// Initializes a new instance of the class. 15 | /// 16 | public CollectionModelMapper() 17 | { 18 | this.CreateMap(); 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Source/Plex.Library/Automapper/ObjectMapper.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.Library.Automapper 2 | { 3 | using System; 4 | using AutoMapper; 5 | 6 | /// 7 | /// 8 | /// 9 | public static class ObjectMapper 10 | { 11 | private static readonly Lazy Lazy = new Lazy(() => 12 | { 13 | var config = new MapperConfiguration(cfg => 14 | { 15 | // This line ensures that internal properties are also mapped over. 16 | cfg.ShouldMapProperty = p => p.GetMethod.IsPublic || p.GetMethod.IsAssembly; 17 | cfg.AddProfile(); 18 | cfg.AddProfile(); 19 | cfg.AddProfile(); 20 | cfg.AddProfile(); 21 | }); 22 | var mapper = config.CreateMapper(); 23 | return mapper; 24 | }); 25 | 26 | /// 27 | /// 28 | /// 29 | public static IMapper Mapper => Lazy.Value; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Source/Plex.Library/Automapper/PlexAccountModelMapper.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.Library.Automapper 2 | { 3 | using System; 4 | using System.Globalization; 5 | using ApiModels.Accounts; 6 | using Profile = AutoMapper.Profile; 7 | 8 | /// 9 | /// 10 | /// 11 | public class PlexAccountModelMapper : Profile 12 | { 13 | /// 14 | /// Initializes a new instance of the class. 15 | /// 16 | public PlexAccountModelMapper() 17 | { 18 | this.CreateMap() 19 | .ForMember(x => x.RememberExpiresAt, 20 | opt => 21 | opt.MapFrom(src => src.RememberExpiresAt.HasValue?DateTimeOffset.FromUnixTimeSeconds(src.RememberExpiresAt.Value).UtcDateTime:(DateTime?)null)); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Source/Plex.Library/Automapper/PlexServerModelMapper.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.Library.Automapper 2 | { 3 | using System; 4 | using System.Globalization; 5 | using ApiModels.Servers; 6 | using ServerApi.PlexModels.Account; 7 | using ServerApi.PlexModels.Server; 8 | using Profile = AutoMapper.Profile; 9 | 10 | public class PlexServerModelMapper : Profile 11 | { 12 | /// 13 | /// Initializes a new instance of the class. 14 | /// 15 | public PlexServerModelMapper() 16 | { 17 | this.CreateMap() 18 | .ForMember(x => x.UpdatedAt, 19 | opt => 20 | opt.MapFrom(src => 21 | DateTimeOffset.FromUnixTimeSeconds(src.UpdatedAt).UtcDateTime)) 22 | 23 | .ForMember(x => x.CreatedAt, 24 | opt => 25 | opt.MapFrom(src => 26 | DateTimeOffset.FromUnixTimeSeconds(src.CreatedAt).UtcDateTime)); 27 | 28 | this.CreateMap().ForMember(x => x.UpdatedAt, 29 | opt => 30 | opt.MapFrom(src => 31 | DateTimeOffset.FromUnixTimeSeconds(src.UpdatedAt).UtcDateTime)); 32 | 33 | this.CreateMap(); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Source/Plex.Library/Factories/IPlexFactory.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.Api.Factories 2 | { 3 | using Library.ApiModels.Accounts; 4 | 5 | /// 6 | /// 7 | /// 8 | public interface IPlexFactory 9 | { 10 | /// 11 | /// 12 | /// 13 | /// 14 | /// 15 | /// 16 | PlexAccount GetPlexAccount(string username, string password); 17 | 18 | /// 19 | /// 20 | /// 21 | /// 22 | /// 23 | PlexAccount GetPlexAccount(string authToken); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Source/Plex.Library/Factories/PlexFactory.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.Library.Factories 2 | { 3 | using Api.Factories; 4 | using ApiModels.Accounts; 5 | using ServerApi.Clients.Interfaces; 6 | 7 | public class PlexFactory : IPlexFactory 8 | { 9 | private readonly IPlexServerClient plexServerClient; 10 | private readonly IPlexAccountClient plexAccountClient; 11 | private readonly IPlexLibraryClient plexLibraryClient; 12 | 13 | /// 14 | /// This is the entry point to the Api. This will initialize an Account object from 15 | /// your plex login information. 16 | /// 17 | /// 18 | /// 19 | /// 20 | public PlexFactory(IPlexServerClient plexServerClient, IPlexAccountClient plexAccountClient, 21 | IPlexLibraryClient plexLibraryClient) 22 | { 23 | this.plexServerClient = plexServerClient; 24 | this.plexAccountClient = plexAccountClient; 25 | this.plexLibraryClient = plexLibraryClient; 26 | } 27 | 28 | /// 29 | /// Plex Account 30 | /// 31 | /// 32 | /// 33 | /// 34 | public PlexAccount GetPlexAccount(string username, string password) => 35 | new(this.plexAccountClient, this.plexServerClient, this.plexLibraryClient, username, password); 36 | 37 | /// 38 | /// 39 | /// 40 | /// 41 | /// 42 | public PlexAccount GetPlexAccount(string authToken) => 43 | new(this.plexAccountClient, this.plexServerClient, this.plexLibraryClient, authToken); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Source/Plex.Library/Plex.Library.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net7.0 5 | True 6 | Plex Api 7 | https://github.com/jensenkd/plex-api 8 | https://github.com/jensenkd/plex-api/blob/master/LICENSE.md 9 | 10 | 11 | 12 | Plex.Api 13 | Library for interacting with Plex Media Servers 14 | Kevin Jensen 15 | git 16 | https://github.com/jensenkd/plex-api 17 | plex dotnet core api 18 | 19 | 20 | 21 | <_PackageFiles Include="$(OutputPath)\Plex.ServerApi.dll"> 22 | None 23 | lib\net6.0 24 | 25 | 26 | 27 | 28 | bin\Debug\Plex.Api.xml 29 | 30 | 31 | 32 | bin\Release\Plex.Api.xml 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/Api/IApiService.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.Api 2 | { 3 | using System.Threading.Tasks; 4 | 5 | /// 6 | /// Api Service Interface. 7 | /// 8 | public interface IApiService 9 | { 10 | /// 11 | /// Invoke Api. 12 | /// 13 | /// Api Request. 14 | /// A representing the asynchronous operation. 15 | Task InvokeApiAsync(ApiRequest request); 16 | 17 | /// 18 | /// Invoke Api for Type. 19 | /// 20 | /// Api Request. 21 | /// Type. 22 | /// A representing the asynchronous operation. 23 | Task InvokeApiAsync(ApiRequest request); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/Api/IPlexRequestsHttpClient.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.Api 2 | { 3 | using System.Net.Http; 4 | using System.Threading.Tasks; 5 | 6 | /// 7 | /// Interface for Plex Request Http Client. 8 | /// 9 | public interface IPlexRequestsHttpClient 10 | { 11 | /// 12 | /// Send Request Message to Http Client Endpoint. 13 | /// 14 | /// Http Request Message. 15 | /// A representing the asynchronous operation. 16 | Task SendAsync(HttpRequestMessage request); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/Api/PlexRequestsHttpClient.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.Api 2 | { 3 | using System.Net.Http; 4 | using System.Threading.Tasks; 5 | 6 | /// 7 | public class PlexRequestsHttpClient : IPlexRequestsHttpClient 8 | { 9 | private readonly HttpClient client; 10 | 11 | /// 12 | /// Initializes a new instance of the class. 13 | /// 14 | public PlexRequestsHttpClient() => this.client = new HttpClient(); 15 | 16 | /// 17 | public async Task SendAsync(HttpRequestMessage request) => 18 | await this.client.SendAsync(request); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/ClientOptions.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi 2 | { 3 | /// 4 | /// Plex Client Options. 5 | /// 6 | public class ClientOptions 7 | { 8 | /// 9 | /// Gets or sets product Code. 10 | /// 11 | public string Product { get; set; } = "Unknown"; 12 | 13 | /// 14 | /// Gets or sets device Name. 15 | /// 16 | public string DeviceName { get; set; } = "Unknown"; 17 | 18 | /// 19 | /// Client Id. 20 | /// 21 | public string ClientId { get; set; } = "PlexApi"; 22 | 23 | /// 24 | /// Version. 25 | /// 26 | public string Version { get; set; } = "v1"; 27 | 28 | /// 29 | /// Platform. 30 | /// 31 | public string Platform { get; set; } = "Web"; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/Enums/MetadataType.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.Enums 2 | { 3 | /// 4 | /// 5 | /// 6 | public enum MetadataType 7 | { 8 | /// 9 | /// Movie 10 | /// 11 | Movie = 1, 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/Enums/SearchType.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.Enums 2 | { 3 | public enum SearchType 4 | { 5 | Movie = 1, 6 | Show = 2, 7 | Season = 3, 8 | Episode = 4, 9 | Trailer = 5, 10 | Comic = 6, 11 | Person = 7, 12 | Artist = 8, 13 | Album = 9, 14 | Track = 10, 15 | Picture = 11, 16 | Clip = 12, 17 | Photo = 13, 18 | PhotoAlbum = 14, 19 | Playlist = 15, 20 | PlaylistFolder = 16, 21 | Collection = 18, 22 | OptimizedVersion = 42, 23 | UserPlaylistItem = 1001 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/Enums/SessionMediaType.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.Enums 2 | { 3 | /// 4 | /// Session Media Type Object 5 | /// {'movie': 1, 'show': 2, 'season': 3, 'episode': 4, 'trailer': 5, 'comic': 6, 'person': 7, 6 | /// 'artist': 8, 'album': 9, 'track': 10, 'picture': 11, 'clip': 12, 'photo': 13, 'photoalbum': 14, 7 | /// 'playlist': 15, 'playlistFolder': 16, 'collection': 18, 'optimizedVersion': 42, 'userPlaylistItem': 1001} 8 | /// 9 | public enum SessionMediaType 10 | { 11 | /// 12 | /// Movie 13 | /// 14 | Movie = 1, 15 | 16 | /// 17 | /// TV Show 18 | /// 19 | Show = 2, 20 | 21 | /// 22 | /// TV Season 23 | /// 24 | Season = 3, 25 | 26 | /// 27 | /// TV Episode 28 | /// 29 | Episode = 4, 30 | 31 | /// 32 | /// Movie Trailer 33 | /// 34 | Trailer = 5, 35 | 36 | /// 37 | /// Comic 38 | /// 39 | Comic = 6, 40 | 41 | /// 42 | /// Person 43 | /// 44 | Person = 7, 45 | 46 | /// 47 | /// Artist 48 | /// 49 | Artist = 8, 50 | 51 | /// 52 | /// Music Album 53 | /// 54 | Album = 9, 55 | 56 | /// 57 | /// Music Track 58 | /// 59 | Track = 10, 60 | 61 | /// 62 | /// Photo Album 63 | /// 64 | PhotoAlbum = 14, 65 | 66 | /// 67 | /// Picture 68 | /// 69 | Picture = 11, 70 | 71 | /// 72 | /// Photo 73 | /// 74 | Photo = 13, 75 | 76 | /// 77 | /// Clip 78 | /// 79 | Clip = 12, 80 | 81 | /// 82 | /// Playlist Item 83 | /// 84 | PlayListItem = 15, 85 | 86 | /// 87 | /// Playlist Folder 88 | /// 89 | PlayListFolder = 16, 90 | 91 | /// 92 | /// Collection Item 93 | /// 94 | Collection = 18 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/Helpers/BooleanValueConverter.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.Helpers 2 | { 3 | using System; 4 | using System.Buffers; 5 | using System.Buffers.Text; 6 | using System.Text.Json; 7 | using System.Text.Json.Serialization; 8 | 9 | /// 10 | /// 11 | /// 12 | public class BooleanValueConverter : JsonConverter 13 | { 14 | /// 15 | public override bool Read(ref Utf8JsonReader reader, Type type, JsonSerializerOptions options) 16 | { 17 | if (reader.TokenType == JsonTokenType.String) 18 | { 19 | if (string.Equals("1", reader.GetString(), StringComparison.OrdinalIgnoreCase) || 20 | string.Equals("0", reader.GetString(), StringComparison.OrdinalIgnoreCase)) 21 | { 22 | return Convert.ToBoolean(Convert.ToInt16(reader.GetString())); 23 | } 24 | 25 | // try to parse number directly from bytes 26 | var span = reader.HasValueSequence ? reader.ValueSequence.ToArray() : reader.ValueSpan; 27 | if (Utf8Parser.TryParse(span, out bool boolean, out var bytesConsumed) && span.Length == bytesConsumed) 28 | { 29 | return boolean; 30 | } 31 | 32 | // try to parse from a string if the above failed, this covers cases with other escaped/UTF characters 33 | if (bool.TryParse(reader.GetString(), out boolean)) 34 | { 35 | return boolean; 36 | } 37 | } 38 | 39 | // fallback to default handling 40 | return reader.GetBoolean(); 41 | } 42 | 43 | /// 44 | public override void Write(Utf8JsonWriter writer, bool value, JsonSerializerOptions options) => 45 | writer.WriteStringValue(value.ToString()); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/Helpers/DoubleValueConverter.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.Helpers 2 | { 3 | using System; 4 | using System.Buffers; 5 | using System.Buffers.Text; 6 | using System.Globalization; 7 | using System.Text.Json; 8 | using System.Text.Json.Serialization; 9 | 10 | /// 11 | /// 12 | /// 13 | public class DoubleValueConverter : JsonConverter 14 | { 15 | /// 16 | public override double Read(ref Utf8JsonReader reader, Type type, JsonSerializerOptions options) 17 | { 18 | if (reader.TokenType == JsonTokenType.String) 19 | { 20 | // try to parse number directly from bytes 21 | var span = reader.HasValueSequence ? reader.ValueSequence.ToArray() : reader.ValueSpan; 22 | if (Utf8Parser.TryParse(span, out double number, out int bytesConsumed) && span.Length == bytesConsumed) 23 | { 24 | return number; 25 | } 26 | 27 | // try to parse from a string if the above failed, this covers cases with other escaped/UTF characters 28 | if (double.TryParse(reader.GetString(), out number)) 29 | { 30 | return number; 31 | } 32 | } 33 | 34 | // fallback to default handling 35 | return reader.GetDouble(); 36 | } 37 | 38 | /// 39 | public override void Write(Utf8JsonWriter writer, double value, JsonSerializerOptions options) 40 | { 41 | writer.WriteStringValue(value.ToString(CultureInfo.InvariantCulture)); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/Helpers/FilterHelper.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.Helpers 2 | { 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | 6 | public static class FilterHelper 7 | { 8 | // OPERATORS = { 9 | // 'iexact': lambda v, q: v.lower() == q.lower(), 10 | // 'contains': lambda v, q: q in v, 11 | // 'icontains': lambda v, q: q.lower() in v.lower(), 12 | // 'ne': lambda v, q: v != q, 13 | // 'in': lambda v, q: v in q, 14 | // 'gt': lambda v, q: v > q, 15 | // 'gte': lambda v, q: v >= q, 16 | // 'lt': lambda v, q: v < q, 17 | // 'lte': lambda v, q: v <= q, 18 | // 'startswith': lambda v, q: v.startswith(q), 19 | // 'istartswith': lambda v, q: v.lower().startswith(q), 20 | // 'endswith': lambda v, q: v.endswith(q), 21 | // 'iendswith': lambda v, q: v.lower().endswith(q), 22 | // 'exists': lambda v, q: v is not None if q else v is None, 23 | // 'regex': lambda v, q: re.match(q, v), 24 | // 'iregex': lambda v, q: re.match(q, v, flags=re.IGNORECASE), 25 | 26 | public static Dictionary GetFilterParams(string operation, List values) 27 | { 28 | var parameters = new Dictionary(); 29 | 30 | if (string.IsNullOrEmpty(operation)) 31 | { 32 | return parameters; 33 | } 34 | 35 | if (values == null || !values.Any()) 36 | { 37 | return parameters; 38 | } 39 | 40 | switch (operation.ToLower()) 41 | { 42 | case "exact": 43 | parameters.Add("=", "=" + string.Join(",", values)); 44 | break; 45 | case "contains": 46 | parameters.Add("=", string.Join(",", values)); 47 | break; 48 | } 49 | 50 | return parameters; 51 | } 52 | 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/Helpers/IntValueConverter.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.Helpers 2 | { 3 | using System; 4 | using System.Buffers; 5 | using System.Buffers.Text; 6 | using System.Text.Json; 7 | using System.Text.Json.Serialization; 8 | 9 | /// 10 | /// 11 | /// 12 | public class IntValueConverter : JsonConverter 13 | { 14 | /// 15 | public override int Read(ref Utf8JsonReader reader, Type type, JsonSerializerOptions options) 16 | { 17 | if (reader.TokenType == JsonTokenType.String) 18 | { 19 | // try to parse number directly from bytes 20 | var span = reader.HasValueSequence ? reader.ValueSequence.ToArray() : reader.ValueSpan; 21 | if (Utf8Parser.TryParse(span, out int number, out int bytesConsumed) && span.Length == bytesConsumed) 22 | { 23 | return number; 24 | } 25 | 26 | // try to parse from a string if the above failed, this covers cases with other escaped/UTF characters 27 | if (int.TryParse(reader.GetString(), out number)) 28 | { 29 | return number; 30 | } 31 | } 32 | 33 | // fallback to default handling 34 | return reader.GetInt32(); 35 | } 36 | 37 | /// 38 | public override void Write(Utf8JsonWriter writer, int value, JsonSerializerOptions options) 39 | { 40 | writer.WriteStringValue(value.ToString()); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/Helpers/LongValueConverter.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.Helpers 2 | { 3 | using System; 4 | using System.Buffers; 5 | using System.Buffers.Text; 6 | using System.Text.Json; 7 | using System.Text.Json.Serialization; 8 | 9 | /// 10 | /// Long Value Converter 11 | /// 12 | public class LongValueConverter : JsonConverter 13 | { 14 | /// 15 | public override long Read(ref Utf8JsonReader reader, Type type, JsonSerializerOptions options) 16 | { 17 | if (reader.TokenType == JsonTokenType.String) 18 | { 19 | // try to parse number directly from bytes 20 | var span = reader.HasValueSequence ? reader.ValueSequence.ToArray() : reader.ValueSpan; 21 | if (Utf8Parser.TryParse(span, out long number, out int bytesConsumed) && span.Length == bytesConsumed) 22 | { 23 | return number; 24 | } 25 | 26 | // try to parse from a string if the above failed, this covers cases with other escaped/UTF characters 27 | if (long.TryParse(reader.GetString(), out number)) 28 | { 29 | return number; 30 | } 31 | } 32 | 33 | // fallback to default handling 34 | return reader.GetInt64(); 35 | } 36 | 37 | /// 38 | public override void Write(Utf8JsonWriter writer, long value, JsonSerializerOptions options) 39 | { 40 | writer.WriteStringValue(value.ToString()); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/Helpers/StringHelpers.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.Helpers 2 | { 3 | using System.Text.RegularExpressions; 4 | 5 | public static class StringHelpers 6 | { 7 | public static string CamelCase(string s) 8 | { 9 | var x = s.Replace("_", ""); 10 | if (x.Length == 0) return "null"; 11 | x = Regex.Replace(x, "([A-Z])([A-Z]+)($|[A-Z])", 12 | m => m.Groups[1].Value + m.Groups[2].Value.ToLower() + m.Groups[3].Value); 13 | return char.ToLower(x[0]) + x.Substring(1); 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/Helpers/UriHelper.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.Helpers 2 | { 3 | using System; 4 | 5 | /// 6 | /// Uri Helper Object 7 | /// 8 | public static class UriHelper 9 | { 10 | private const string Https = "Https"; 11 | private const string Http = "Http"; 12 | 13 | /// 14 | /// Get Url from Server Info 15 | /// 16 | /// Server Host 17 | /// Server Port 18 | /// Url Scheme 19 | /// Uri of Server 20 | /// Application Exception 21 | /// Exception 22 | public static Uri ReturnUriFromServerInfo(this string host, int port, string scheme) 23 | { 24 | if (host == null) 25 | { 26 | throw new ApplicationException("The URI is null, please check your settings to make sure you have configured the applications correctly."); 27 | } 28 | 29 | try 30 | { 31 | UriBuilder uri; 32 | 33 | var ssl = string.Equals(scheme, Https, StringComparison.OrdinalIgnoreCase); 34 | 35 | if (host.StartsWith("http://", StringComparison.Ordinal)) 36 | { 37 | var split = host.Split('/'); 38 | uri = split.Length >= 4 ? new UriBuilder(Http, split[2], port, "/" + split[3]) : new UriBuilder(new Uri($"{host}:{port}")); 39 | } 40 | else if (host.StartsWith("https://", StringComparison.Ordinal)) 41 | { 42 | var split = host.Split('/'); 43 | uri = split.Length >= 4 44 | ? new UriBuilder(Https, split[2], port, "/" + split[3]) 45 | : new UriBuilder(Https, split[2], port); 46 | } 47 | else if (ssl) 48 | { 49 | uri = new UriBuilder(Https, host, port); 50 | } 51 | else 52 | { 53 | uri = new UriBuilder(Http, host, port); 54 | } 55 | 56 | return uri.Uri; 57 | } 58 | catch (Exception exception) 59 | { 60 | throw new Exception(exception.Message, exception); 61 | } 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/Models/PlexAdd/AddUserError.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.Models.PlexAdd 2 | { 3 | using System.Xml.Serialization; 4 | 5 | /// 6 | /// Add User Error Object 7 | /// 8 | [XmlRoot(ElementName = "Response")] 9 | public class AddUserError 10 | { 11 | /// 12 | /// Code 13 | /// 14 | [XmlAttribute(AttributeName = "code")] 15 | public string Code { get; set; } 16 | 17 | /// 18 | /// Status 19 | /// 20 | [XmlAttribute(AttributeName = "status")] 21 | public string Status { get; set; } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/Models/PlexAdd/PlexAdd.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.Models.PlexAdd 2 | { 3 | using System.Xml.Serialization; 4 | 5 | /// 6 | /// Plex Add Object 7 | /// 8 | [XmlRoot(ElementName = "MediaContainer")] 9 | public class PlexAdd 10 | { 11 | /// 12 | /// Shared Server 13 | /// 14 | [XmlElement(ElementName = "SharedServer")] 15 | public SharedServer SharedServer { get; set; } 16 | 17 | /// 18 | /// Friendly Name 19 | /// 20 | [XmlAttribute(AttributeName = "friendlyName")] 21 | public string FriendlyName { get; set; } 22 | 23 | /// 24 | /// Identifier 25 | /// 26 | [XmlAttribute(AttributeName = "identifier")] 27 | public string Identifier { get; set; } 28 | 29 | /// 30 | /// Machine Identifier 31 | /// 32 | [XmlAttribute(AttributeName = "machineIdentifier")] 33 | public string MachineIdentifier { get; set; } 34 | 35 | /// 36 | /// Size 37 | /// 38 | [XmlAttribute(AttributeName = "size")] 39 | public string Size { get; set; } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/Models/PlexAdd/PlexAddWrapper.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.Models.PlexAdd 2 | { 3 | /// 4 | /// Plex Add Wrapper 5 | /// 6 | public class PlexAddWrapper 7 | { 8 | /// 9 | /// Add 10 | /// 11 | public PlexAdd Add { get; set; } 12 | 13 | /// 14 | /// Error 15 | /// 16 | public AddUserError Error { get; set; } 17 | 18 | /// 19 | /// Has Error? 20 | /// 21 | public bool HasError => this.Error != null; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/Models/PlexAdd/Section.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.Models.PlexAdd 2 | { 3 | using System.Xml.Serialization; 4 | 5 | /// 6 | /// Section Object 7 | /// 8 | [XmlRoot(ElementName = "Section")] 9 | public class Section 10 | { 11 | /// 12 | /// Id 13 | /// 14 | [XmlAttribute(AttributeName = "id")] 15 | public string Id { get; set; } 16 | 17 | /// 18 | /// Key 19 | /// 20 | [XmlAttribute(AttributeName = "key")] 21 | public string Key { get; set; } 22 | 23 | /// 24 | /// Title 25 | /// 26 | [XmlAttribute(AttributeName = "title")] 27 | public string Title { get; set; } 28 | 29 | /// 30 | /// Type 31 | /// 32 | [XmlAttribute(AttributeName = "type")] 33 | public string Type { get; set; } 34 | 35 | /// 36 | /// Shared 37 | /// 38 | [XmlAttribute(AttributeName = "shared")] 39 | public string Shared { get; set; } 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/Models/UserRole.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.Models 2 | { 3 | using System.Collections.Generic; 4 | using System.Text.Json.Serialization; 5 | 6 | /// 7 | /// User Role Object 8 | /// 9 | public class UserRole 10 | { 11 | /// 12 | /// Roles 13 | /// 14 | [JsonPropertyName("Roles")] 15 | public List Roles { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/Plex.ServerApi.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net7.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Account/AccountServer.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Account 2 | { 3 | using System; 4 | using System.Xml.Serialization; 5 | using Helpers; 6 | 7 | [XmlRoot(ElementName = "Server")] 8 | public class AccountServer 9 | { 10 | [XmlAttribute(AttributeName = "accessToken")] 11 | public string AccessToken { get; set; } 12 | 13 | [XmlAttribute(AttributeName = "name")] 14 | public string Name { get; set; } 15 | 16 | [XmlAttribute(AttributeName = "address")] 17 | public string Address { get; set; } 18 | 19 | [XmlAttribute(AttributeName = "port")] 20 | public int Port { get; set; } 21 | 22 | [XmlAttribute(AttributeName = "version")] 23 | public string Version { get; set; } 24 | 25 | [XmlAttribute(AttributeName = "scheme")] 26 | public string Scheme { get; set; } 27 | 28 | [XmlAttribute(AttributeName = "host")] 29 | public string Host { get; set; } 30 | 31 | [XmlAttribute(AttributeName = "localAddresses")] 32 | public string LocalAddresses { get; set; } 33 | 34 | [XmlAttribute(AttributeName = "machineIdentifier")] 35 | public string MachineIdentifier { get; set; } 36 | 37 | [XmlAttribute(AttributeName = "createdAt")] 38 | public int CreatedAt { get; set; } 39 | 40 | [XmlAttribute(AttributeName = "updatedAt")] 41 | public long UpdatedAt { get; set; } 42 | 43 | [XmlAttribute(AttributeName = "owned")] 44 | public int Owned { get; set; } 45 | 46 | [XmlAttribute(AttributeName = "synced")] 47 | public int Synced { get; set; } 48 | 49 | [XmlAttribute(AttributeName = "sourceTitle")] 50 | public string SourceTitle { get; set; } 51 | 52 | [XmlAttribute(AttributeName = "ownerId")] 53 | public int OwnerId { get; set; } 54 | 55 | [XmlAttribute(AttributeName = "home")] 56 | public int Home { get; set; } 57 | 58 | public Uri Uri => this.Host.ReturnUriFromServerInfo(this.Port, this.Scheme); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Account/AccountServerContainer.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Account 2 | { 3 | using System.Collections.Generic; 4 | using System.Xml.Serialization; 5 | 6 | [XmlRoot(ElementName = "MediaContainer")] 7 | public class AccountServerContainer 8 | { 9 | [XmlElement(ElementName = "Server")] 10 | public List Servers { get; set; } 11 | 12 | [XmlAttribute(AttributeName = "friendlyName")] 13 | public string FriendlyName { get; set; } 14 | 15 | [XmlAttribute(AttributeName = "identifier")] 16 | public string Identifier { get; set; } 17 | 18 | [XmlAttribute(AttributeName = "machineIdentifier")] 19 | public string MachineIdentifier { get; set; } 20 | 21 | [XmlAttribute(AttributeName = "size")] public int Size { get; set; } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Account/Announcements/Announcement.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Account.Announcements 2 | { 3 | using System.Xml.Serialization; 4 | 5 | public class Announcement 6 | { 7 | [XmlAttribute(AttributeName = "id")] 8 | public string Id { get; set; } 9 | 10 | [XmlAttribute(AttributeName = "title")] 11 | public string Title { get; set; } 12 | 13 | [XmlAttribute(AttributeName = "content")] 14 | public string Content { get; set; } 15 | 16 | [XmlAttribute(AttributeName = "plainContent")] 17 | public string PlainContent { get; set; } 18 | 19 | [XmlAttribute(AttributeName = "imageUrl")] 20 | public string ImageUrl { get; set; } 21 | 22 | [XmlAttribute(AttributeName = "style")] 23 | public string Style { get; set; } 24 | 25 | [XmlAttribute(AttributeName = "url")] 26 | public string Url { get; set; } 27 | 28 | [XmlAttribute(AttributeName = "expiresAt")] 29 | public string ExpiresAt { get; set; } 30 | 31 | [XmlAttribute(AttributeName = "notifyAt")] 32 | public string NotifyAt { get; set; } 33 | 34 | [XmlAttribute(AttributeName = "read")] 35 | public string Read { get; set; } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Account/Announcements/AnnouncementContainer.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Account.Announcements 2 | { 3 | using System.Collections.Generic; 4 | using System.Xml.Serialization; 5 | 6 | /// 7 | /// Announcement Container 8 | /// 9 | [XmlRoot(ElementName = "MediaContainer")] 10 | public class AnnouncementContainer 11 | { 12 | [XmlAttribute(AttributeName = "freindlyName")] 13 | public string FriendlyName { get; set; } 14 | 15 | [XmlAttribute(AttributeName = "identifier")] 16 | public string Identifier { get; set; } 17 | 18 | [XmlAttribute(AttributeName = "machineIdentifier")] 19 | public string MachineIdentifier { get; set; } 20 | 21 | [XmlAttribute(AttributeName = "totalSize")] 22 | public int TotalSize { get; set; } 23 | 24 | [XmlAttribute(AttributeName = "size")] 25 | public int Size { get; set; } 26 | 27 | [XmlAttribute(AttributeName = "title1")] 28 | public string Title1 { get; set; } 29 | 30 | [XmlAttribute(AttributeName = "viewGroup")] 31 | public string ViewGroup { get; set; } 32 | 33 | [XmlAttribute(AttributeName = "content")] 34 | public string Content { get; set; } 35 | 36 | [XmlElement(ElementName = "Announcement")] 37 | public List Announcements { get; set; } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Account/Device.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Account 2 | { 3 | public class Device 4 | { 5 | public int Id { get; set; } 6 | public string Name { get; set; } 7 | public string Product { get; set; } 8 | public string Version { get; set; } 9 | public string LastSeenAt { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Account/Discover/DiscoverSearchContainer.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Account.Discover; 2 | 3 | using System.Text.Json.Serialization; 4 | 5 | public class DiscoverSearchContainer 6 | { 7 | public string[] SuggestedTerms { get; set; } 8 | public string Identifier { get; set; } 9 | public int Size { get; set; } 10 | 11 | [JsonPropertyName("SearchResult")] 12 | public DiscoverSearchResult[] SearchResults { get; set; } 13 | } 14 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Account/Discover/DiscoverSearchResult.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Account.Discover; 2 | 3 | using System.Text.Json.Serialization; 4 | 5 | public class DiscoverSearchResult 6 | { 7 | public decimal Score { get; set; } 8 | 9 | [JsonPropertyName("Metadata")] 10 | public DiscoverSearchResultMetadata Metadata { get; set; } 11 | } 12 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Account/Discover/DiscoverSearchResultMetadata.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Account.Discover; 2 | 3 | public class DiscoverSearchResultMetadata 4 | { 5 | public int AddedAt { get; set; } 6 | public string Art { get; set; } 7 | public int ChildCount { get; set; } 8 | public long Duration { get; set; } 9 | public string Guid { get; set; } 10 | public string Key { get; set; } 11 | public int LeafCount { get; set; } 12 | public string OriginallyAvailableAt { get; set; } 13 | public string RatingKey { get; set; } 14 | public string Slug { get; set; } 15 | public string Thumb { get; set; } 16 | public string Title { get; set; } 17 | public string Type { get; set; } 18 | public int Year { get; set; } 19 | public string Source { get; set; } 20 | } 21 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Account/Friend.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Account 2 | { 3 | public class Friend 4 | { 5 | public int Id { get; set; } 6 | public string Uuid { get; set; } 7 | public string Title { get; set; } 8 | public string Username { get; set; } 9 | public bool Restricted { get; set; } 10 | public string Thumb { get; set; } 11 | public string Email { get; set; } 12 | public bool Home { get; set; } 13 | public string Status { get; set; } 14 | public string RestrictionProfile { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Account/Profile.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Account 2 | { 3 | using System.Text.Json.Serialization; 4 | 5 | public class Profile 6 | { 7 | [JsonPropertyName("autoSelectAudio")] 8 | public bool AutoSelectAudio { get; set; } 9 | 10 | [JsonPropertyName("defaultAudioLanguage")] 11 | public string DefaultAudioLanguage { get; set; } 12 | 13 | [JsonPropertyName("defaultSubtitleLanguage")] 14 | public string DefaultSubtitleLanguage { get; set; } 15 | 16 | [JsonPropertyName("autoSelectSubtitle")] 17 | public int AutoSelectSubtitle { get; set; } 18 | 19 | [JsonPropertyName("defaultSubtitleAccessibility")] 20 | public int DefaultSubtitleAccessibility { get; set; } 21 | 22 | [JsonPropertyName("defaultSubtitleForced")] 23 | public int DefaultSubtitleForced { get; set; } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Account/Resources/Resource.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Account.Resources; 2 | 3 | using System.Collections.Generic; 4 | using System.Xml.Serialization; 5 | 6 | /// 7 | /// This object represents resources connected to your Plex server that can provide 8 | /// content such as Plex Media Servers, iPhone or Android clients, etc. The raw xml 9 | /// for the data presented here can be found at: 10 | /// https://plex.tv/api/resources?includeHttps=1&includeRelay=1 11 | /// 12 | public class Resource 13 | { 14 | public string Name { get; set; } 15 | public string Product { get; set; } 16 | public string ProductVersion { get; set; } 17 | public string Platform { get; set; } 18 | public string PlatformVersion { get; set; } 19 | public string Device { get; set; } 20 | public string ClientIdentifier { get; set; } 21 | public string CreatedAt { get; set; } 22 | public string LastSeenAt { get; set; } 23 | public string Provides { get; set; } 24 | public int? OwnerId { get; set; } 25 | public string SourceTitle { get; set; } 26 | public string PublicAddress { get; set; } 27 | public string AccessToken { get; set; } 28 | public bool Owned { get; set; } 29 | public bool Home { get; set; } 30 | public bool Synced { get; set; } 31 | public bool Relay { get; set; } 32 | public bool Presence { get; set; } 33 | public bool HttpsRequired { get; set; } 34 | public bool PublicAddressMatches { get; set; } 35 | public bool DnsRebindingProtection { get; set; } 36 | public bool NatLoopbackSupport { get; set; } 37 | 38 | /// 39 | /// Connections 40 | /// 41 | public List Connections { get; set; } 42 | } 43 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Account/Resources/ResourceConnection.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Account.Resources; 2 | 3 | using System.Text.Json.Serialization; 4 | 5 | public class ResourceConnection { 6 | 7 | public string Protocol { get; set; } 8 | public string Address { get; set; } 9 | public int Port { get; set; } 10 | public string Uri { get; set; } 11 | public bool Local { get; set; } 12 | public bool Relay { get; set; } 13 | [JsonPropertyName("IPv6")] 14 | public bool IpV6 { get; set; } 15 | } 16 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Account/Service.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Account 2 | { 3 | using System.Text.Json.Serialization; 4 | 5 | public class Service { 6 | [JsonPropertyName("identifier")] 7 | public string Identifier { get; set; } 8 | 9 | [JsonPropertyName("endpoint")] 10 | public string Endpoint { get; set; } 11 | 12 | [JsonPropertyName("token")] 13 | public string Token { get; set; } 14 | 15 | [JsonPropertyName("status")] 16 | public string Status { get; set; } 17 | 18 | [JsonPropertyName("secret")] 19 | public string Secret { get; set; } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Account/SharedItems/SharedItem.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Account.SharedItems; 2 | 3 | public class SharedItem 4 | { 5 | public int Id { get; set; } 6 | public string Uri { get; set; } 7 | public string Status { get; set; } 8 | public string Title { get; set; } 9 | public string Type { get; set; } 10 | public string CreatedAt { get; set; } 11 | } 12 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Account/SharedItems/SharedItemAddModel.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Account.SharedItems; 2 | 3 | using System.Collections.Generic; 4 | 5 | public class SharedItemAddModel 6 | { 7 | public int InvitedId { get; set; } 8 | public List Items { get; set; } = new(); 9 | } 10 | 11 | public class SharedItemModelRequest 12 | { 13 | public string Uri { get; set; } 14 | public string Type { get; set; } 15 | public string Title { get; set; } 16 | } 17 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Account/SharedItems/SharedItemContainer.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Account.SharedItems; 2 | 3 | using System.Collections.Generic; 4 | 5 | public class SharedItemContainer 6 | { 7 | public int Id { get; set; } 8 | public string Origin { get; set; } 9 | public string Name { get; set; } 10 | public int ServerId { get; set; } 11 | public string Status { get; set; } 12 | public int SharedItemsCount { get; set; } 13 | public string CreatedAt { get; set; } 14 | public string AccessToken { get; set; } 15 | 16 | public SharedItemUser Invited { get; set; } 17 | public SharedItemUser Owner { get; set; } 18 | 19 | public List SharedItems { get; set; } 20 | } 21 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Account/SharedItems/SharedItemOwner.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Account.SharedItems; 2 | 3 | public class SharedItemUser 4 | { 5 | public int Id { get; set; } 6 | public string Uuid { get; set; } 7 | public string Title { get; set; } 8 | public string Username { get; set; } 9 | public bool Restricted { get; set; } 10 | public string Thumb { get; set; } 11 | } 12 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Account/Subscription.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Account 2 | { 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text.Json.Serialization; 6 | 7 | public class Subscription 8 | { 9 | [JsonPropertyName("active")] 10 | public bool Active { get; set; } 11 | 12 | [JsonPropertyName("subscribedAt")] 13 | public DateTime? SubscribedAt { get; set; } 14 | 15 | [JsonPropertyName("status")] 16 | public string Status { get; set; } 17 | 18 | [JsonPropertyName("paymentService")] 19 | public string PaymentService { get; set; } 20 | 21 | [JsonPropertyName("plan")] 22 | public string Plan { get; set; } 23 | 24 | [JsonPropertyName("features")] 25 | public List Features { get; set; } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Account/User/HomeUser.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Account.User; 2 | 3 | using System.Text.Json.Serialization; 4 | 5 | public class HomeUser 6 | { 7 | /// 8 | /// User's Plex account ID. 9 | /// 10 | public int Id { get; set; } 11 | 12 | /// 13 | /// User's Plex account UUID. 14 | /// 15 | public string Uuid { get; set; } 16 | 17 | /// 18 | /// Seems to be an alias for username. 19 | /// 20 | public string Title { get; set; } 21 | 22 | /// 23 | /// User's username. 24 | /// 25 | public string Username { get; set; } 26 | 27 | /// 28 | /// User's email address (user@gmail.com). 29 | /// 30 | public string Email { get; set; } 31 | 32 | /// 33 | /// ??? 34 | /// 35 | public string FriendlyName { get; set; } 36 | 37 | /// 38 | /// Link to the users avatar. 39 | /// 40 | public string Thumb { get; set; } 41 | 42 | /// 43 | /// Does the user have a password 44 | /// 45 | public bool HasPassword { get; set; } 46 | 47 | /// 48 | /// Date user was last updated 49 | /// 50 | public long UpdatedAt { get; set; } 51 | 52 | /// 53 | /// Is User Account Admin. 54 | /// 55 | [JsonPropertyName("admin")] 56 | public bool IsAdmin { get; set; } 57 | 58 | /// 59 | /// Is User Account Guest. 60 | /// 61 | [JsonPropertyName("guest")] 62 | public bool IsGuest { get; set; } 63 | 64 | /// 65 | /// Is User Account Restricted. 66 | /// 67 | [JsonPropertyName("restricted")] 68 | public bool IsRestricted { get; set; } 69 | 70 | /// 71 | /// Profile if user is restricted 72 | /// 73 | public string RestrictionProfile { get; set; } 74 | 75 | /// 76 | /// Unknown (possibly SSL enabled?). 77 | /// 78 | [JsonPropertyName("protected")] 79 | public bool IsProtected { get; set; } 80 | } 81 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Account/User/PlexUserRequest.cs: -------------------------------------------------------------------------------- 1 | #region Copyright 2 | // /************************************************************************ 3 | // Copyright (c) 2017 Jamie Rees 4 | // File: PlexUserRequest.cs 5 | // Created By: Jamie Rees 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining 8 | // a copy of this software and associated documentation files (the 9 | // "Software"), to deal in the Software without restriction, including 10 | // without limitation the rights to use, copy, modify, merge, publish, 11 | // distribute, sublicense, and/or sell copies of the Software, and to 12 | // permit persons to whom the Software is furnished to do so, subject to 13 | // the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be 16 | // included in all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 | // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 22 | // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 24 | // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 | // ************************************************************************/ 26 | #endregion 27 | 28 | namespace Plex.ServerApi.PlexModels.Account.User 29 | { 30 | /// 31 | /// Plex User Request Object 32 | /// 33 | public class PlexUserRequest 34 | { 35 | /// 36 | /// User Request Object 37 | /// 38 | public UserRequest User { get; set; } 39 | } 40 | 41 | /// 42 | /// User Request Object 43 | /// 44 | public class UserRequest 45 | { 46 | /// 47 | /// Login 48 | /// 49 | public string Login { get; set; } 50 | 51 | /// 52 | /// Password 53 | /// 54 | public string Password { get; set; } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Account/User/UserContainer.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Account.User; 2 | 3 | using System.Collections.Generic; 4 | using System.Text.Json.Serialization; 5 | 6 | public class HomeUserContainer 7 | { 8 | public int Id { get; set; } 9 | public string Name { get; set; } 10 | 11 | [JsonPropertyName(("guestUserID"))] 12 | public int GuestUserId { get; set; } 13 | 14 | [JsonPropertyName(("guestUserUUID"))] 15 | public string GuestUserUuid { get; set; } 16 | 17 | public bool GuestEnabled { get; set; } 18 | public bool Subscription { get; set; } 19 | 20 | public List Users { get; set; } 21 | } 22 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Account/User/UserSharedServer.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Account.User 2 | { 3 | using System.Xml.Serialization; 4 | 5 | [XmlRoot(ElementName="Server")] 6 | public class UserSharedServer 7 | { 8 | /// 9 | /// id for this share 10 | /// 11 | [XmlAttribute(AttributeName="id")] 12 | public int Id { get; set; } 13 | 14 | /// 15 | /// what id plex uses for this. 16 | /// 17 | [XmlAttribute(AttributeName="serverId")] 18 | public int ServerId { get; set; } 19 | 20 | /// 21 | /// The servers machineIdentifier 22 | /// 23 | [XmlAttribute(AttributeName="machineIdentifier")] 24 | public string MachineIdentifier { get; set; } 25 | 26 | /// 27 | /// The servers name 28 | /// 29 | [XmlAttribute(AttributeName="name")] 30 | public string Name { get; set; } 31 | 32 | /// 33 | /// Last connected to the server? 34 | /// 35 | [XmlAttribute(AttributeName="lastSeenAt")] 36 | public long LastSeenAt { get; set; } 37 | 38 | /// 39 | /// Total number of libraries 40 | /// 41 | [XmlAttribute(AttributeName="numLibraries")] 42 | public int NumLibraries { get; set; } 43 | 44 | /// 45 | /// 1 if all libraries is shared with this user. 46 | /// 47 | [XmlAttribute(AttributeName="allLibraries")] 48 | public int AllLibraries { get; set; } 49 | 50 | /// 51 | /// 1 if the server is owned by the user. 52 | /// 53 | [XmlAttribute(AttributeName="owned")] 54 | public int Owned { get; set; } 55 | 56 | /// 57 | /// 1 if user's invite is pending. 58 | /// 59 | [XmlAttribute(AttributeName="pending")] 60 | public int Pending { get; set; } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Account/Watchlist/WatchlistContainer.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Watchlist; 2 | 3 | using System.Text.Json.Serialization; 4 | 5 | public class WatchlistContainer 6 | { 7 | public int Size { get; set; } 8 | public string Identifier { get; set; } 9 | 10 | [JsonPropertyName("librarySectionID")] public string librarySectionId { get; set; } 11 | 12 | public string librarySectionTitle { get; set; } 13 | 14 | [JsonPropertyName("Directory")] public WatchlistDirectory[] Directories { get; set; } 15 | 16 | [JsonPropertyName("Type")] public WatchlistType[] Types { get; set; } 17 | 18 | [JsonPropertyName("MediaContainer")] 19 | public WatchlistMetadataContainer[] MediaContainers { get; set; } 20 | } 21 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Account/Watchlist/WatchlistDirectory.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Watchlist; 2 | 3 | public class WatchlistDirectory 4 | { 5 | public string Title { get; set; } 6 | public string Key { get; set; } 7 | public bool Secondary { get; set; } 8 | } 9 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Account/Watchlist/WatchlistFilter.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Watchlist; 2 | 3 | public class WatchlistFilter 4 | { 5 | public string Filter { get; set; } 6 | public string FilterType { get; set; } 7 | public string Title { get; set; } 8 | public string Key { get; set; } 9 | public string Type { get; set; } 10 | } 11 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Account/Watchlist/WatchlistMetadata.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Watchlist; 2 | 3 | using System.Text.Json.Serialization; 4 | 5 | public class WatchlistMetadata 6 | { 7 | public string Art { get; set; } 8 | public string Banner { get; set; } 9 | public string Guid { get; set; } 10 | public string Key { get; set; } 11 | public string PrimaryExtraKey { get; set; } 12 | public decimal? Rating { get; set; } 13 | public string RatingKey { get; set; } 14 | public string Studio { get; set; } 15 | public string Type { get; set; } 16 | public string Thumb { get; set; } 17 | public long AddedAt { get; set; } 18 | public long Duration { get; set; } 19 | [JsonPropertyName("publicPagesURL")] 20 | public string PublicPagesUrl { get; set; } 21 | public string Slug { get; set; } 22 | public bool UserState { get; set; } 23 | public string Title { get; set; } 24 | public string ContentRating { get; set; } 25 | public string OriginallyAvailableAt { get; set; } 26 | public int Year { get; set; } 27 | public decimal? AudienceRating { get; set; } 28 | public string AudienceRatingImage { get; set; } 29 | public long? ImdbRatingCount { get; set; } 30 | 31 | [JsonPropertyName("Image")] 32 | public WatchlistMetadataImage[] Images { get; set; } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Account/Watchlist/WatchlistMetadataContainer.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Watchlist; 2 | 3 | using System.Text.Json.Serialization; 4 | 5 | public class WatchlistMetadataContainer 6 | { 7 | public int Size { get; set; } 8 | [JsonPropertyName("Metadata")] 9 | public WatchlistMetadata[] Metadata { get; set; } 10 | } 11 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Account/Watchlist/WatchlistMetadataImage.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Watchlist; 2 | 3 | public class WatchlistMetadataImage 4 | { 5 | public string Alt { get; set; } 6 | public string Type { get; set; } 7 | public string Url { get; set; } 8 | } 9 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Account/Watchlist/WatchlistSort.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Watchlist; 2 | 3 | public class WatchlistSort 4 | { 5 | public bool Active { get; set; } 6 | public string ActiveDirection { get; set; } 7 | public string DefaultDirection { get; set; } 8 | public string Key { get; set; } 9 | public string DescKey { get; set; } 10 | public string Title { get; set; } 11 | public string FirstCharacterKey { get; set; } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Account/Watchlist/WatchlistType.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Watchlist; 2 | 3 | using System.Text.Json.Serialization; 4 | 5 | public class WatchlistType 6 | { 7 | public bool Active { get; set; } 8 | public string Type { get; set; } 9 | public string Title { get; set; } 10 | public string Key { get; set; } 11 | 12 | [JsonPropertyName("Filter")] 13 | public WatchlistFilter[] Filters { get; set; } 14 | } 15 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Account/Watchlist/WatchlistUserState.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Watchlist; 2 | 3 | public class WatchlistUserState 4 | { 5 | public int WatchlistedAt { get; set; } 6 | public int ViewCount { get; set; } 7 | public int ViewOffset { get; set; } 8 | public string RatingKey { get; set; } 9 | public string Type { get; set; } 10 | } 11 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Account/Watchlist/WatchlistUserStateContainer.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Watchlist; 2 | 3 | using System.Text.Json.Serialization; 4 | 5 | public class WatchlistUserStateContainer 6 | { 7 | public string Identitfier { get; set; } 8 | public int Size { get; set; } 9 | 10 | [JsonPropertyName("UserState")] 11 | public WatchlistUserState UserState { get; set; } 12 | } 13 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Audio/Album.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Audio 2 | { 3 | public class Album 4 | { 5 | 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Audio/Artist.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Audio 2 | { 3 | public class Artist 4 | { 5 | 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Audio/AudioBase.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Audio 2 | { 3 | public class AudioBase 4 | { 5 | 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Folders/Folder.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Folders 2 | { 3 | using System.Text.Json.Serialization; 4 | 5 | public class Folder 6 | { 7 | [JsonPropertyName("key")] 8 | public string Key { get; set; } 9 | 10 | [JsonPropertyName("title")] 11 | public string Title { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Folders/FolderContainer.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Folders 2 | { 3 | using System.Collections.Generic; 4 | using System.Text.Json.Serialization; 5 | 6 | public class FolderContainer 7 | { 8 | [JsonPropertyName("size")] 9 | public int Size { get; set; } 10 | 11 | [JsonPropertyName("allowSync")] 12 | public bool AllowSync { get; set; } 13 | 14 | [JsonPropertyName("art")] 15 | public string Art { get; set; } 16 | 17 | [JsonPropertyName("identifier")] 18 | public string Identifier { get; set; } 19 | 20 | [JsonPropertyName("librarySectionID")] 21 | public int LibrarySectionID { get; set; } 22 | 23 | [JsonPropertyName("librarySectionTitle")] 24 | public string LibrarySectionTitle { get; set; } 25 | 26 | [JsonPropertyName("librarySectionUUID")] 27 | public string LibrarySectionUUID { get; set; } 28 | 29 | [JsonPropertyName("mediaTagPrefix")] 30 | public string MediaTagPrefix { get; set; } 31 | 32 | [JsonPropertyName("mediaTagVersion")] 33 | public int MediaTagVersion { get; set; } 34 | 35 | [JsonPropertyName("thumb")] 36 | public string Thumb { get; set; } 37 | 38 | [JsonPropertyName("title1")] 39 | public string Title1 { get; set; } 40 | 41 | [JsonPropertyName("title2")] 42 | public string Title2 { get; set; } 43 | 44 | [JsonPropertyName("viewGroup")] 45 | public string ViewGroup { get; set; } 46 | 47 | [JsonPropertyName("viewMode")] 48 | public int ViewMode { get; set; } 49 | 50 | [JsonPropertyName("Metadata")] 51 | public List Folders { get; set; } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/GenericWrapper.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels 2 | { 3 | using System.Text.Json.Serialization; 4 | 5 | public class GenericWrapper 6 | { 7 | [JsonPropertyName("MediaContainer")] 8 | public T Container { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Hubs/Hub.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Hubs 2 | { 3 | using System.Collections.Generic; 4 | using System.Text.Json.Serialization; 5 | using Media; 6 | 7 | public class Hub 8 | { 9 | [JsonPropertyName("hubKey")] 10 | public string HubKey { get; set; } 11 | 12 | [JsonPropertyName("key")] 13 | public string Key { get; set; } 14 | 15 | [JsonPropertyName("title")] 16 | public string Title { get; set; } 17 | 18 | [JsonPropertyName("type")] 19 | public string Type { get; set; } 20 | 21 | [JsonPropertyName("hubIdentifier")] 22 | public string HubIdentifier { get; set; } 23 | 24 | [JsonPropertyName("context")] 25 | public string Context { get; set; } 26 | 27 | [JsonPropertyName("size")] 28 | public int Size { get; set; } 29 | 30 | [JsonPropertyName("more")] 31 | public bool More { get; set; } 32 | 33 | [JsonPropertyName("style")] 34 | public string Style { get; set; } 35 | 36 | [JsonPropertyName("Metadata")] 37 | public List Metadata { get; set; } 38 | 39 | [JsonPropertyName("random")] 40 | public bool? Random { get; set; } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Hubs/HubMediaContainer.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Hubs 2 | { 3 | using System.Collections.Generic; 4 | using System.Text.Json.Serialization; 5 | 6 | public class HubMediaContainer 7 | { 8 | [JsonPropertyName("size")] 9 | public int Size { get; set; } 10 | 11 | [JsonPropertyName("allowSync")] 12 | public bool AllowSync { get; set; } 13 | 14 | [JsonPropertyName("identifier")] 15 | public string Identifier { get; set; } 16 | 17 | [JsonPropertyName("librarySectionID")] 18 | public int LibrarySectionId { get; set; } 19 | 20 | [JsonPropertyName("librarySectionTitle")] 21 | public string LibrarySectionTitle { get; set; } 22 | 23 | [JsonPropertyName("librarySectionUUID")] 24 | public string LibrarySectionUuid { get; set; } 25 | 26 | [JsonPropertyName("Hub")] 27 | public List Hub { get; set; } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Library/Collections/Collection.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Library.Collections 2 | { 3 | using System.Text.Json.Serialization; 4 | 5 | public class Collection 6 | { 7 | [JsonPropertyName("ratingKey")] 8 | public string RatingKey { get; set; } 9 | 10 | [JsonPropertyName("key")] 11 | public string Key { get; set; } 12 | 13 | [JsonPropertyName("guid")] 14 | public string Guid { get; set; } 15 | 16 | [JsonPropertyName("type")] 17 | public string Type { get; set; } 18 | 19 | [JsonPropertyName("title")] 20 | public string Title { get; set; } 21 | 22 | [JsonPropertyName("contentRating")] 23 | public string ContentRating { get; set; } 24 | 25 | [JsonPropertyName("subtype")] 26 | public string Subtype { get; set; } 27 | 28 | [JsonPropertyName("summary")] 29 | public string Summary { get; set; } 30 | 31 | [JsonPropertyName("index")] 32 | public int Index { get; set; } 33 | 34 | [JsonPropertyName("ratingCount")] 35 | public int RatingCount { get; set; } 36 | 37 | [JsonPropertyName("thumb")] 38 | public string Thumb { get; set; } 39 | 40 | [JsonPropertyName("addedAt")] 41 | public int AddedAt { get; set; } 42 | 43 | [JsonPropertyName("updatedAt")] 44 | public int UpdatedAt { get; set; } 45 | 46 | [JsonPropertyName("childCount")] 47 | public string ChildCount { get; set; } 48 | 49 | [JsonPropertyName("collectionMode")] 50 | public string CollectionMode { get; set; } 51 | 52 | [JsonPropertyName("collectionSort")] 53 | public string CollectionSort { get; set; } 54 | 55 | [JsonPropertyName("maxYear")] 56 | public string MaxYear { get; set; } 57 | 58 | [JsonPropertyName("minYear")] 59 | public string MinYear { get; set; } 60 | 61 | [JsonPropertyName("titleSort")] 62 | public string TitleSort { get; set; } 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Library/Collections/CollectionContainer.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Library.Collections 2 | { 3 | using System.Collections.Generic; 4 | using System.Text.Json.Serialization; 5 | 6 | public class CollectionContainer 7 | { 8 | [JsonPropertyName("size")] 9 | public int Size { get; set; } 10 | 11 | [JsonPropertyName("allowSync")] 12 | public bool AllowSync { get; set; } 13 | 14 | [JsonPropertyName("art")] 15 | public string Art { get; set; } 16 | 17 | [JsonPropertyName("identifier")] 18 | public string Identifier { get; set; } 19 | 20 | [JsonPropertyName("librarySectionID")] 21 | public int LibrarySectionID { get; set; } 22 | 23 | [JsonPropertyName("librarySectionTitle")] 24 | public string LibrarySectionTitle { get; set; } 25 | 26 | [JsonPropertyName("librarySectionUUID")] 27 | public string LibrarySectionUuid { get; set; } 28 | 29 | [JsonPropertyName("mediaTagPrefix")] 30 | public string MediaTagPrefix { get; set; } 31 | 32 | [JsonPropertyName("mediaTagVersion")] 33 | public int MediaTagVersion { get; set; } 34 | 35 | [JsonPropertyName("thumb")] 36 | public string Thumb { get; set; } 37 | 38 | [JsonPropertyName("title1")] 39 | public string Title1 { get; set; } 40 | 41 | [JsonPropertyName("title2")] 42 | public string Title2 { get; set; } 43 | 44 | [JsonPropertyName("viewGroup")] 45 | public string ViewGroup { get; set; } 46 | 47 | [JsonPropertyName("viewMode")] 48 | public int ViewMode { get; set; } 49 | 50 | [JsonPropertyName("Metadata")] 51 | public List Collections { get; set; } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Library/Library.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Library 2 | { 3 | using System.Collections.Generic; 4 | using System.Text.Json.Serialization; 5 | 6 | public class Library 7 | { 8 | [JsonPropertyName("allowSync")] 9 | public bool AllowSync { get; set; } 10 | 11 | [JsonPropertyName("art")] 12 | public string Art { get; set; } 13 | 14 | [JsonPropertyName("composite")] 15 | public string Composite { get; set; } 16 | 17 | [JsonPropertyName("filters")] 18 | public bool HasFilters { get; set; } 19 | 20 | [JsonPropertyName("refreshing")] 21 | public bool Refreshing { get; set; } 22 | 23 | [JsonPropertyName("thumb")] 24 | public string Thumb { get; set; } 25 | 26 | [JsonPropertyName("key")] 27 | public string Key { get; set; } 28 | 29 | [JsonPropertyName("type")] 30 | public string Type { get; set; } 31 | 32 | [JsonPropertyName("title")] 33 | public string Title { get; set; } 34 | 35 | [JsonPropertyName("agent")] 36 | public string Agent { get; set; } 37 | 38 | [JsonPropertyName("scanner")] 39 | public string Scanner { get; set; } 40 | 41 | [JsonPropertyName("language")] 42 | public string Language { get; set; } 43 | 44 | [JsonPropertyName("uuid")] 45 | public string Uuid { get; set; } 46 | 47 | [JsonPropertyName("updatedAt")] 48 | public long UpdatedAt { get; set; } 49 | 50 | [JsonPropertyName("createdAt")] 51 | public long CreatedAt { get; set; } 52 | 53 | [JsonPropertyName("scannedAt")] 54 | public long ScannedAt { get; set; } 55 | 56 | [JsonPropertyName("content")] 57 | public bool Content { get; set; } 58 | 59 | [JsonPropertyName("directory")] 60 | public bool Directory { get; set; } 61 | 62 | [JsonPropertyName("contentChangedAt")] 63 | public long ContentChangedAt { get; set; } 64 | 65 | [JsonPropertyName("hidden")] 66 | public int Hidden { get; set; } 67 | 68 | [JsonPropertyName("enableAutoPhotoTags")] 69 | public bool? EnableAutoPhotoTags { get; set; } 70 | 71 | [JsonPropertyName("Location")] 72 | public List Location { get; set; } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Library/LibraryContainer.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Library 2 | { 3 | using System.Collections.Generic; 4 | using System.Text.Json.Serialization; 5 | 6 | public class LibraryContainer 7 | { 8 | [JsonPropertyName("size")] 9 | public int Size { get; set; } 10 | 11 | [JsonPropertyName("allowSync")] 12 | public bool AllowSync { get; set; } 13 | 14 | [JsonPropertyName("identifier")] 15 | public string Identifier { get; set; } 16 | 17 | [JsonPropertyName("mediaTagPrefix")] 18 | public string MediaTagPrefix { get; set; } 19 | 20 | [JsonPropertyName("mediaTagVersion")] 21 | public int MediaTagVersion { get; set; } 22 | 23 | [JsonPropertyName("title1")] 24 | public string Title1 { get; set; } 25 | 26 | [JsonPropertyName("Directory")] 27 | public List Libraries { get; set; } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Library/LibraryFilter.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Library 2 | { 3 | using System.Collections.Generic; 4 | 5 | public class LibraryFilter 6 | { 7 | public List Types { get; set; } = new List(); 8 | public List Keys { get; set; } = new List(); 9 | public List Titles { get; set; } = new List(); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Library/LibraryLocation.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Library 2 | { 3 | using System.Text.Json.Serialization; 4 | 5 | public class LibraryLocation { 6 | [JsonPropertyName("id")] 7 | public int Id { get; set; } 8 | 9 | [JsonPropertyName("path")] 10 | public string Path { get; set; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Library/Operator.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Library 2 | { 3 | public enum Operator 4 | { 5 | Is, 6 | IsNot, 7 | Contains, 8 | NotContains, 9 | GreaterThan, 10 | LessThan, 11 | BeginsWith, 12 | EndsWith 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Library/Search/FieldMeta.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Library.Search 2 | { 3 | using System.Collections.Generic; 4 | using System.Text.Json.Serialization; 5 | 6 | public class FieldMeta 7 | { 8 | /// 9 | /// Filter Type (album, artist, track, movie, show, episode, etc). 10 | /// 11 | [JsonPropertyName("Type")] 12 | public List Types { get; set; } 13 | 14 | /// 15 | /// Type of Field (tag, integer, etc..) along with operators. 16 | /// 17 | [JsonPropertyName("FieldType")] 18 | public List FieldTypes { get; set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Library/Search/FieldMetaType.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Library.Search 2 | { 3 | using System.Collections.Generic; 4 | using System.Text.Json.Serialization; 5 | 6 | public class FieldMetaType 7 | { 8 | [JsonPropertyName("key")] 9 | public string Key { get; set; } 10 | 11 | [JsonPropertyName("type")] 12 | public string FieldType { get; set; } 13 | 14 | [JsonPropertyName("title")] 15 | public string Title { get; set; } 16 | 17 | [JsonPropertyName("active")] 18 | public bool Active { get; set; } 19 | 20 | [JsonPropertyName("Filter")] 21 | public List Filters { get; set; } 22 | 23 | [JsonPropertyName("Sort")] 24 | public List Sorts { get; set; } 25 | 26 | [JsonPropertyName("Field")] 27 | public List Fields { get; set; } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Library/Search/FieldType.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Library.Search 2 | { 3 | using System.Collections.Generic; 4 | using System.Text.Json.Serialization; 5 | 6 | public class FieldType 7 | { 8 | /// 9 | /// Type for the Field (tag, integer, string, date, resolution, etc..). 10 | /// 11 | [JsonPropertyName("type")] 12 | public string Type { get; set; } 13 | 14 | /// 15 | /// Operators applicable to this field. 16 | /// 17 | [JsonPropertyName("Operator")] 18 | public List Operators { get; set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Library/Search/Filter.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Library.Search 2 | { 3 | using System.Text.Json.Serialization; 4 | 5 | // Root myDeserializedClass = JsonSerializer.Deserialize(myJsonResponse); 6 | public class Filter 7 | { 8 | /// 9 | /// Filter Name. 10 | /// 11 | [JsonPropertyName("filter")] 12 | public string FilterName { get; set; } 13 | 14 | /// 15 | /// Filter Type 16 | /// 17 | [JsonPropertyName("filterType")] 18 | public string FilterType { get; set; } 19 | 20 | /// 21 | /// Filter Url Key 22 | /// 23 | [JsonPropertyName("key")] 24 | public string Key { get; set; } 25 | 26 | /// 27 | /// Title 28 | /// 29 | [JsonPropertyName("title")] 30 | public string Title { get; set; } 31 | 32 | /// 33 | /// Type 34 | /// 35 | [JsonPropertyName("type")] 36 | public string Type { get; set; } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Library/Search/FilterContainer.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Library.Search 2 | { 3 | using System.Collections.Generic; 4 | using System.Text.Json.Serialization; 5 | 6 | namespace Plex.Api.PlexModels.Library.Search 7 | { 8 | public class FilterContainer 9 | { 10 | [JsonPropertyName("size")] 11 | public int Size { get; set; } 12 | 13 | [JsonPropertyName("allowSync")] 14 | public bool AllowSync { get; set; } 15 | 16 | [JsonPropertyName("art")] 17 | public string Art { get; set; } 18 | 19 | [JsonPropertyName("content")] 20 | public string Content { get; set; } 21 | 22 | [JsonPropertyName("identifier")] 23 | public string Identifier { get; set; } 24 | 25 | [JsonPropertyName("librarySectionID")] 26 | public int LibrarySectionId { get; set; } 27 | 28 | [JsonPropertyName("librarySectionTitle")] 29 | public string LibrarySectionTitle { get; set; } 30 | 31 | [JsonPropertyName("librarySectionUUID")] 32 | public string LibrarySectionUuid { get; set; } 33 | 34 | [JsonPropertyName("mediaTagPrefix")] 35 | public string MediaTagPrefix { get; set; } 36 | 37 | [JsonPropertyName("mediaTagVersion")] 38 | public int MediaTagVersion { get; set; } 39 | 40 | [JsonPropertyName("thumb")] 41 | public string Thumb { get; set; } 42 | 43 | [JsonPropertyName("title1")] 44 | public string Title1 { get; set; } 45 | 46 | [JsonPropertyName("viewGroup")] 47 | public string ViewGroup { get; set; } 48 | 49 | [JsonPropertyName("viewMode")] 50 | public int ViewMode { get; set; } 51 | 52 | [JsonPropertyName("Directory")] 53 | public List Filters { get; set; } 54 | } 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Library/Search/FilterField.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Library.Search 2 | { 3 | using System.Text.Json.Serialization; 4 | 5 | public class FilterField 6 | { 7 | /// 8 | /// Url key for the filter. 9 | /// 10 | [JsonPropertyName("key")] 11 | public string Key { get; set; } 12 | 13 | /// 14 | /// Title of filter. 15 | /// 16 | [JsonPropertyName("title")] 17 | public string Title { get; set; } 18 | 19 | /// 20 | /// Subtype of filter (decade, rating, etc). 21 | /// 22 | [JsonPropertyName("type")] 23 | public string Type { get; set; } 24 | 25 | /// 26 | /// 27 | /// 28 | [JsonPropertyName("subType")] 29 | public string SubType { get; set; } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Library/Search/FilterFieldContainer.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Library.Search 2 | { 3 | using System.Text.Json.Serialization; 4 | 5 | public class FilterFieldContainer 6 | { 7 | [JsonPropertyName("size")] 8 | public int Size { get; set; } 9 | 10 | [JsonPropertyName("allowSync")] 11 | public bool AllowSync { get; set; } 12 | 13 | [JsonPropertyName("art")] 14 | public string Art { get; set; } 15 | 16 | [JsonPropertyName("content")] 17 | public string Content { get; set; } 18 | 19 | [JsonPropertyName("identifier")] 20 | public string Identifier { get; set; } 21 | 22 | [JsonPropertyName("librarySectionID")] 23 | public int LibrarySectionId { get; set; } 24 | 25 | [JsonPropertyName("librarySectionTitle")] 26 | public string LibrarySectionTitle { get; set; } 27 | 28 | [JsonPropertyName("librarySectionUUID")] 29 | public string LibrarySectionUuid { get; set; } 30 | 31 | [JsonPropertyName("mediaTagPrefix")] 32 | public string MediaTagPrefix { get; set; } 33 | 34 | [JsonPropertyName("mediaTagVersion")] 35 | public int MediaTagVersion { get; set; } 36 | 37 | [JsonPropertyName("thumb")] 38 | public string Thumb { get; set; } 39 | 40 | [JsonPropertyName("title1")] 41 | public string Title1 { get; set; } 42 | 43 | [JsonPropertyName("viewGroup")] 44 | public string ViewGroup { get; set; } 45 | 46 | [JsonPropertyName("viewMode")] 47 | public int ViewMode { get; set; } 48 | 49 | [JsonPropertyName("Meta")] 50 | public FieldMeta FieldMetas { get; set; } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Library/Search/FilterOperator.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Library.Search 2 | { 3 | using System; 4 | using System.Text.Json.Serialization; 5 | 6 | public class FilterOperator 7 | { 8 | public Operator Type 9 | { 10 | get 11 | { 12 | switch (this.Key) 13 | { 14 | case "=": 15 | return Operator.Is; 16 | case "!=": 17 | return Operator.IsNot; 18 | case ">>": 19 | return Operator.GreaterThan; 20 | case "<<": 21 | return Operator.LessThan; 22 | case "==": 23 | return Operator.Contains; 24 | case "!==": 25 | return Operator.NotContains; 26 | case "<=": 27 | return Operator.BeginsWith; 28 | case ">=": 29 | return Operator.EndsWith; 30 | default: 31 | throw new ApplicationException("Non-Mapped Operator: " + this.Key); 32 | } 33 | } 34 | } 35 | 36 | /// 37 | /// Key for the Operator (ex: =, !=, >). 38 | /// 39 | [JsonPropertyName("key")] 40 | public string Key { get; set; } 41 | 42 | /// 43 | /// Title for the Operator (ex: is, is not) 44 | /// 45 | [JsonPropertyName("title")] 46 | public string Title { get; set; } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Library/Search/FilterRequest.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Library.Search 2 | { 3 | using System.Collections.Generic; 4 | 5 | public class FilterRequest 6 | { 7 | public string Field { get; set; } 8 | public Operator Operator { get; set; } 9 | public List Values { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Library/Search/FilterSort.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Library.Search 2 | { 3 | using System.Text.Json.Serialization; 4 | 5 | public class FilterSort 6 | { 7 | [JsonPropertyName("active")] 8 | public bool Active { get; set; } 9 | 10 | [JsonPropertyName("activeDirection")] 11 | public string ActiveDirection { get; set; } 12 | 13 | [JsonPropertyName("default")] 14 | public string Default { get; set; } 15 | 16 | [JsonPropertyName("defaultDirection")] 17 | public string DefaultDirection { get; set; } 18 | 19 | [JsonPropertyName("descKey")] 20 | public string DescKey { get; set; } 21 | 22 | [JsonPropertyName("firstCharacterKey")] 23 | public string FirstCharacterKey { get; set; } 24 | 25 | [JsonPropertyName("key")] 26 | public string Key { get; set; } 27 | 28 | [JsonPropertyName("title")] 29 | public string Title { get; set; } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Library/Search/FilterValue.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Library.Search 2 | { 3 | using System.Text.Json.Serialization; 4 | 5 | public class FilterValue 6 | { 7 | [JsonPropertyName("fastKey")] 8 | public string FastKey { get; set; } 9 | 10 | [JsonPropertyName("key")] 11 | public string Key { get; set; } 12 | 13 | [JsonPropertyName("title")] 14 | public string Title { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Library/Search/FilterValueContainer.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Library.Search 2 | { 3 | using System.Collections.Generic; 4 | using System.Text.Json.Serialization; 5 | 6 | public class FilterValueContainer 7 | { 8 | [JsonPropertyName("size")] 9 | public int Size { get; set; } 10 | 11 | [JsonPropertyName("allowSync")] 12 | public bool AllowSync { get; set; } 13 | 14 | [JsonPropertyName("art")] 15 | public string Art { get; set; } 16 | 17 | [JsonPropertyName("content")] 18 | public string Content { get; set; } 19 | 20 | [JsonPropertyName("identifier")] 21 | public string Identifier { get; set; } 22 | 23 | [JsonPropertyName("mediaTagPrefix")] 24 | public string MediaTagPrefix { get; set; } 25 | 26 | [JsonPropertyName("mediaTagVersion")] 27 | public int MediaTagVersion { get; set; } 28 | 29 | [JsonPropertyName("thumb")] 30 | public string Thumb { get; set; } 31 | 32 | [JsonPropertyName("title1")] 33 | public string Title1 { get; set; } 34 | 35 | [JsonPropertyName("title2")] 36 | public string Title2 { get; set; } 37 | 38 | [JsonPropertyName("viewGroup")] 39 | public string ViewGroup { get; set; } 40 | 41 | [JsonPropertyName("viewMode")] 42 | public int ViewMode { get; set; } 43 | 44 | [JsonPropertyName("Directory")] 45 | public List FilterValues { get; set; } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Media/Chapter.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Media 2 | { 3 | using System.Text.Json.Serialization; 4 | 5 | public class Chapter 6 | { 7 | [JsonNumberHandling(JsonNumberHandling.AllowReadingFromString)] 8 | [JsonPropertyName("id")] 9 | public long Id { get; set; } 10 | 11 | [JsonPropertyName("filter")] 12 | public string Filter { get; set; } 13 | 14 | [JsonPropertyName("tag")] 15 | public string Tag { get; set; } 16 | 17 | [JsonPropertyName("index")] 18 | public int Index { get; set; } 19 | 20 | [JsonPropertyName("startTimeOffset")] 21 | public int StartTimeOffset { get; set; } 22 | 23 | [JsonPropertyName("endTimeOffset")] 24 | public int EndTimeOffset { get; set; } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Media/Collection.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Media 2 | { 3 | using System.Text.Json.Serialization; 4 | 5 | public class Collection 6 | { 7 | [JsonNumberHandling(JsonNumberHandling.AllowReadingFromString)] 8 | [JsonPropertyName("id")] 9 | public long Id { get; set; } 10 | 11 | [JsonPropertyName("filter")] 12 | public string Filter { get; set; } 13 | 14 | [JsonPropertyName("tag")] 15 | public string Tag { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Media/Country.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Media 2 | { 3 | using System.Text.Json.Serialization; 4 | 5 | public class Country 6 | { 7 | [JsonNumberHandling(JsonNumberHandling.AllowReadingFromString)] 8 | [JsonPropertyName("id")] 9 | public long Id { get; set; } 10 | 11 | [JsonPropertyName("filter")] 12 | public string Filter { get; set; } 13 | 14 | [JsonPropertyName("tag")] 15 | public string Tag { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Media/Director.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Media 2 | { 3 | using System.Text.Json.Serialization; 4 | 5 | public class Director 6 | { 7 | [JsonNumberHandling(JsonNumberHandling.AllowReadingFromString)] 8 | [JsonPropertyName("id")] 9 | public long Id { get; set; } 10 | 11 | [JsonPropertyName("filter")] 12 | public string Filter { get; set; } 13 | 14 | [JsonPropertyName("tag")] 15 | public string Tag { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Media/Extras.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Media 2 | { 3 | using System.Collections.Generic; 4 | using System.Text.Json.Serialization; 5 | 6 | public class Extras 7 | { 8 | [JsonPropertyName("size")] 9 | public long Size { get; set; } 10 | 11 | [JsonPropertyName("allowSync")] 12 | public bool AllowSync { get; set; } 13 | 14 | [JsonPropertyName("augmentationKey")] 15 | public bool AugmentationKey { get; set; } 16 | 17 | [JsonPropertyName("identifier")] 18 | public string Identifier { get; set; } 19 | 20 | [JsonPropertyName("mediaTagPrefix")] 21 | public string MediaTagPrefix { get; set; } 22 | 23 | [JsonPropertyName("mediaTagVersion")] 24 | public long MediaTagVersion { get; set; } 25 | 26 | [JsonPropertyName("librarySectionID")] 27 | public int LibrarySectionId { get; set; } 28 | 29 | [JsonPropertyName("librarySectionTitle")] 30 | public string LibrarySectionTitle { get; set; } 31 | 32 | [JsonPropertyName("librarySectionUUID")] 33 | public string LibrarySectionUuid { get; set; } 34 | 35 | [JsonPropertyName("Metadata")] 36 | public List Media { get; set; } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Media/Genre.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Media 2 | { 3 | using System.Text.Json.Serialization; 4 | 5 | public class Genre 6 | { 7 | [JsonNumberHandling(JsonNumberHandling.AllowReadingFromString)] 8 | [JsonPropertyName("id")] 9 | public long Id { get; set; } 10 | 11 | [JsonPropertyName("filter")] 12 | public string Filter { get; set; } 13 | 14 | [JsonPropertyName("tag")] 15 | public string Tag { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Media/MediaContainer.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Media; 2 | 3 | using System.Collections.Generic; 4 | using System.Text.Json.Serialization; 5 | 6 | public class MediaContainer 7 | { 8 | public int Size { get; set; } 9 | public int TotalSize { get; set; } 10 | public bool AllowSync { get; set; } 11 | public string Art { get; set; } 12 | public string Identifier { get; set; } 13 | 14 | [JsonPropertyName("librarySectionID")] public int LibrarySectionId { get; set; } 15 | public string LibrarySectionTitle { get; set; } 16 | 17 | [JsonPropertyName("librarySectionUUID")] 18 | public string LibrarySectionUuid { get; set; } 19 | 20 | public string MediaTagPrefix { get; set; } 21 | public int MediaTagVersion { get; set; } 22 | public int Offset { get; set; } 23 | public string Thumb { get; set; } 24 | public string Title1 { get; set; } 25 | public string Title2 { get; set; } 26 | public string ViewGroup { get; set; } 27 | public int ViewMode { get; set; } 28 | 29 | [JsonPropertyName("Meta")] public MediaMeta Meta { get; set; } 30 | [JsonPropertyName("Metadata")] public List Media { get; set; } 31 | } 32 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Media/MediaField.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Media 2 | { 3 | using System.Text.Json.Serialization; 4 | 5 | public class MediaField 6 | { 7 | [JsonPropertyName("key")] 8 | public string Key { get; set; } 9 | 10 | [JsonPropertyName("title")] 11 | public string Title { get; set; } 12 | 13 | [JsonPropertyName("type")] 14 | public string Type { get; set; } 15 | 16 | [JsonPropertyName("subType")] 17 | public string SubType { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Media/MediaFieldType.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Media 2 | { 3 | using System.Collections.Generic; 4 | using System.Text.Json.Serialization; 5 | 6 | public class MediaFieldType 7 | { 8 | [JsonPropertyName("type")] 9 | public string Type { get; set; } 10 | 11 | [JsonPropertyName("Operator")] 12 | public List Operator { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Media/MediaFilter.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Media 2 | { 3 | using System.Text.Json.Serialization; 4 | 5 | public class MediaFilter 6 | { 7 | [JsonPropertyName("filter")] 8 | public string Filter { get; set; } 9 | 10 | [JsonPropertyName("filterType")] 11 | public string FilterType { get; set; } 12 | 13 | [JsonPropertyName("key")] 14 | public string Key { get; set; } 15 | 16 | [JsonPropertyName("title")] 17 | public string Title { get; set; } 18 | 19 | [JsonPropertyName("type")] 20 | public string Type { get; set; } 21 | 22 | [JsonPropertyName("advanced")] 23 | public bool? Advanced { get; set; } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Media/MediaMeta.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Media 2 | { 3 | using System.Collections.Generic; 4 | using System.Text.Json.Serialization; 5 | 6 | public class MediaMeta 7 | { 8 | [JsonPropertyName("Type")] 9 | public List Type { get; set; } 10 | 11 | [JsonPropertyName("FieldType")] 12 | public List FieldType { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Media/MediaOperator.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Media 2 | { 3 | using System.Text.Json.Serialization; 4 | 5 | public class MediaOperator 6 | { 7 | [JsonPropertyName("key")] 8 | public string Key { get; set; } 9 | 10 | [JsonPropertyName("title")] 11 | public string Title { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Media/MediaPart.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Media 2 | { 3 | using System.Collections.Generic; 4 | using System.Text.Json.Serialization; 5 | 6 | /// 7 | /// Represents a single media part (often a single file) for the media this belongs to. 8 | /// 9 | public class MediaPart 10 | { 11 | /// 12 | /// The unique ID for this media part on the server. 13 | /// 14 | [JsonNumberHandling(JsonNumberHandling.AllowReadingFromString)] 15 | [JsonPropertyName("id")] 16 | public long Id { get; set; } 17 | 18 | /// 19 | /// API URL (ex: /library/parts/46618/1389985872/file.mkv). 20 | /// 21 | [JsonPropertyName("key")] 22 | public string Key { get; set; } 23 | 24 | /// 25 | /// The duration of the file in milliseconds. 26 | /// 27 | [JsonPropertyName("duration")] 28 | public long Duration { get; set; } 29 | 30 | /// 31 | /// The path to this file on disk (ex: /media/Movies/Cars (2006)/Cars (2006).mkv) 32 | /// 33 | [JsonPropertyName("file")] 34 | public string File { get; set; } 35 | 36 | /// 37 | /// The size of the file in bytes (ex: 733884416). 38 | /// 39 | [JsonPropertyName("size")] 40 | public long Size { get; set; } 41 | 42 | /// 43 | /// The audio profile of the file. 44 | /// 45 | [JsonPropertyName("audioProfile")] 46 | public string AudioProfile { get; set; } 47 | 48 | /// 49 | /// The container type of the file (ex: avi). 50 | /// 51 | [JsonPropertyName("container")] 52 | public string Container { get; set; } 53 | 54 | /// 55 | /// The video profile of the file. 56 | /// 57 | [JsonPropertyName("videoProfile")] 58 | public string VideoProfile { get; set; } 59 | 60 | /// 61 | /// True if the file (track) has an embedded thumbnail. 62 | /// 63 | [JsonPropertyName("hasThumbnail")] 64 | public string HasThumbnail { get; set; } 65 | 66 | /// 67 | /// List of stream objects. 68 | /// 69 | [JsonPropertyName("Stream")] 70 | public List Stream { get; set; } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Media/MediaRole.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Media 2 | { 3 | using System.Text.Json.Serialization; 4 | 5 | public class MediaRole 6 | { 7 | [JsonNumberHandling(JsonNumberHandling.AllowReadingFromString)] 8 | [JsonPropertyName("id")] 9 | public long Id { get; set; } 10 | 11 | [JsonPropertyName("filter")] 12 | public string Filter { get; set; } 13 | 14 | [JsonPropertyName("tag")] 15 | public string Tag { get; set; } 16 | 17 | [JsonPropertyName("role")] 18 | public string Role { get; set; } 19 | 20 | [JsonPropertyName("thumb")] 21 | public string Thumb { get; set; } 22 | 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Media/MediaSort.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Media 2 | { 3 | using System.Text.Json.Serialization; 4 | 5 | public class MediaSort 6 | { 7 | [JsonPropertyName("active")] 8 | public bool Active { get; set; } 9 | 10 | [JsonPropertyName("activeDirection")] 11 | public string ActiveDirection { get; set; } 12 | 13 | [JsonPropertyName("default")] 14 | public string Default { get; set; } 15 | 16 | [JsonPropertyName("defaultDirection")] 17 | public string DefaultDirection { get; set; } 18 | 19 | [JsonPropertyName("descKey")] 20 | public string DescKey { get; set; } 21 | 22 | [JsonPropertyName("firstCharacterKey")] 23 | public string FirstCharacterKey { get; set; } 24 | 25 | [JsonPropertyName("key")] 26 | public string Key { get; set; } 27 | 28 | [JsonPropertyName("title")] 29 | public string Title { get; set; } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Media/MediaType.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Media 2 | { 3 | using System.Collections.Generic; 4 | using System.Text.Json.Serialization; 5 | 6 | public class MediaType 7 | { 8 | [JsonPropertyName("key")] 9 | public string Key { get; set; } 10 | 11 | [JsonPropertyName("type")] 12 | public string Type { get; set; } 13 | 14 | [JsonPropertyName("title")] 15 | public string Title { get; set; } 16 | 17 | [JsonPropertyName("active")] 18 | public bool Active { get; set; } 19 | 20 | [JsonPropertyName("Filter")] 21 | public List Filter { get; set; } 22 | 23 | [JsonPropertyName("Sort")] 24 | public List Sort { get; set; } 25 | 26 | [JsonPropertyName("Field")] 27 | public List Field { get; set; } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Media/MetadataField.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Media 2 | { 3 | using System.Text.Json.Serialization; 4 | 5 | public class MetadataField 6 | { 7 | [JsonPropertyName("locked")] 8 | public bool Locked { get; set; } 9 | 10 | [JsonPropertyName("name")] 11 | public string Name { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Media/Preference.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Media 2 | { 3 | using System.Collections.Generic; 4 | using System.Text.Json.Serialization; 5 | 6 | public class Preference 7 | { 8 | [JsonPropertyName("Setting")] 9 | public List Setting { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Media/Producer.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Media 2 | { 3 | using System.Text.Json.Serialization; 4 | 5 | public class Producer 6 | { 7 | [JsonNumberHandling(JsonNumberHandling.AllowReadingFromString)] 8 | [JsonPropertyName("id")] 9 | public long Id { get; set; } 10 | 11 | [JsonPropertyName("filter")] 12 | public string Filter { get; set; } 13 | 14 | [JsonPropertyName("tag")] 15 | public string Tag { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Media/Review.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Media 2 | { 3 | using System.Text.Json.Serialization; 4 | 5 | public class Review 6 | { 7 | [JsonNumberHandling(JsonNumberHandling.AllowReadingFromString)] 8 | [JsonPropertyName("id")] 9 | public long Id { get; set; } 10 | 11 | [JsonPropertyName("filter")] 12 | public string Filter { get; set; } 13 | 14 | [JsonPropertyName("tag")] 15 | public string Tag { get; set; } 16 | 17 | [JsonPropertyName("text")] 18 | public string Text { get; set; } 19 | 20 | [JsonPropertyName("image")] 21 | public string Image { get; set; } 22 | 23 | [JsonPropertyName("link")] 24 | public string Link { get; set; } 25 | 26 | [JsonPropertyName("source")] 27 | public string Source { get; set; } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Media/ScrapingId.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Media 2 | { 3 | using System.Text.Json.Serialization; 4 | 5 | public class ScrapingId 6 | { 7 | [JsonPropertyName("id")] 8 | public string Id { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Media/Setting.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Media 2 | { 3 | using System.Text.Json.Serialization; 4 | 5 | public class Setting 6 | { 7 | [JsonPropertyName("id")] 8 | public string Id { get; set; } 9 | 10 | [JsonPropertyName("label")] 11 | public string Label { get; set; } 12 | 13 | [JsonPropertyName("summary")] 14 | public string Summary { get; set; } 15 | 16 | [JsonPropertyName("type")] 17 | public string Type { get; set; } 18 | 19 | [JsonPropertyName("default")] 20 | public string Default { get; set; } 21 | 22 | [JsonPropertyName("value")] 23 | public string Value { get; set; } 24 | 25 | [JsonPropertyName("hidden")] 26 | public bool Hidden { get; set; } 27 | 28 | [JsonPropertyName("advanced")] 29 | public bool Advanced { get; set; } 30 | 31 | [JsonPropertyName("group")] 32 | public string Group { get; set; } 33 | 34 | [JsonPropertyName("enumValues")] 35 | public string EnumValues { get; set; } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Media/Similar.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Media 2 | { 3 | using System.Text.Json.Serialization; 4 | 5 | public class Similar 6 | { 7 | [JsonNumberHandling(JsonNumberHandling.AllowReadingFromString)] 8 | [JsonPropertyName("id")] 9 | public long Id { get; set; } 10 | 11 | [JsonPropertyName("filter")] 12 | public string Filter { get; set; } 13 | 14 | [JsonPropertyName("tag")] 15 | public string Tag { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Media/Writer.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Media 2 | { 3 | using System.Text.Json.Serialization; 4 | 5 | public class Writer 6 | { 7 | [JsonNumberHandling(JsonNumberHandling.AllowReadingFromString)] 8 | [JsonPropertyName("id")] 9 | public long Id { get; set; } 10 | 11 | [JsonPropertyName("filter")] 12 | public string Filter { get; set; } 13 | 14 | [JsonPropertyName("tag")] 15 | public string Tag { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/OAuth/Location.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.OAuth 2 | { 3 | /// 4 | /// Location Object 5 | /// 6 | public class Location 7 | { 8 | /// 9 | /// Code 10 | /// 11 | public string Code { get; set; } 12 | 13 | /// 14 | /// Country 15 | /// 16 | public string Country { get; set; } 17 | 18 | /// 19 | /// City 20 | /// 21 | public string City { get; set; } 22 | 23 | /// 24 | /// Sub Division 25 | /// 26 | public string Subdivisions { get; set; } 27 | 28 | /// 29 | /// Coordinates 30 | /// 31 | public string Coordinates { get; set; } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/OAuth/OAuthPin.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.OAuth 2 | { 3 | using System; 4 | 5 | /// 6 | /// OAuth Pin Object 7 | /// 8 | public class OAuthPin 9 | { 10 | /// 11 | /// Id 12 | /// 13 | public int Id { get; set; } 14 | 15 | /// 16 | /// Code 17 | /// 18 | public string Code { get; set; } 19 | 20 | /// 21 | /// Trusted 22 | /// 23 | public bool Trusted { get; set; } 24 | 25 | /// 26 | /// Client Identifier 27 | /// 28 | public string ClientIdentifier { get; set; } 29 | 30 | /// 31 | /// Location 32 | /// 33 | public Location Location { get; set; } 34 | 35 | /// 36 | /// Expires In 37 | /// 38 | public int ExpiresIn { get; set; } 39 | 40 | /// 41 | /// Created At 42 | /// 43 | public string CreatedAt { get; set; } 44 | 45 | /// 46 | /// Expires At 47 | /// 48 | public string ExpiresAt { get; set; } 49 | 50 | /// 51 | /// Auth Token 52 | /// 53 | public string AuthToken { get; set; } 54 | 55 | /// 56 | /// Url 57 | /// 58 | public string Url { get; set; } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/PlayQueues/PlayQueueContainer.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.PlayQueues 2 | { 3 | using System.Collections.Generic; 4 | using System.Text.Json.Serialization; 5 | using Media; 6 | 7 | public class PlayQueueContainer 8 | { 9 | [JsonPropertyName("size")] 10 | public int Size { get; set; } 11 | 12 | [JsonPropertyName("identifier")] 13 | public string Identifier { get; set; } 14 | 15 | [JsonPropertyName("mediaTagPrefix")] 16 | public string MediaTagPrefix { get; set; } 17 | 18 | [JsonPropertyName("mediaTagVersion")] 19 | public long MediaTagVersion { get; set; } 20 | 21 | [JsonPropertyName("playQueueID")] 22 | public long PlayQueueId { get; set; } 23 | 24 | [JsonPropertyName("playQueueSelectedItemID")] 25 | public long PlayQueueSelectedItemId { get; set; } 26 | 27 | [JsonPropertyName("playQueueSelectedItemOffset")] 28 | public long PlayQueueSelectedItemOffset { get; set; } 29 | 30 | [JsonPropertyName("playQueueSelectedMetadataItemID")] 31 | public string PlayQueueSelectedMetadataItemId { get; set; } 32 | 33 | [JsonPropertyName("playQueueShuffled")] 34 | public bool PlayQueueShuffled { get; set; } 35 | 36 | [JsonPropertyName("playQueueSourceURI")] 37 | public string PlayQueueSourceUri { get; set; } 38 | 39 | [JsonPropertyName("playQueueTotalCount")] 40 | public int PlayQueueTotalCount { get; set; } 41 | 42 | [JsonPropertyName("playQueueVersion")] 43 | public int PlayQueueVersion { get; set; } 44 | 45 | [JsonPropertyName("Metadata")] 46 | public List Media { get; set; } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Providers/Feature.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Providers 2 | { 3 | using System.Collections.Generic; 4 | using System.Text.Json.Serialization; 5 | 6 | /// 7 | /// Feature Object 8 | /// 9 | public class Feature 10 | { 11 | public string Key { get; set; } 12 | public string Type { get; set; } 13 | public string ScrobbleKey { get; set; } 14 | public string UnscrobbleKey { get; set; } 15 | 16 | [JsonPropertyName("Directory")] 17 | public List Directories { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Providers/FeatureDirectory.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Providers 2 | { 3 | using System.Collections.Generic; 4 | using System.Text.Json.Serialization; 5 | 6 | public class FeatureDirectory 7 | { 8 | public string Id { get; set; } 9 | public string HubKey { get; set; } 10 | public string Title { get; set; } 11 | 12 | [JsonPropertyName("Pivot")] 13 | public List Pivots { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Providers/FeatureDirectoryPivot.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Providers 2 | { 3 | /// 4 | /// Pivot Object 5 | /// 6 | public class FeatureDirectoryPivot 7 | { 8 | public string Id { get; set; } 9 | public string Key { get; set; } 10 | public string Type { get; set; } 11 | public string Title { get; set; } 12 | public string Context { get; set; } 13 | public string Symbol { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Providers/Provider.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Providers 2 | { 3 | using System.Collections.Generic; 4 | using System.Text.Json.Serialization; 5 | 6 | public class Provider 7 | { 8 | 9 | public int? Id { get; set; } 10 | 11 | [JsonPropertyName("parentID")] 12 | public int? ParentId { get; set; } 13 | 14 | /// 15 | /// 16 | /// 17 | public string Identifier { get; set; } 18 | 19 | /// 20 | /// 21 | /// 22 | public string ProviderIdentifier { get; set; } 23 | 24 | /// 25 | /// 26 | /// 27 | public string Title { get; set; } 28 | 29 | /// 30 | /// 31 | /// 32 | public string Types { get; set; } 33 | 34 | /// 35 | /// 36 | /// 37 | public string Protocols { get; set; } 38 | 39 | /// 40 | /// 41 | /// 42 | public string EpgSource { get; set; } 43 | 44 | /// 45 | /// 46 | /// 47 | [JsonPropertyName("Feature")] 48 | public List Features { get; set; } 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Server/Activities/Activity.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Server.Activities 2 | { 3 | using System.Text.Json.Serialization; 4 | 5 | public class Activity 6 | { 7 | [JsonPropertyName("uuid")] 8 | public string Uuid { get; set; } 9 | 10 | [JsonPropertyName("type")] 11 | public string Type { get; set; } 12 | 13 | [JsonPropertyName("cancellable")] 14 | public bool Cancellable { get; set; } 15 | 16 | [JsonPropertyName("userID")] 17 | public int UserId { get; set; } 18 | 19 | [JsonPropertyName("title")] 20 | public string Title { get; set; } 21 | 22 | [JsonPropertyName("subtitle")] 23 | public string Subtitle { get; set; } 24 | 25 | [JsonPropertyName("progress")] 26 | public int Progress { get; set; } 27 | 28 | [JsonPropertyName("Context")] 29 | public ActivityContext ActivityContext { get; set; } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Server/Activities/ActivityContainer.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Server.Activities 2 | { 3 | using System.Collections.Generic; 4 | using System.Text.Json.Serialization; 5 | 6 | public class ActivityContainer { 7 | [JsonPropertyName("size")] 8 | public int Size { get; set; } 9 | 10 | [JsonPropertyName("Activity")] 11 | public List Activity { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Server/Activities/ActivityContext.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Server.Activities 2 | { 3 | using System.Text.Json.Serialization; 4 | 5 | public class ActivityContext 6 | { 7 | [JsonPropertyName("librarySectionID")] 8 | public string LibrarySectionId { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Server/Clients/ClientMediaContainer.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Server.Clients 2 | { 3 | using System.Collections.Generic; 4 | using System.Text.Json.Serialization; 5 | 6 | public class ClientMediaContainer { 7 | [JsonPropertyName("size")] 8 | public int Size { get; set; } 9 | 10 | [JsonPropertyName("Server")] 11 | public List Server { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Server/Clients/ClientServer.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Server.Clients 2 | { 3 | using System.Text.Json.Serialization; 4 | 5 | public class ClientServer { 6 | [JsonPropertyName("name")] 7 | public string Name { get; set; } 8 | 9 | [JsonPropertyName("host")] 10 | public string Host { get; set; } 11 | 12 | [JsonPropertyName("address")] 13 | public string Address { get; set; } 14 | 15 | [JsonPropertyName("port")] 16 | public int Port { get; set; } 17 | 18 | [JsonPropertyName("machineIdentifier")] 19 | public string MachineIdentifier { get; set; } 20 | 21 | [JsonPropertyName("version")] 22 | public string Version { get; set; } 23 | 24 | [JsonPropertyName("protocol")] 25 | public string Protocol { get; set; } 26 | 27 | [JsonPropertyName("product")] 28 | public string Product { get; set; } 29 | 30 | [JsonPropertyName("deviceClass")] 31 | public string DeviceClass { get; set; } 32 | 33 | [JsonPropertyName("protocolVersion")] 34 | public string ProtocolVersion { get; set; } 35 | 36 | [JsonPropertyName("protocolCapabilities")] 37 | public string ProtocolCapabilities { get; set; } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Server/Devices/Device.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Server.Devices 2 | { 3 | using System.Text.Json.Serialization; 4 | 5 | public class Device 6 | { 7 | [JsonPropertyName("id")] 8 | public int Id { get; set; } 9 | 10 | [JsonPropertyName("name")] 11 | public string Name { get; set; } 12 | 13 | [JsonPropertyName("platform")] 14 | public string Platform { get; set; } 15 | 16 | [JsonPropertyName("clientIdentifier")] 17 | public string ClientIdentifier { get; set; } 18 | 19 | [JsonPropertyName("createdAt")] 20 | public long CreatedAt { get; set; } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Server/Devices/DeviceContainer.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Server.Devices 2 | { 3 | using System.Collections.Generic; 4 | using System.Text.Json.Serialization; 5 | 6 | public class DeviceContainer 7 | { 8 | [JsonPropertyName("size")] 9 | public int Size { get; set; } 10 | 11 | [JsonPropertyName("identifier")] 12 | public string Identifier { get; set; } 13 | 14 | [JsonPropertyName("Device")] 15 | public List Devices { get; set; } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Server/History/HistoryMediaContainer.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Server.History 2 | { 3 | using System.Collections.Generic; 4 | using System.Text.Json.Serialization; 5 | 6 | public class HistoryMediaContainer 7 | { 8 | public int Size { get; set; } 9 | public int TotalSize { get; set; } 10 | 11 | [JsonPropertyName("Metadata")] 12 | public List HistoryMetadata { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Server/History/HistoryMetadata.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Server.History; 2 | 3 | using System.Text.Json.Serialization; 4 | 5 | public class HistoryMetadata 6 | { 7 | public string HistoryKey { get; set; } 8 | public string Key { get; set; } 9 | public string RatingKey { get; set; } 10 | public string Title { get; set; } 11 | public string Type { get; set; } 12 | public string Thumb { get; set; } 13 | public string OriginallyAvailableAt { get; set; } 14 | public int ViewedAt { get; set; } 15 | 16 | [JsonPropertyName("accountID")] 17 | public int AccountId { get; set; } 18 | 19 | public string ParentKey { get; set; } 20 | 21 | [JsonPropertyName("grandparentKey")] 22 | public string GrandParentKey { get; set; } 23 | } 24 | 25 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Server/Playlists/Medium.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Server.Playlists 2 | { 3 | using System.Collections.Generic; 4 | using System.Text.Json.Serialization; 5 | 6 | public class Medium 7 | { 8 | [JsonPropertyName("aspectRatio")] 9 | public string AspectRatio { get; set; } 10 | 11 | [JsonPropertyName("audioChannels")] 12 | public string AudioChannels { get; set; } 13 | 14 | [JsonPropertyName("audioCodec")] 15 | public string AudioCodec { get; set; } 16 | 17 | [JsonPropertyName("bitrate")] 18 | public string Bitrate { get; set; } 19 | 20 | [JsonPropertyName("container")] 21 | public string Container { get; set; } 22 | 23 | [JsonPropertyName("duration")] 24 | public string Duration { get; set; } 25 | 26 | [JsonPropertyName("height")] 27 | public string Height { get; set; } 28 | 29 | [JsonPropertyName("id")] 30 | public string Id { get; set; } 31 | 32 | [JsonPropertyName("videoCodec")] 33 | public string VideoCodec { get; set; } 34 | 35 | [JsonPropertyName("videoFrameRate")] 36 | public string VideoFrameRate { get; set; } 37 | 38 | [JsonPropertyName("videoProfile")] 39 | public string VideoProfile { get; set; } 40 | 41 | [JsonPropertyName("videoResolution")] 42 | public string VideoResolution { get; set; } 43 | 44 | [JsonPropertyName("width")] 45 | public string Width { get; set; } 46 | 47 | [JsonPropertyName("selected")] 48 | public bool Selected { get; set; } 49 | 50 | [JsonPropertyName("Part")] 51 | public List Part { get; set; } 52 | 53 | [JsonPropertyName("audioProfile")] 54 | public string AudioProfile { get; set; } 55 | 56 | [JsonPropertyName("optimizedForStreaming")] 57 | public string OptimizedForStreaming { get; set; } 58 | 59 | [JsonPropertyName("protocol")] 60 | public string Protocol { get; set; } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Server/Playlists/Part.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Server.Playlists 2 | { 3 | using System.Collections.Generic; 4 | using System.Text.Json.Serialization; 5 | 6 | public class Part 7 | { 8 | [JsonPropertyName("container")] 9 | public string Container { get; set; } 10 | 11 | [JsonPropertyName("duration")] 12 | public string Duration { get; set; } 13 | 14 | [JsonPropertyName("file")] 15 | public string File { get; set; } 16 | 17 | [JsonPropertyName("id")] 18 | public string Id { get; set; } 19 | 20 | [JsonPropertyName("key")] 21 | public string Key { get; set; } 22 | 23 | [JsonPropertyName("size")] 24 | public string Size { get; set; } 25 | 26 | [JsonPropertyName("videoProfile")] 27 | public string VideoProfile { get; set; } 28 | 29 | [JsonPropertyName("decision")] 30 | public string Decision { get; set; } 31 | 32 | [JsonPropertyName("selected")] 33 | public bool Selected { get; set; } 34 | 35 | [JsonPropertyName("Stream")] 36 | public List Stream { get; set; } 37 | 38 | [JsonPropertyName("audioProfile")] 39 | public string AudioProfile { get; set; } 40 | 41 | [JsonPropertyName("bitrate")] 42 | public string Bitrate { get; set; } 43 | 44 | [JsonPropertyName("height")] 45 | public string Height { get; set; } 46 | 47 | [JsonPropertyName("optimizedForStreaming")] 48 | public string OptimizedForStreaming { get; set; } 49 | 50 | [JsonPropertyName("protocol")] 51 | public string Protocol { get; set; } 52 | 53 | [JsonPropertyName("width")] 54 | public string Width { get; set; } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Server/Playlists/Player.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Server.Playlists 2 | { 3 | using System.Text.Json.Serialization; 4 | 5 | public class Player 6 | { 7 | [JsonPropertyName("address")] 8 | public string Address { get; set; } 9 | 10 | [JsonPropertyName("device")] 11 | public string Device { get; set; } 12 | 13 | [JsonPropertyName("machineIdentifier")] 14 | public string MachineIdentifier { get; set; } 15 | 16 | [JsonPropertyName("model")] 17 | public string Model { get; set; } 18 | 19 | [JsonPropertyName("platform")] 20 | public string Platform { get; set; } 21 | 22 | [JsonPropertyName("platformVersion")] 23 | public string PlatformVersion { get; set; } 24 | 25 | [JsonPropertyName("product")] 26 | public string Product { get; set; } 27 | 28 | [JsonPropertyName("profile")] 29 | public string Profile { get; set; } 30 | 31 | [JsonPropertyName("remotePublicAddress")] 32 | public string RemotePublicAddress { get; set; } 33 | 34 | [JsonPropertyName("state")] 35 | public string State { get; set; } 36 | 37 | [JsonPropertyName("title")] 38 | public string Title { get; set; } 39 | 40 | [JsonPropertyName("vendor")] 41 | public string Vendor { get; set; } 42 | 43 | [JsonPropertyName("version")] 44 | public string Version { get; set; } 45 | 46 | [JsonPropertyName("local")] 47 | public bool Local { get; set; } 48 | 49 | [JsonPropertyName("relayed")] 50 | public bool Relayed { get; set; } 51 | 52 | [JsonPropertyName("secure")] 53 | public bool Secure { get; set; } 54 | 55 | [JsonPropertyName("userID")] 56 | public int UserID { get; set; } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Server/Playlists/PlaylistContainer.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Server.Playlists 2 | { 3 | using System.Collections.Generic; 4 | using System.Text.Json.Serialization; 5 | 6 | public class PlaylistContainer 7 | { 8 | [JsonPropertyName("size")] 9 | public int Size { get; set; } 10 | 11 | [JsonPropertyName("Metadata")] 12 | public List Metadata { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Server/Playlists/Session.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Server.Playlists 2 | { 3 | using System.Text.Json.Serialization; 4 | 5 | public class Session 6 | { 7 | [JsonPropertyName("id")] 8 | public string Id { get; set; } 9 | 10 | [JsonPropertyName("bandwidth")] 11 | public int Bandwidth { get; set; } 12 | 13 | [JsonPropertyName("location")] 14 | public string Location { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Server/Playlists/TranscodeSession.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Server.Playlists 2 | { 3 | using System.Text.Json.Serialization; 4 | 5 | public class TranscodeSession 6 | { 7 | [JsonPropertyName("key")] 8 | public string Key { get; set; } 9 | 10 | [JsonPropertyName("throttled")] 11 | public bool Throttled { get; set; } 12 | 13 | [JsonPropertyName("complete")] 14 | public bool Complete { get; set; } 15 | 16 | [JsonPropertyName("progress")] 17 | public double Progress { get; set; } 18 | 19 | [JsonPropertyName("size")] 20 | public int Size { get; set; } 21 | 22 | [JsonPropertyName("speed")] 23 | public string Speed { get; set; } 24 | 25 | [JsonPropertyName("duration")] 26 | public int Duration { get; set; } 27 | 28 | [JsonPropertyName("remaining")] 29 | public int Remaining { get; set; } 30 | 31 | [JsonPropertyName("context")] 32 | public string Context { get; set; } 33 | 34 | [JsonPropertyName("sourceVideoCodec")] 35 | public string SourceVideoCodec { get; set; } 36 | 37 | [JsonPropertyName("sourceAudioCodec")] 38 | public string SourceAudioCodec { get; set; } 39 | 40 | [JsonPropertyName("videoDecision")] 41 | public string VideoDecision { get; set; } 42 | 43 | [JsonPropertyName("audioDecision")] 44 | public string AudioDecision { get; set; } 45 | 46 | [JsonPropertyName("protocol")] 47 | public string Protocol { get; set; } 48 | 49 | [JsonPropertyName("container")] 50 | public string Container { get; set; } 51 | 52 | [JsonPropertyName("videoCodec")] 53 | public string VideoCodec { get; set; } 54 | 55 | [JsonPropertyName("audioCodec")] 56 | public string AudioCodec { get; set; } 57 | 58 | [JsonPropertyName("audioChannels")] 59 | public int AudioChannels { get; set; } 60 | 61 | [JsonPropertyName("transcodeHwRequested")] 62 | public bool TranscodeHwRequested { get; set; } 63 | 64 | [JsonPropertyName("transcodeHwFullPipeline")] 65 | public bool TranscodeHwFullPipeline { get; set; } 66 | 67 | [JsonPropertyName("timeStamp")] 68 | public string TimeStamp { get; set; } 69 | 70 | [JsonPropertyName("maxOffsetAvailable")] 71 | public string MaxOffsetAvailable { get; set; } 72 | 73 | [JsonPropertyName("minOffsetAvailable")] 74 | public string MinOffsetAvailable { get; set; } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Server/Playlists/User.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Server.Playlists 2 | { 3 | using System.Text.Json.Serialization; 4 | 5 | public class User 6 | { 7 | [JsonPropertyName("id")] 8 | public string Id { get; set; } 9 | 10 | [JsonPropertyName("thumb")] 11 | public string Thumb { get; set; } 12 | 13 | [JsonPropertyName("title")] 14 | public string Title { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Server/Playlists/Writer.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Server.Playlists 2 | { 3 | using System.Text.Json.Serialization; 4 | 5 | public class Writer 6 | { 7 | [JsonPropertyName("filter")] 8 | public string Filter { get; set; } 9 | 10 | [JsonPropertyName("id")] 11 | public string Id { get; set; } 12 | 13 | [JsonPropertyName("tag")] 14 | public string Tag { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Server/PlexServerContainer.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Server 2 | { 3 | using System.Text.Json.Serialization; 4 | 5 | public class PlexServerContainer 6 | { 7 | [JsonPropertyName("MediaContainer")] 8 | public PlexServer PlexServer { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Server/PlexServerDirectory.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Server; 2 | 3 | public class PlexServerDirectory 4 | { 5 | public int Count { get; set; } 6 | public string Key { get; set; } 7 | public string Title { get; set; } 8 | } 9 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Server/Sessions/Medium.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Server.Sessions 2 | { 3 | using System.Collections.Generic; 4 | using System.Text.Json.Serialization; 5 | 6 | public class Medium 7 | { 8 | [JsonPropertyName("aspectRatio")] 9 | public string AspectRatio { get; set; } 10 | 11 | [JsonPropertyName("audioChannels")] 12 | public int AudioChannels { get; set; } 13 | 14 | [JsonPropertyName("audioCodec")] 15 | public string AudioCodec { get; set; } 16 | 17 | [JsonPropertyName("bitrate")] 18 | public int Bitrate { get; set; } 19 | 20 | [JsonPropertyName("container")] 21 | public string Container { get; set; } 22 | 23 | [JsonPropertyName("duration")] 24 | public int Duration { get; set; } 25 | 26 | [JsonPropertyName("height")] 27 | public int Height { get; set; } 28 | 29 | [JsonPropertyName("id")] 30 | public string Id { get; set; } 31 | 32 | [JsonPropertyName("videoCodec")] 33 | public string VideoCodec { get; set; } 34 | 35 | [JsonPropertyName("videoFrameRate")] 36 | public string VideoFrameRate { get; set; } 37 | 38 | [JsonPropertyName("videoProfile")] 39 | public string VideoProfile { get; set; } 40 | 41 | [JsonPropertyName("videoResolution")] 42 | public string VideoResolution { get; set; } 43 | 44 | [JsonPropertyName("width")] 45 | public int Width { get; set; } 46 | 47 | [JsonPropertyName("selected")] 48 | public bool Selected { get; set; } 49 | 50 | [JsonPropertyName("Part")] 51 | public List Part { get; set; } 52 | 53 | [JsonPropertyName("audioProfile")] 54 | public string AudioProfile { get; set; } 55 | 56 | [JsonPropertyName("optimizedForStreaming")] 57 | public bool OptimizedForStreaming { get; set; } 58 | 59 | [JsonPropertyName("protocol")] 60 | public string Protocol { get; set; } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Server/Sessions/Part.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Server.Sessions 2 | { 3 | using System.Collections.Generic; 4 | using System.Text.Json.Serialization; 5 | 6 | public class Part 7 | { 8 | [JsonPropertyName("container")] 9 | public string Container { get; set; } 10 | 11 | [JsonPropertyName("duration")] 12 | public long Duration { get; set; } 13 | 14 | [JsonPropertyName("file")] 15 | public string File { get; set; } 16 | 17 | [JsonPropertyName("id")] 18 | public string Id { get; set; } 19 | 20 | [JsonPropertyName("key")] 21 | public string Key { get; set; } 22 | 23 | [JsonPropertyName("size")] 24 | public long Size { get; set; } 25 | 26 | [JsonPropertyName("videoProfile")] 27 | public string VideoProfile { get; set; } 28 | 29 | [JsonPropertyName("decision")] 30 | public string Decision { get; set; } 31 | 32 | [JsonPropertyName("selected")] 33 | public bool Selected { get; set; } 34 | 35 | [JsonPropertyName("Stream")] 36 | public List Stream { get; set; } 37 | 38 | [JsonPropertyName("audioProfile")] 39 | public string AudioProfile { get; set; } 40 | 41 | [JsonPropertyName("bitrate")] 42 | public int Bitrate { get; set; } 43 | 44 | [JsonPropertyName("height")] 45 | public int Height { get; set; } 46 | 47 | [JsonPropertyName("optimizedForStreaming")] 48 | public bool OptimizedForStreaming { get; set; } 49 | 50 | [JsonPropertyName("protocol")] 51 | public string Protocol { get; set; } 52 | 53 | [JsonPropertyName("width")] 54 | public int Width { get; set; } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Server/Sessions/Player.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Server.Sessions 2 | { 3 | using System.Text.Json.Serialization; 4 | 5 | public class Player 6 | { 7 | public string Address { get; set; } 8 | public string Device { get; set; } 9 | public string MachineIdentifier { get; set; } 10 | public string Model { get; set; } 11 | public string Platform { get; set; } 12 | public string PlatformVersion { get; set; } 13 | public string Product { get; set; } 14 | public string Profile { get; set; } 15 | public string RemotePublicAddress { get; set; } 16 | public string State { get; set; } 17 | public string Title { get; set; } 18 | public string Vendor { get; set; } 19 | public string Version { get; set; } 20 | 21 | public bool Local { get; set; } 22 | public bool Relayed { get; set; } 23 | public bool Secure { get; set; } 24 | 25 | [JsonPropertyName("userID")] 26 | public int UserID { get; set; } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Server/Sessions/Session.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Server.Sessions 2 | { 3 | using System.Text.Json.Serialization; 4 | 5 | public class Session 6 | { 7 | [JsonPropertyName("id")] 8 | public string Id { get; set; } 9 | 10 | [JsonPropertyName("bandwidth")] 11 | public int Bandwidth { get; set; } 12 | 13 | [JsonPropertyName("location")] 14 | public string Location { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Server/Sessions/SessionContainer.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Server.Sessions 2 | { 3 | using System.Collections.Generic; 4 | using System.Text.Json.Serialization; 5 | 6 | public class SessionContainer 7 | { 8 | [JsonPropertyName("size")] 9 | public int Size { get; set; } 10 | 11 | [JsonPropertyName("Metadata")] 12 | public List Metadata { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Server/Sessions/TranscodeSession.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Server.Sessions 2 | { 3 | using System.Text.Json.Serialization; 4 | 5 | public class TranscodeSession 6 | { 7 | [JsonPropertyName("key")] 8 | public string Key { get; set; } 9 | 10 | [JsonPropertyName("throttled")] 11 | public bool Throttled { get; set; } 12 | 13 | [JsonPropertyName("complete")] 14 | public bool Complete { get; set; } 15 | 16 | [JsonPropertyName("progress")] 17 | public double Progress { get; set; } 18 | 19 | [JsonPropertyName("size")] 20 | public int Size { get; set; } 21 | 22 | [JsonPropertyName("speed")] 23 | public float Speed { get; set; } 24 | 25 | [JsonPropertyName("duration")] 26 | public int Duration { get; set; } 27 | 28 | [JsonPropertyName("remaining")] 29 | public int Remaining { get; set; } 30 | 31 | [JsonPropertyName("context")] 32 | public string Context { get; set; } 33 | 34 | [JsonPropertyName("sourceVideoCodec")] 35 | public string SourceVideoCodec { get; set; } 36 | 37 | [JsonPropertyName("sourceAudioCodec")] 38 | public string SourceAudioCodec { get; set; } 39 | 40 | [JsonPropertyName("videoDecision")] 41 | public string VideoDecision { get; set; } 42 | 43 | [JsonPropertyName("audioDecision")] 44 | public string AudioDecision { get; set; } 45 | 46 | [JsonPropertyName("protocol")] 47 | public string Protocol { get; set; } 48 | 49 | [JsonPropertyName("container")] 50 | public string Container { get; set; } 51 | 52 | [JsonPropertyName("videoCodec")] 53 | public string VideoCodec { get; set; } 54 | 55 | [JsonPropertyName("audioCodec")] 56 | public string AudioCodec { get; set; } 57 | 58 | [JsonPropertyName("audioChannels")] 59 | public int AudioChannels { get; set; } 60 | 61 | [JsonPropertyName("transcodeHwRequested")] 62 | public bool TranscodeHwRequested { get; set; } 63 | 64 | [JsonPropertyName("transcodeHwFullPipeline")] 65 | public bool TranscodeHwFullPipeline { get; set; } 66 | 67 | [JsonPropertyName("timeStamp")] 68 | public double TimeStamp { get; set; } 69 | 70 | [JsonPropertyName("maxOffsetAvailable")] 71 | public double MaxOffsetAvailable { get; set; } 72 | 73 | [JsonPropertyName("minOffsetAvailable")] 74 | public double MinOffsetAvailable { get; set; } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Server/Sessions/User.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Server.Sessions 2 | { 3 | using System.Text.Json.Serialization; 4 | 5 | public class User 6 | { 7 | [JsonPropertyName("id")] 8 | public string Id { get; set; } 9 | 10 | [JsonPropertyName("thumb")] 11 | public string Thumb { get; set; } 12 | 13 | [JsonPropertyName("title")] 14 | public string Title { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Server/Sessions/Writer.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Server.Sessions 2 | { 3 | using System.Text.Json.Serialization; 4 | 5 | public class Writer 6 | { 7 | [JsonPropertyName("filter")] 8 | public string Filter { get; set; } 9 | 10 | [JsonPropertyName("id")] 11 | public string Id { get; set; } 12 | 13 | [JsonPropertyName("tag")] 14 | public string Tag { get; set; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Server/Statistics/StatisticContainer.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Server.Statistics 2 | { 3 | using System.Collections.Generic; 4 | using System.Text.Json.Serialization; 5 | 6 | public class StatisticContainer 7 | { 8 | [JsonPropertyName("size")] 9 | public int Size { get; set; } 10 | 11 | [JsonPropertyName("StatisticsResources")] 12 | public List StatisticsResources { get; set; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Server/Statistics/StatisticsResource.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Server.Statistics 2 | { 3 | using System.Text.Json.Serialization; 4 | 5 | public class StatisticsResource 6 | { 7 | [JsonPropertyName("timespan")] 8 | public int Timespan { get; set; } 9 | 10 | [JsonPropertyName("at")] 11 | public int At { get; set; } 12 | 13 | [JsonPropertyName("hostCpuUtilization")] 14 | public double HostCpuUtilization { get; set; } 15 | 16 | [JsonPropertyName("processCpuUtilization")] 17 | public double ProcessCpuUtilization { get; set; } 18 | 19 | [JsonPropertyName("hostMemoryUtilization")] 20 | public double HostMemoryUtilization { get; set; } 21 | 22 | [JsonPropertyName("processMemoryUtilization")] 23 | public double ProcessMemoryUtilization { get; set; } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Server/Transcoders/TranscodeContainer.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Server.Transcoders 2 | { 3 | using System.Collections.Generic; 4 | using System.Text.Json.Serialization; 5 | 6 | public class TranscodeContainer { 7 | [JsonPropertyName("size")] 8 | public int Size { get; set; } 9 | 10 | [JsonPropertyName("TranscodeSession")] 11 | public List TranscodeSession { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Server/Transcoders/TranscodeSession.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Server.Transcoders 2 | { 3 | using System.Text.Json.Serialization; 4 | 5 | public class TranscodeSession 6 | { 7 | [JsonPropertyName("key")] 8 | public string Key { get; set; } 9 | 10 | [JsonPropertyName("throttled")] 11 | public bool Throttled { get; set; } 12 | 13 | [JsonPropertyName("complete")] 14 | public bool Complete { get; set; } 15 | 16 | [JsonPropertyName("progress")] 17 | public double Progress { get; set; } 18 | 19 | [JsonPropertyName("size")] 20 | public int Size { get; set; } 21 | 22 | [JsonPropertyName("speed")] 23 | public float Speed { get; set; } 24 | 25 | [JsonPropertyName("duration")] 26 | public int Duration { get; set; } 27 | 28 | [JsonPropertyName("remaining")] 29 | public int Remaining { get; set; } 30 | 31 | [JsonPropertyName("context")] 32 | public string Context { get; set; } 33 | 34 | [JsonPropertyName("sourceVideoCodec")] 35 | public string SourceVideoCodec { get; set; } 36 | 37 | [JsonPropertyName("sourceAudioCodec")] 38 | public string SourceAudioCodec { get; set; } 39 | 40 | [JsonPropertyName("videoDecision")] 41 | public string VideoDecision { get; set; } 42 | 43 | [JsonPropertyName("audioDecision")] 44 | public string AudioDecision { get; set; } 45 | 46 | [JsonPropertyName("protocol")] 47 | public string Protocol { get; set; } 48 | 49 | [JsonPropertyName("container")] 50 | public string Container { get; set; } 51 | 52 | [JsonPropertyName("videoCodec")] 53 | public string VideoCodec { get; set; } 54 | 55 | [JsonPropertyName("audioCodec")] 56 | public string AudioCodec { get; set; } 57 | 58 | [JsonPropertyName("audioChannels")] 59 | public int AudioChannels { get; set; } 60 | 61 | [JsonPropertyName("transcodeHwRequested")] 62 | public bool TranscodeHwRequested { get; set; } 63 | 64 | [JsonPropertyName("transcodeHwFullPipeline")] 65 | public bool TranscodeHwFullPipeline { get; set; } 66 | 67 | [JsonPropertyName("timeStamp")] 68 | public double TimeStamp { get; set; } 69 | 70 | [JsonPropertyName("maxOffsetAvailable")] 71 | public double MaxOffsetAvailable { get; set; } 72 | 73 | [JsonPropertyName("minOffsetAvailable")] 74 | public double MinOffsetAvailable { get; set; } 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Server/TransientTokenContainer.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Server 2 | { 3 | using System.Text.Json.Serialization; 4 | 5 | public class TransientTokenContainer 6 | { 7 | [JsonPropertyName("size")] 8 | public int Size { get; set; } 9 | 10 | [JsonPropertyName("token")] 11 | public string Token { get; set; } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Server/Updates/Release.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Server.Updates 2 | { 3 | using System.Text.Json.Serialization; 4 | 5 | /// 6 | /// 7 | /// 8 | public class Release 9 | { 10 | [JsonPropertyName("key")] 11 | public string Key { get; set; } 12 | 13 | [JsonPropertyName("version")] 14 | public string Version { get; set; } 15 | 16 | [JsonPropertyName("added")] 17 | public string Added { get; set; } 18 | 19 | [JsonPropertyName("fixed")] 20 | public string Fixed { get; set; } 21 | 22 | /// 23 | /// 24 | /// 25 | [JsonPropertyName("downloadURL")] 26 | public string DownloadUrl { get; set; } 27 | 28 | [JsonPropertyName("state")] 29 | public string State { get; set; } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Source/Plex.ServerApi/PlexModels/Server/Updates/UpdateContainer.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.PlexModels.Server.Updates 2 | { 3 | using System.Collections.Generic; 4 | using System.Text.Json.Serialization; 5 | 6 | public class UpdateContainer 7 | { 8 | [JsonPropertyName("size")] 9 | public int Size { get; set; } 10 | 11 | [JsonPropertyName("canInstall")] 12 | public bool CanInstall { get; set; } 13 | 14 | [JsonPropertyName("checkedAt")] 15 | public int CheckedAt { get; set; } 16 | 17 | [JsonPropertyName("status")] 18 | public int Status { get; set; } 19 | 20 | [JsonPropertyName("Release")] 21 | public List Releases { get; set; } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Tests/.editorconfig: -------------------------------------------------------------------------------- 1 | ########################################## 2 | # StyleCop 3 | ########################################## 4 | 5 | [*] 6 | # SA0001: XML comment analysis is disabled due to project configuration 7 | # Justification: Comments turned off 8 | # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA0001.md 9 | dotnet_diagnostic.SA0001.severity = none 10 | 11 | [*.cs] 12 | # SA1600: A C# code element is missing a documentation header. 13 | # Justification: Comments turned off 14 | # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1600.md 15 | dotnet_diagnostic.SA1600.severity = none 16 | 17 | # SA1601: A C# partial element is missing a documentation header. 18 | # Justification: Comments turned off 19 | # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1601.md 20 | dotnet_diagnostic.SA1601.severity = none 21 | 22 | # SA1602: An item within a C# enumeration is missing an XML documentation header. 23 | # Justification: Comments turned off 24 | # https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1602.md 25 | dotnet_diagnostic.SA1602.severity = none 26 | 27 | ########################################## 28 | # Custom 29 | ########################################## 30 | 31 | [*.cs] 32 | # CA1062: Validate arguments of public methods 33 | # Justification: xUnit Theory method parameters don't need to be validated 34 | # https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1062 35 | dotnet_diagnostic.CA1062.severity = none 36 | 37 | # CA1707: Identifiers should not contain underscores 38 | # Justification: Test method names contain underscores 39 | # https://docs.microsoft.com/en-us/visualstudio/code-quality/ca1707 40 | dotnet_diagnostic.CA1707.severity = none 41 | -------------------------------------------------------------------------------- /Tests/Plex.Library.Test/Plex.Library.Test.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net7.0 5 | 28d1554b-79da-4a82-b7f7-4779a8c8ae95 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | runtime; build; native; contentfiles; analyzers; buildtransitive 19 | all 20 | 21 | 22 | runtime; build; native; contentfiles; analyzers; buildtransitive 23 | all 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /Tests/Plex.Library.Test/PlexFixture.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.Library.Test 2 | { 3 | using Microsoft.Extensions.Configuration; 4 | using Microsoft.Extensions.DependencyInjection; 5 | using Microsoft.Extensions.Logging; 6 | using ServerApi; 7 | using ServerApi.Api; 8 | using ServerApi.Clients; 9 | using ServerApi.Clients.Interfaces; 10 | 11 | public class PlexFixture 12 | { 13 | public PlexFixture() 14 | { 15 | IConfiguration configuration = new ConfigurationBuilder() 16 | .AddUserSecrets() 17 | .Build(); 18 | 19 | var clientOptions = new ClientOptions 20 | { 21 | Platform = "Web", 22 | Product = "API_UnitTests", 23 | DeviceName = "API_UnitTests", 24 | ClientId = "PlexApi", 25 | Version = "v1", 26 | }; 27 | 28 | var testConfiguration = new TestConfiguration(configuration["Plex:Host"], 29 | configuration["Plex:AuthenticationKey"],configuration["Plex:Login"], 30 | configuration["Plex:Password"]); 31 | 32 | var services = new ServiceCollection(); 33 | services.AddLogging(configure=> configure.AddConsole()); 34 | services.AddSingleton(testConfiguration); 35 | services.AddSingleton(clientOptions); 36 | services.AddTransient(); 37 | services.AddTransient(); 38 | services.AddTransient(); 39 | services.AddTransient(); 40 | services.AddTransient(); 41 | 42 | 43 | this.ServiceProvider = services.BuildServiceProvider(); 44 | } 45 | 46 | public ServiceProvider ServiceProvider { get; set; } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Tests/Plex.Library.Test/TestConfiguration.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.Library.Test 2 | { 3 | public class TestConfiguration 4 | { 5 | public string Host { get; } 6 | public string AuthenticationKey { get; } 7 | public string Login { get; set; } 8 | public string Password { get; set; } 9 | 10 | public TestConfiguration(string host, string authenticationKey, string login, string password) 11 | { 12 | this.Host = host; 13 | this.AuthenticationKey = authenticationKey; 14 | this.Login = login; 15 | this.Password = password; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Tests/Plex.ServerApi.Test/Plex.ServerApi.Test.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net7.0 5 | 28d1554b-79da-4a82-b7f7-4779a8c8ae95 6 | Library 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | all 18 | runtime; build; native; contentfiles; analyzers; buildtransitive 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Tests/Plex.ServerApi.Test/TestConfiguration.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.Test 2 | { 3 | public class TestConfiguration 4 | { 5 | public string Login { get; } 6 | public string Password { get; } 7 | public string AccessToken { get; } 8 | public ClientOptions ClientOptions { get; } 9 | 10 | public TestConfiguration(string login, string password, string accessToken, ClientOptions clientOptions) 11 | { 12 | this.Login = login; 13 | this.Password = password; 14 | this.AccessToken = accessToken; 15 | this.ClientOptions = clientOptions; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Tests/Plex.ServerApi.Test/Tests/MediaTest.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.Test.Tests 2 | { 3 | using Xunit; 4 | using Xunit.Abstractions; 5 | 6 | public class MediaTest : IClassFixture 7 | { 8 | private readonly PlexFixture fixture; 9 | private readonly ITestOutputHelper output; 10 | 11 | public MediaTest(ITestOutputHelper output, PlexFixture fixture) 12 | { 13 | this.output = output; 14 | this.fixture = fixture; 15 | } 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Tests/Plex.ServerApi.Test/Tests/PhotoLibraryTest.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.ServerApi.Test.Tests 2 | { 3 | using Xunit; 4 | using Xunit.Abstractions; 5 | 6 | public class PhotoLibraryTest : IClassFixture 7 | { 8 | private readonly PlexFixture fixture; 9 | private readonly ITestOutputHelper output; 10 | 11 | public PhotoLibraryTest(ITestOutputHelper output, PlexFixture fixture) 12 | { 13 | this.output = output; 14 | this.fixture = fixture; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Tests/Plex.WebApi.IntegrationTest/CustomWebApplicationFactory.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.WebApi.IntegrationTest 2 | { 3 | using System; 4 | using System.Net.Http; 5 | using Plex.WebApi.Options; 6 | using Plex.WebApi.Services; 7 | using Microsoft.AspNetCore.Hosting; 8 | using Microsoft.AspNetCore.Mvc.Testing; 9 | using Microsoft.Extensions.DependencyInjection; 10 | using Microsoft.Extensions.Options; 11 | using Moq; 12 | using Serilog; 13 | using Serilog.Events; 14 | using Xunit.Abstractions; 15 | 16 | public class CustomWebApplicationFactory : WebApplicationFactory 17 | where TEntryPoint : class 18 | { 19 | public CustomWebApplicationFactory(ITestOutputHelper testOutputHelper) 20 | { 21 | this.ClientOptions.AllowAutoRedirect = false; 22 | this.Server.AllowSynchronousIO = true; 23 | 24 | Log.Logger = new LoggerConfiguration() 25 | .WriteTo.Debug() 26 | .WriteTo.TestOutput(testOutputHelper, LogEventLevel.Verbose) 27 | .CreateLogger(); 28 | } 29 | 30 | public ApplicationOptions ApplicationOptions { get; private set; } 31 | 32 | public Mock ClockServiceMock { get; } = new Mock(MockBehavior.Strict); 33 | 34 | public void VerifyAllMocks() => Mock.VerifyAll(this.ClockServiceMock); 35 | 36 | protected override void ConfigureClient(HttpClient client) 37 | { 38 | using (var serviceScope = this.Services.CreateScope()) 39 | { 40 | var serviceProvider = serviceScope.ServiceProvider; 41 | this.ApplicationOptions = serviceProvider.GetRequiredService>().Value; 42 | } 43 | 44 | base.ConfigureClient(client); 45 | } 46 | 47 | protected override void ConfigureWebHost(IWebHostBuilder builder) => 48 | builder 49 | .UseEnvironment("Test") 50 | .ConfigureServices(this.ConfigureServices); 51 | 52 | protected virtual void ConfigureServices(IServiceCollection services) => 53 | services.AddSingleton(this.ClockServiceMock.Object); 54 | 55 | protected override void Dispose(bool disposing) 56 | { 57 | if (disposing) 58 | { 59 | this.VerifyAllMocks(); 60 | } 61 | 62 | base.Dispose(disposing); 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /Tests/Plex.WebApi.IntegrationTest/HealthCheckTest.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.WebApi.IntegrationTest.Controllers 2 | { 3 | using System; 4 | using System.Net; 5 | using System.Net.Http; 6 | using System.Threading.Tasks; 7 | using Xunit; 8 | using Xunit.Abstractions; 9 | 10 | public class HealthCheckTest : CustomWebApplicationFactory 11 | { 12 | private readonly HttpClient client; 13 | 14 | public HealthCheckTest(ITestOutputHelper testOutputHelper) 15 | : base(testOutputHelper) => 16 | this.client = this.CreateClient(); 17 | 18 | [Fact] 19 | public async Task GetStatus_Default_Returns200OkAsync() 20 | { 21 | var response = await this.client.GetAsync(new Uri("/status", UriKind.Relative)).ConfigureAwait(false); 22 | 23 | Assert.Equal(HttpStatusCode.OK, response.StatusCode); 24 | } 25 | 26 | [Fact] 27 | public async Task GetStatusSelf_Default_Returns200OkAsync() 28 | { 29 | var response = await this.client.GetAsync(new Uri("/status/self", UriKind.Relative)).ConfigureAwait(false); 30 | 31 | Assert.Equal(HttpStatusCode.OK, response.StatusCode); 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Tests/Plex.WebApi.IntegrationTest/HttpClientExtensions.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.WebApi.IntegrationTest 2 | { 3 | using System; 4 | using System.Net.Http; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | public static class HttpClientExtensions 9 | { 10 | private const string GraphQLContentType = "application/graphql"; 11 | 12 | public static Task PostGraphQLAsync(this HttpClient httpClient, string content) 13 | { 14 | if (httpClient is null) 15 | { 16 | throw new ArgumentNullException(nameof(httpClient)); 17 | } 18 | 19 | if (content is null) 20 | { 21 | throw new ArgumentNullException(nameof(content)); 22 | } 23 | 24 | if (content.Length == 0) 25 | { 26 | throw new ArgumentException("Cannot be empty.", nameof(content)); 27 | } 28 | 29 | using var stringContent = new StringContent(content, Encoding.UTF8, GraphQLContentType); 30 | return httpClient.PostAsync(new Uri("/graphql", UriKind.Relative), stringContent); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Tests/Plex.WebApi.IntegrationTest/Models/GraphQLError.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.WebApi.IntegrationTest.Models 2 | { 3 | using System.Collections.Generic; 4 | 5 | public class GraphQLError 6 | { 7 | public GraphQLError() => this.Locations = new List(); 8 | 9 | public string Message { get; set; } 10 | 11 | public List Locations { get; } 12 | 13 | public GraphQLErrorExtensions Extensions { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Tests/Plex.WebApi.IntegrationTest/Models/GraphQLErrorExtensions.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.WebApi.IntegrationTest.Models 2 | { 3 | public class GraphQLErrorExtensions 4 | { 5 | public string Code { get; set; } 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Tests/Plex.WebApi.IntegrationTest/Models/GraphQLErrorLocation.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.WebApi.IntegrationTest.Models 2 | { 3 | public class GraphQLErrorLocation 4 | { 5 | public int Line { get; set; } 6 | 7 | public int Column { get; set; } 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /Tests/Plex.WebApi.IntegrationTest/Models/GraphQLResponse.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.WebApi.IntegrationTest.Models 2 | { 3 | using System.Collections.Generic; 4 | 5 | public class GraphQLResponse 6 | { 7 | public GraphQLResponse() => this.Errors = new List(); 8 | 9 | public List Errors { get; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Tests/Plex.WebApi.IntegrationTest/Plex.WebApi.IntegrationTest.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | 7 | 8 | 9 | runtime; build; native; contentfiles; analyzers; buildtransitive 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | runtime; build; native; contentfiles; analyzers 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Tests/Plex.WebApi.IntegrationTest/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:21722/", 7 | "sslPort": 44387 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "Plex.WebApi.IntegrationTest": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "environmentVariables": { 22 | "ASPNETCORE_ENVIRONMENT": "Development" 23 | }, 24 | "applicationUrl": "https://localhost:5001;http://localhost:5000" 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /Tests/Plex.WebApi.IntegrationTest/QueryTest.cs: -------------------------------------------------------------------------------- 1 | namespace Plex.WebApi.IntegrationTest.Controllers 2 | { 3 | using System.Net; 4 | using System.Net.Http; 5 | using System.Threading.Tasks; 6 | using Plex.WebApi.IntegrationTest.Constants; 7 | using Plex.WebApi.IntegrationTest.Models; 8 | using Xunit; 9 | using Xunit.Abstractions; 10 | 11 | public class QueryTest : CustomWebApplicationFactory 12 | { 13 | private readonly HttpClient client; 14 | 15 | public QueryTest(ITestOutputHelper testOutputHelper) 16 | : base(testOutputHelper) => 17 | this.client = this.CreateClient(); 18 | 19 | [Fact] 20 | public async Task IntrospectionQuery_Default_Returns200OkAsync() 21 | { 22 | var response = await this.client.PostGraphQLAsync(GraphQlQuery.Introspection).ConfigureAwait(false); 23 | 24 | var graphQlResponse = await response.Content.ReadAsAsync().ConfigureAwait(false); 25 | Assert.Equal(HttpStatusCode.OK, response.StatusCode); 26 | Assert.Empty(graphQlResponse.Errors); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Tests/Plex.WebApi.IntegrationTest/xunit.runner.json: -------------------------------------------------------------------------------- 1 | { 2 | "shadowCopy": false 3 | } 4 | -------------------------------------------------------------------------------- /global.json: -------------------------------------------------------------------------------- 1 | { 2 | "sdk": { 3 | "version": "7.0.400" 4 | } 5 | } 6 | --------------------------------------------------------------------------------