Giter Club home page Giter Club logo

plexrequestsapi's Introduction

PlexRequestsApi (name TBC)

Build Status

Note - Work in progress

This project contains a Web Api to allow for Plex server administrators to provide functionality to their users so they can request new content or flag existing content for review. Users should also be notified when requests are fulfilled and be able to see if content being requested is already available within Plex.

Data Providers

PlexRequests needs to be able to gather both TV and Movie data from varying 3rd party API's. The main purpose is to allow for users to request new content and the other is to try and match up existing Plex content to the data from the 3rd party API's to identify content already available on the server.

The following popular API's exist for retrieving metadata:

To begin with TheMovieDb will be the primary data provider for all content.

Getting Started

If you want to run the project in its existing state, it can be built and deployed using docker.

Pre-requisites

  • Docker
  • .NET Core 3.0
  • MSSQL Instance

Build & Run

This is in progress as the system is migrating to use a MSSQL database

plexrequestsapi's People

Contributors

jbond312 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

plexrequestsapi's Issues

Create ViewModels for TheMovieDbApi

TheMovieDbApi shouldn't expose its response directly from PlexRequestsApi. Instead, we should map them to an intermediary object that can then be returned. Giving more control over the responses being returned.

Improve Error Handling within API

At the moment, the services are throwing exceptions that are being caught in a generic middleware. The services are also able to specify which HTTP status code they want to return to. Whilst this works, I would prefer that the services are agnostic of any HTTP responses and that exceptions are only thrown when something exceptional happens.

Proposed changes:

  • Have each command/query return an object with a base response.
    For example it could look something like:
public class BaseResult
{
	public bool Success {get; set;}
	public string Message {get; set;}
	public string Description {get; set;}
	public ValidationFailures FailureReason {get; set;}
}

public enum ValidationFailures
{
	InvalidRequest,
	Unauthorised
}
  • Controllers are then responsible (as they should be) for returning the correct responses.
  • The exception middleware should only then be used for unhandled exceptions

Stop Tracking TV Shows - Automatic

As an Administrator, I'd like to setup a job that runs on a given schedule and checks to see if all currently tracked TV Shows are still in production and if not, they are automatically completed so that I do not have to manage this manually.

Criteria:

  • Only checks existing TV Shows that are actively being tracked
  • Job can be setup on a schedule defined by the user
  • Automatic comment is added if auto completed
  • InProduction status is determined by 3rd party Api (i.e. TheMovieDb)

Retrieve requests that have been created

As a user, I want to be able to view created requests so that I can see what media has already been requested.

Criteria:

  • Can filter by "my requests" (i.e. current user from jwt) (optional)
  • Can filter by Approval Status (Unapproved by default)
  • Can filter by Title (optional) (deep search into tv shows, i.e. episode names included)
  • Can filter by media type (i.e. TV/Movie) (optional)
  • Results are paginated (optional) (page = 1 and pagesize = 10 by default)

Synchronise Plex content on an interval

As an administrator, I would like to be able to synchronise content from a Plex server on a regular interval so that I do not need to manually perform the task.

Criteria:

  • The server must have a valid access token for the server
  • The task should run in the background
  • The sync must only be a partial sync (i.e. recently added content only)

Bddfy tests

Re-write any existing tests to follow a BDD approach using TestStack.Bddfy.

All future tests should follow this same methodology.

Improve Swagger Metadata

The controllers should be updated to provider further annotations to generate improved metadata for the swagger document. e.g. expected responses, expected response types, etc.

Stop tracking TV Shows - Manual

As an administrator I should be able to manually remove tracked TV shows i no longer wish to track.

Criteria:

  • Only Admin user can remove a tracked tv show
  • The reason for the tracked show ending should be set

Nice to have:

  • Handle an 'Ended' TV Show being restarted again.

Utilise web hooks to trigger plex synchronisation

As an admin, I want to be able to utilise existing web hooks that are available that can track new items being added to Plex so that the synchronisation happens as and when new content is added to Plex.

Criteria:

  • Identify webhooks that are available (Tautulli?)
  • Trigger a plex sync for a specific item or subset of items from the webhook result

Duplicate Seasons/Episodes in TV request

Summary of the Bug

When creating a TV show request. It is possible to include both duplicate seasons and episodes.

Steps To Reproduce

Steps to reproduce the behaviour:

  1. Login
  2. Create a TV show request. Ensure that the same season appears twice OR the same episode within a season twice

Expected Behaviour

The API should return an error stating that the payload was invalid as it contains duplicate season/episodes in request.

Actual Behaviour

The request is created successfully and the duplicate seasons/episodes are persisted to the database.

Request - Manual Completion

As an administrator, I would like to be able to automatically complete a request so that I do not have to rely upon the Plex synchronisation.

Criteria:

  • A request can be completed with a comment required by the user
  • The next time PlexSync is ran it should still try and resolve the PlexMediaItemUri so that a valid Uri can be set and the user can still navigate through to Plex. This should have a backoff mechanism so that we don't keep retrying everytime Plex sync's if no Uri is ever found.

