예제 #1
0
 /// <summary>
 /// This is the entry point to the Api.  This will initialize an Account object from
 /// your plex login information.
 /// </summary>
 /// <param name="plexServerClient"></param>
 /// <param name="plexAccountClient"></param>
 /// <param name="plexLibraryClient"></param>
 public PlexFactory(IPlexServerClient plexServerClient, IPlexAccountClient plexAccountClient,
                    IPlexLibraryClient plexLibraryClient)
 {
     this.plexServerClient  = plexServerClient;
     this.plexAccountClient = plexAccountClient;
     this.plexLibraryClient = plexLibraryClient;
 }
예제 #2
0
 public ServerTest(ITestOutputHelper output, PlexFixture fixture)
 {
     this.output            = output;
     this.serviceProvider   = fixture.ServiceProvider;
     this.config            = fixture.ServiceProvider.GetService <TestConfiguration>();
     this.plexServerClient  = fixture.ServiceProvider.GetService <IPlexServerClient>();
     this.plexLibraryClient = fixture.ServiceProvider.GetService <IPlexLibraryClient>();
 }
예제 #3
0
        /// <summary>
        /// Initialize PlexAccount instance.
        /// </summary>
        /// <param name="plexAccountClient">IPlexAccountClient instance.</param>
        /// <param name="plexServerClient">IPlexServerClient instance.</param>
        /// <param name="plexLibraryClient">IPlexLibraryClient instance.</param>
        /// <param name="authToken">Plex Auth Token.</param>
        /// <exception cref="ArgumentNullException"></exception>
        public PlexAccount(IPlexAccountClient plexAccountClient, IPlexServerClient plexServerClient,
                           IPlexLibraryClient plexLibraryClient, string authToken)
        {
            if (string.IsNullOrEmpty(authToken))
            {
                throw new ArgumentNullException(nameof(authToken));
            }

            this.plexAccountClient = plexAccountClient ?? throw new ArgumentNullException(nameof(plexAccountClient));
            this.plexServerClient  = plexServerClient ?? throw new ArgumentNullException(nameof(plexServerClient));
            this.plexLibraryClient = plexLibraryClient ?? throw new ArgumentNullException(nameof(plexLibraryClient));

            var account = plexAccountClient.GetPlexAccountAsync(authToken).Result;

            ObjectMapper.Mapper.Map(account, this);
        }
예제 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="plexServerClient">Plex Server Client</param>
        /// <param name="plexLibraryClient">Plex Library Client</param>
        /// <param name="accountServer">Account Server Object</param>
        /// <exception cref="ArgumentNullException">Invalid Account Server</exception>
        public Server(IPlexServerClient plexServerClient, IPlexLibraryClient plexLibraryClient, AccountServer accountServer)
        {
            this.plexServerClient  = plexServerClient ?? throw new ArgumentNullException(nameof(plexServerClient));
            this.plexLibraryClient = plexLibraryClient ?? throw new ArgumentNullException(nameof(plexLibraryClient));

            if (accountServer == null)
            {
                throw new ArgumentNullException(nameof(accountServer));
            }

            // Map AccountServer to this Server Object (Mainly to get Access Token and Host)
            ObjectMapper.Mapper.Map(accountServer, this);

            var serverModel = plexServerClient.GetPlexServerInfo(this.AccessToken, this.Uri.ToString()).Result;

            ObjectMapper.Mapper.Map(serverModel, this);
        }
예제 #5
0
        /// <summary>
        /// Initialize PlexAccount instance.
        /// </summary>
        /// <param name="plexAccountClient">IPlexAccountClient instance.</param>
        /// <param name="plexServerClient">IPlexServerClient instance.</param>
        /// <param name="plexLibraryClient">IPlexLibraryClient instance.</param>
        /// <param name="username">Plex account username.</param>
        /// <param name="password">Plex account password.</param>
        /// <exception cref="ArgumentNullException"></exception>
        public PlexAccount(IPlexAccountClient plexAccountClient, IPlexServerClient plexServerClient,
                           IPlexLibraryClient plexLibraryClient, string username, string password)
        {
            if (string.IsNullOrEmpty(username))
            {
                throw new ArgumentNullException(nameof(username));
            }

            if (string.IsNullOrEmpty(password))
            {
                throw new ArgumentNullException(nameof(password));
            }

            this.plexAccountClient = plexAccountClient ?? throw new ArgumentNullException(nameof(plexAccountClient));
            this.plexServerClient  = plexServerClient ?? throw new ArgumentNullException(nameof(plexServerClient));
            this.plexLibraryClient = plexLibraryClient ?? throw new ArgumentNullException(nameof(plexLibraryClient));

            var account = plexAccountClient.GetPlexAccountAsync(username, password).Result;

            ObjectMapper.Mapper.Map(account, this);
        }
예제 #6
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="plexServerClient"></param>
 /// <param name="plexLibraryClient"></param>
 /// <param name="server"></param>
 public MovieLibrary(IPlexServerClient plexServerClient, IPlexLibraryClient plexLibraryClient, Server server)
     : base(plexServerClient, plexLibraryClient, server)
 {
 }
예제 #7
0
 /// <summary>
 /// This will become the Base Object for All Plex Libraries.
 /// When we instantiate a library, we will pull all the Filter Fields, Sorts and Operators
 /// </summary>
 /// <param name="plexServerClient">Plex Server Client</param>
 /// <param name="plexLibraryClient">Plex Library Client</param>
 /// <param name="server">Server Object</param>
 public LibraryBase(IPlexServerClient plexServerClient, IPlexLibraryClient plexLibraryClient, Server server)
 {
     this._plexServerClient  = plexServerClient ?? throw new ArgumentNullException(nameof(plexServerClient));
     this._plexLibraryClient = plexLibraryClient ?? throw new ArgumentNullException(nameof(plexLibraryClient));
     this._server            = server ?? throw new ArgumentNullException(nameof(server));
 }