Reject Requests

As an admin, I want to be able to reject requests so that I can respond to a request I do not intend to approve.

Criteria:

  • Can only reject requests that are not already complete or rejected
  • A comment should be given as to why the request was rejected
  • Individual episodes within a TV Show can be rejected, as well as the whole TV request overall
  • During PlexSync, if a rejected request is found within the Plex content, override and set it as completed.

Approve Movies

As an administrator, I should be able to approve an open request so that the user knows the content is being processed and will become available.

Criteria:

  • Cannot approve requests that have been approved
  • Can approve one or many requests

JSON integer 2792269749 is too large or small for an Int32. Path 'revenue'

Summary of the Bug

When attempting to make a request for a movie an unexpected error occurs. The movie in question is Avengers: Endgame

Steps To Reproduce

Steps to reproduce the behaviour:

  1. Login
  2. Search for movie 'Avengers Endgame' and copy id returned. Ensure it has not previously been requested
  3. Create a request for the movie

Expected Behaviour

The request should be created successfully

Actual Behaviour

An exception occurs:
JSON integer 2792269749 is too large or small for an Int32. Path 'revenue'

TV Request - Track a TV Show

As a user, I want the ability to track a TV show that still has future seasons/episodes to air so that I do not have to keep requesting new episodes as they air.

Criteria:

  • A TV request can set the option to track a show
  • A user should be able to see 'Tracked' shows separately from requests for specific episodes
  • If a show is already being tracked then any new requests should not be allowed for that same show if the episode has NOT yet been aired. i.e. A TV show can be tracked for future episodes but episodes already aired can still be requested as normal

Nice to have:

  • Validate whether a show is intending to still be aired

Return AccessToken and a RefreshToken on login

To help towards limiting the life of a token, the access token itself should be short lived but the refresh token long lived. This means that the client will have to request tokens more often but it ensures that if a user is disabled, the access will be short lived and prevented access on the next token refresh. This also helps remove the db call check on the OnTokenValidated handler.

Criteria:

  • Login & CreateAdmin endpoints should return a new structured object that includes the accessToken and refreshToken
  • AccessTokens should be short lived, i.e. 5-15mins
  • Refresh tokens should be valid for ~24hrs.

Remove previously created requests

As a user, I would like to remove a request I had previously made so that I can remove requests that are no longer required.

Criteria:

  • Only the user who created the request can remove it
  • The whole request should be removed (i.e. in the case of TV you cannot update specific seasons/episodes)
  • It should be a hard delete

Auto complete requests during Plex synchronisation

As an administrator, I would expect that any existing requests are automatically completed where the requested content is found within Plex during synchronisation so that I can avoid manual approvals when not necessary.

Criteria:

  • Auto completion of requests occur when a Plex sync is started
  • Auto approval during sync should be configurable by the admin (i.e. feature switch)
  • Plex content should match across all agent types stored against the request

Manage Plex Users

As an Administrator, I want to be able to view all imported users from Plex so that I can see who is able to make requests.

Criteria:

  • View existing users that were imported from Plex
  • Give specific rights to users (e.g. read only, no comments)
  • Disable a specific users
  • Re-enable a specific user (that still exists within Plex)

Approve TV Episodes

As an administrator I should be able to approve an TV requests so that the user can see that the request is being processed with the intention of the media becoming available.

Criteria:
- Cannot approve requests that are already approved

  • Can approve one or many requests at a time
  • Can approve one or many episodes within a request at a time
  • Have the option to approve the whole request in one go (without having to specify seasons/episodes in request)

E-mail notification of completed requests

As a user, I want to get an e-mail notification of any completed requests I have created so that I know when they become available in Plex.

Criteria:

  • E-mail should be sent to the associated Plex e-mail
  • Feature is configurable by the user to turn on/off
  • E-mail should aggregate completed requests to prevent e-mail spam. i.e. Perform notification after a Plex sync
  • E-mail should contain basic metadata about the request. i.e. Title, Year, Episodes (if TV), Resolution and Images

Persist additional Metadata about a Movie/TV Request

When creating a request for either a Movie or TV Show additional metadata should be stored to prevent further lookups to TheMovieDb Api.

Metadata to persist:

  • Title
  • ImagePath
  • Year
  • All 'ExternalIds' available from TheMovieDb for both Movies/Tv

Enable/Disable server libraries

As an administrator, I want to be able to either enable or disable libraries associated with the server so that they can either be included or excluded from Plex synchronisation.

Criteria:

  • Archived libraries cannot be updated
  • All disabled libraries should be excluded from Plex synchronisation

Create an Issue

As a user, I want to be able to raise an issue with an existing plex media item so that the plex admin can review and resolve it.

Criteria:

  • Issue's can be raised for any item found, it does not necessarily have to exist within Plex.
  • Multiple issue's can be raised for the same media item
  • Comments can be added to an issue
  • An issue can be in multiple states (i.e. Pending, In Progress, Resolved
  • A comment can have a Title and a Description.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.