From e2dca22cf93f70621ec5f46c6d8a248cdc8b7306 Mon Sep 17 00:00:00 2001 From: Jason House Date: Wed, 23 Sep 2020 22:31:59 +0900 Subject: [PATCH 1/3] Adding backend support --- .../gaps/properties/PlexProperties.java | 2 +- .../jasonhhouse/gaps/service/PlexQuery.java | 6 +- .../com/jasonhhouse/gaps/GapsApplication.java | 2 +- .../jasonhhouse/gaps/GapsUrlGenerator.java | 5 +- .../gaps/PlexServerToStringConverter.java | 1 + .../com/jasonhhouse/gaps/SearchGapsTask.java | 6 +- .../com/jasonhhouse/gaps/UrlGenerator.java | 5 +- .../controller/ConfigurationController.java | 22 +- .../gaps/controller/LibraryController.java | 13 +- .../gaps/controller/MislabeledController.java | 2 +- .../controller/PlexMovieListController.java | 4 +- .../gaps/controller/RSSController.java | 4 +- .../controller/RecommendedController.java | 13 +- .../gaps/service/GapsSearchService.java | 4 +- .../gaps/service/MediaContainerService.java | 2 +- .../gaps/service/MislabeledService.java | 4 +- .../gaps/service/Notification.java | 4 +- .../gaps/service/NotificationService.java | 4 +- .../gaps/service/PlexQueryImpl.java | 87 ++- .../jasonhhouse/gaps/service/RssService.java | 4 +- .../gaps/sql/MediaContainerRepository.java | 2 +- .../gaps/validator/PlexServerValidator.java | 2 +- .../src/main/resources/static/css/input.css | 8 + .../main/resources/static/js/configuration.js | 15 + .../resources/templates/configuration.html | 14 +- Plex/pom.xml | 6 + .../jasonhhouse/gaps/plex/PlexLibrary.java | 112 ++++ .../jasonhhouse/gaps/plex}/PlexServer.java | 96 ++- .../{ => gaps}/plex/video/Collection.java | 2 +- .../{ => gaps}/plex/video/Country.java | 2 +- .../{ => gaps}/plex/video/Director.java | 2 +- .../{ => gaps}/plex/video/Genre.java | 2 +- .../{ => gaps}/plex/video/Media.java | 2 +- .../{ => gaps}/plex/video/MediaContainer.java | 2 +- .../{ => gaps}/plex/video/Part.java | 2 +- .../{ => gaps}/plex/video/Role.java | 2 +- .../{ => gaps}/plex/video/Video.java | 2 +- .../{ => gaps}/plex/video/Writer.java | 2 +- .../com/jasonhhouse/plex/libs/Location.java | 128 ---- .../jasonhhouse/plex/libs/MediaContainer.java | 246 -------- .../jasonhhouse/plex/libs/PlexLibrary.java | 549 ------------------ .../com/jasonhhouse/plex/libs/libraries.xsd | 52 -- .../jasonhhouse/{ => gaps}/plex/PlexTest.java | 4 +- .../{ => gaps}/plex/plex_videos.xml | 0 44 files changed, 338 insertions(+), 1110 deletions(-) create mode 100644 Plex/src/main/java/com/jasonhhouse/gaps/plex/PlexLibrary.java rename {Core/src/main/java/com/jasonhhouse/gaps => Plex/src/main/java/com/jasonhhouse/gaps/plex}/PlexServer.java (50%) rename Plex/src/main/java/com/jasonhhouse/{ => gaps}/plex/video/Collection.java (97%) rename Plex/src/main/java/com/jasonhhouse/{ => gaps}/plex/video/Country.java (97%) rename Plex/src/main/java/com/jasonhhouse/{ => gaps}/plex/video/Director.java (97%) rename Plex/src/main/java/com/jasonhhouse/{ => gaps}/plex/video/Genre.java (97%) rename Plex/src/main/java/com/jasonhhouse/{ => gaps}/plex/video/Media.java (99%) rename Plex/src/main/java/com/jasonhhouse/{ => gaps}/plex/video/MediaContainer.java (99%) rename Plex/src/main/java/com/jasonhhouse/{ => gaps}/plex/video/Part.java (98%) rename Plex/src/main/java/com/jasonhhouse/{ => gaps}/plex/video/Role.java (97%) rename Plex/src/main/java/com/jasonhhouse/{ => gaps}/plex/video/Video.java (99%) rename Plex/src/main/java/com/jasonhhouse/{ => gaps}/plex/video/Writer.java (97%) delete mode 100644 Plex/src/main/java/com/jasonhhouse/plex/libs/Location.java delete mode 100644 Plex/src/main/java/com/jasonhhouse/plex/libs/MediaContainer.java delete mode 100644 Plex/src/main/java/com/jasonhhouse/plex/libs/PlexLibrary.java delete mode 100644 Plex/src/main/java/com/jasonhhouse/plex/libs/libraries.xsd rename Plex/src/test/java/com/jasonhhouse/{ => gaps}/plex/PlexTest.java (96%) rename Plex/src/test/resources/com/jasonhhouse/{ => gaps}/plex/plex_videos.xml (100%) diff --git a/Core/src/main/java/com/jasonhhouse/gaps/properties/PlexProperties.java b/Core/src/main/java/com/jasonhhouse/gaps/properties/PlexProperties.java index 67527d83..2d9fb173 100755 --- a/Core/src/main/java/com/jasonhhouse/gaps/properties/PlexProperties.java +++ b/Core/src/main/java/com/jasonhhouse/gaps/properties/PlexProperties.java @@ -14,7 +14,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; -import com.jasonhhouse.gaps.PlexServer; +import com.jasonhhouse.gaps.plex.PlexServer; import com.jasonhhouse.gaps.Schedule; import java.util.HashSet; import java.util.Set; diff --git a/Core/src/main/java/com/jasonhhouse/gaps/service/PlexQuery.java b/Core/src/main/java/com/jasonhhouse/gaps/service/PlexQuery.java index ec25042e..74578443 100755 --- a/Core/src/main/java/com/jasonhhouse/gaps/service/PlexQuery.java +++ b/Core/src/main/java/com/jasonhhouse/gaps/service/PlexQuery.java @@ -14,10 +14,10 @@ import com.jasonhhouse.gaps.BasicMovie; import com.jasonhhouse.gaps.Pair; import com.jasonhhouse.gaps.Payload; -import com.jasonhhouse.gaps.PlexServer; +import com.jasonhhouse.gaps.plex.PlexServer; import com.jasonhhouse.gaps.properties.PlexProperties; -import com.jasonhhouse.plex.libs.PlexLibrary; -import com.jasonhhouse.plex.video.MediaContainer; +import com.jasonhhouse.gaps.plex.PlexLibrary; +import com.jasonhhouse.gaps.plex.video.MediaContainer; import java.util.List; import java.util.Map; import okhttp3.HttpUrl; diff --git a/GapsWeb/src/main/java/com/jasonhhouse/gaps/GapsApplication.java b/GapsWeb/src/main/java/com/jasonhhouse/gaps/GapsApplication.java index b29c867a..561c5526 100755 --- a/GapsWeb/src/main/java/com/jasonhhouse/gaps/GapsApplication.java +++ b/GapsWeb/src/main/java/com/jasonhhouse/gaps/GapsApplication.java @@ -34,7 +34,7 @@ * Search for all missing movies in your plex collection by MovieDB collection. */ @SpringBootApplication -@EntityScan("com.jasonhhouse.plex") +@EntityScan("com.jasonhhouse.gaps.plex") @EnableAsync @EnableConfigurationProperties @ConfigurationPropertiesScan diff --git a/GapsWeb/src/main/java/com/jasonhhouse/gaps/GapsUrlGenerator.java b/GapsWeb/src/main/java/com/jasonhhouse/gaps/GapsUrlGenerator.java index 3b01ca50..9d78f97e 100755 --- a/GapsWeb/src/main/java/com/jasonhhouse/gaps/GapsUrlGenerator.java +++ b/GapsWeb/src/main/java/com/jasonhhouse/gaps/GapsUrlGenerator.java @@ -10,7 +10,8 @@ package com.jasonhhouse.gaps; -import com.jasonhhouse.plex.libs.PlexLibrary; +import com.jasonhhouse.gaps.plex.PlexLibrary; +import com.jasonhhouse.gaps.plex.PlexServer; import okhttp3.HttpUrl; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -103,7 +104,7 @@ public class GapsUrlGenerator implements UrlGenerator { } @Override - public @Nullable HttpUrl generatePlexLibraryUrl(@NotNull PlexServer plexServer,@NotNull PlexLibrary plexLibrary) { + public @Nullable HttpUrl generatePlexLibraryUrl(@NotNull PlexServer plexServer, @NotNull PlexLibrary plexLibrary) { return new HttpUrl.Builder() .scheme(HTTP) .host(plexServer.getAddress()) diff --git a/GapsWeb/src/main/java/com/jasonhhouse/gaps/PlexServerToStringConverter.java b/GapsWeb/src/main/java/com/jasonhhouse/gaps/PlexServerToStringConverter.java index 01555454..3a904697 100755 --- a/GapsWeb/src/main/java/com/jasonhhouse/gaps/PlexServerToStringConverter.java +++ b/GapsWeb/src/main/java/com/jasonhhouse/gaps/PlexServerToStringConverter.java @@ -11,6 +11,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; +import com.jasonhhouse.gaps.plex.PlexServer; import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/GapsWeb/src/main/java/com/jasonhhouse/gaps/SearchGapsTask.java b/GapsWeb/src/main/java/com/jasonhhouse/gaps/SearchGapsTask.java index 28ff20bc..c1d2a782 100644 --- a/GapsWeb/src/main/java/com/jasonhhouse/gaps/SearchGapsTask.java +++ b/GapsWeb/src/main/java/com/jasonhhouse/gaps/SearchGapsTask.java @@ -10,13 +10,14 @@ package com.jasonhhouse.gaps; +import com.jasonhhouse.gaps.plex.PlexLibrary; +import com.jasonhhouse.gaps.plex.PlexServer; import com.jasonhhouse.gaps.properties.PlexProperties; import com.jasonhhouse.gaps.service.GapsSearch; import com.jasonhhouse.gaps.service.FileIoService; import com.jasonhhouse.gaps.service.NotificationService; import com.jasonhhouse.gaps.service.PlexQuery; import com.jasonhhouse.gaps.service.TmdbService; -import com.jasonhhouse.plex.libs.PlexLibrary; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -91,7 +92,8 @@ private void checkPlexServers(PlexProperties plexProperties) { for (PlexServer plexServer : plexProperties.getPlexServers()) { Payload payload = plexQuery.queryPlexServer(plexServer); if (payload.getCode() == Payload.PLEX_CONNECTION_SUCCEEDED.getCode()) { - notificationService.plexServerConnectSuccessful(plexServer); + plexProperties.addPlexServer((PlexServer) payload.getExtras()); + notificationService.plexServerConnectSuccessful((PlexServer) payload.getExtras()); } else { notificationService.plexServerConnectFailed(plexServer, payload.getReason()); } diff --git a/GapsWeb/src/main/java/com/jasonhhouse/gaps/UrlGenerator.java b/GapsWeb/src/main/java/com/jasonhhouse/gaps/UrlGenerator.java index d16d2282..85502436 100755 --- a/GapsWeb/src/main/java/com/jasonhhouse/gaps/UrlGenerator.java +++ b/GapsWeb/src/main/java/com/jasonhhouse/gaps/UrlGenerator.java @@ -9,7 +9,8 @@ */ package com.jasonhhouse.gaps; -import com.jasonhhouse.plex.libs.PlexLibrary; +import com.jasonhhouse.gaps.plex.PlexLibrary; +import com.jasonhhouse.gaps.plex.PlexServer; import okhttp3.HttpUrl; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -70,7 +71,7 @@ public interface UrlGenerator { * @param plexLibrary The PlexLibrary to query * @return query */ - @Nullable HttpUrl generatePlexLibraryUrl(@NotNull PlexServer plexServer,@NotNull PlexLibrary plexLibrary); + @Nullable HttpUrl generatePlexLibraryUrl(@NotNull PlexServer plexServer, @NotNull PlexLibrary plexLibrary); @NotNull HttpUrl generatePlexMetadataUrl(@NotNull PlexServer plexServer, @NotNull PlexLibrary plexLibrary,@NotNull Integer ratingKey); diff --git a/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/ConfigurationController.java b/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/ConfigurationController.java index 316a1c16..db7d2d58 100755 --- a/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/ConfigurationController.java +++ b/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/ConfigurationController.java @@ -12,7 +12,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.ObjectNode; import com.jasonhhouse.gaps.Payload; -import com.jasonhhouse.gaps.PlexServer; +import com.jasonhhouse.gaps.plex.PlexServer; import com.jasonhhouse.gaps.properties.PlexProperties; import com.jasonhhouse.gaps.service.FileIoService; import com.jasonhhouse.gaps.service.PlexQueryImpl; @@ -20,6 +20,7 @@ import com.jasonhhouse.gaps.service.TmdbService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; +import java.util.Collections; import javax.validation.Valid; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; @@ -80,13 +81,20 @@ public ModelAndView getConfiguration() { @PostMapping(value = "/add/plex", consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE) @ResponseStatus(value = HttpStatus.OK) - public void postAddPlexServer(@Parameter(description = "The details of the Plex Server to add.") @Valid final PlexServer plexServer) { - LOGGER.info("postAddPlexServer( {} )", plexServer); + public void postAddPlexServer(@Parameter(description = "The details of the Plex Server to add.") @Valid final PlexServer sentPlexServer) { + LOGGER.info("postAddPlexServer( {} )", sentPlexServer); PlexProperties plexProperties = fileIoService.readProperties(); try { - plexQuery.queryPlexServer(plexServer); + PlexServer plexServer; + Payload plexServerPayload = plexQuery.queryPlexServer(sentPlexServer); + if (plexServerPayload.getCode() == Payload.PLEX_CONNECTION_SUCCEEDED.getCode()) { + plexServer = (PlexServer) plexServerPayload.getExtras(); + } else { + plexServer = sentPlexServer; + } + Payload payload = plexQuery.getLibraries(plexServer); if (payload.getCode() == Payload.PLEX_LIBRARIES_FOUND.getCode()) { @@ -135,7 +143,8 @@ public ResponseEntity putTestPlexServerByMachineId(@PathVariable("machin PlexProperties plexProperties = fileIoService.readProperties(); ObjectNode objectNode = objectMapper.createObjectNode(); - PlexServer returnedPlexServer = plexProperties.getPlexServers().stream().filter(plexServer -> plexServer.getMachineIdentifier().equals(machineIdentifier)).findFirst().orElse(new PlexServer()); + PlexServer returnedPlexServer = plexProperties.getPlexServers().stream().filter(plexServer -> + plexServer.getMachineIdentifier().equals(machineIdentifier)).findFirst().orElse(new PlexServer("", "", "", "", -1, Collections.emptySet())); if (StringUtils.isEmpty(returnedPlexServer.getMachineIdentifier())) { //Failed to find and delete @@ -157,7 +166,8 @@ public ResponseEntity deletePlexServer(@PathVariable("machineIdentifier" PlexProperties plexProperties = fileIoService.readProperties(); ObjectNode objectNode = objectMapper.createObjectNode(); - PlexServer returnedPlexServer = plexProperties.getPlexServers().stream().filter(plexServer -> plexServer.getMachineIdentifier().equals(machineIdentifier)).findFirst().orElse(new PlexServer()); + PlexServer returnedPlexServer = plexProperties.getPlexServers().stream().filter(plexServer -> + plexServer.getMachineIdentifier().equals(machineIdentifier)).findFirst().orElse(new PlexServer("", "", "", "", -1, Collections.emptySet())); if (StringUtils.isEmpty(returnedPlexServer.getMachineIdentifier())) { //Failed to find and delete objectNode.put(SUCCESS, false); diff --git a/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/LibraryController.java b/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/LibraryController.java index 3e911f44..1e10da92 100755 --- a/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/LibraryController.java +++ b/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/LibraryController.java @@ -11,10 +11,11 @@ import com.jasonhhouse.gaps.BasicMovie; import com.jasonhhouse.gaps.Payload; -import com.jasonhhouse.gaps.PlexServer; +import com.jasonhhouse.gaps.plex.PlexServer; import com.jasonhhouse.gaps.properties.PlexProperties; import com.jasonhhouse.gaps.service.FileIoService; -import com.jasonhhouse.plex.libs.PlexLibrary; +import com.jasonhhouse.gaps.plex.PlexLibrary; +import java.util.Collections; import java.util.List; import java.util.Map; import java.util.function.Function; @@ -56,12 +57,12 @@ public ModelAndView getLibraries() { PlexLibrary plexLibrary; if (CollectionUtils.isNotEmpty(plexProperties.getPlexServers())) { //Read first plex servers movies - plexServer = plexProperties.getPlexServers().stream().findFirst().orElse(new PlexServer()); - plexLibrary = plexServer.getPlexLibraries().stream().findFirst().orElse(new PlexLibrary()); + plexServer = plexProperties.getPlexServers().stream().findFirst().orElse(new PlexServer("", "","", "",-1, Collections.emptySet())); + plexLibrary = plexServer.getPlexLibraries().stream().findFirst().orElse(new PlexLibrary(-1, "","","",false, false)); plexServersFound = true; } else { - plexServer = new PlexServer(); - plexLibrary = new PlexLibrary(); + plexServer = new PlexServer("", "","", "",-1, Collections.emptySet()); + plexLibrary = new PlexLibrary(-1, "","","",false, false); plexServersFound = false; } diff --git a/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/MislabeledController.java b/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/MislabeledController.java index b472353f..3af2d58a 100755 --- a/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/MislabeledController.java +++ b/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/MislabeledController.java @@ -15,7 +15,7 @@ import com.jasonhhouse.gaps.service.FileIoService; import com.jasonhhouse.gaps.service.MediaContainerService; import com.jasonhhouse.gaps.service.MislabeledService; -import com.jasonhhouse.plex.video.MediaContainer; +import com.jasonhhouse.gaps.plex.video.MediaContainer; import java.util.List; import org.apache.commons.lang3.time.StopWatch; import org.slf4j.Logger; diff --git a/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/PlexMovieListController.java b/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/PlexMovieListController.java index 19f7e902..1b89344a 100755 --- a/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/PlexMovieListController.java +++ b/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/PlexMovieListController.java @@ -13,11 +13,11 @@ import com.jasonhhouse.gaps.GapsUrlGenerator; import com.jasonhhouse.gaps.BasicMovie; import com.jasonhhouse.gaps.Pair; +import com.jasonhhouse.gaps.plex.PlexLibrary; import com.jasonhhouse.gaps.service.PlexQuery; -import com.jasonhhouse.gaps.PlexServer; +import com.jasonhhouse.gaps.plex.PlexServer; import com.jasonhhouse.gaps.properties.PlexProperties; import com.jasonhhouse.gaps.service.FileIoService; -import com.jasonhhouse.plex.libs.PlexLibrary; import java.util.HashMap; import java.util.List; import java.util.Map; diff --git a/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/RSSController.java b/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/RSSController.java index 4e0f3c4a..850fff3b 100755 --- a/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/RSSController.java +++ b/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/RSSController.java @@ -10,11 +10,11 @@ package com.jasonhhouse.gaps.controller; -import com.jasonhhouse.gaps.PlexServer; +import com.jasonhhouse.gaps.plex.PlexLibrary; +import com.jasonhhouse.gaps.plex.PlexServer; import com.jasonhhouse.gaps.properties.PlexProperties; import com.jasonhhouse.gaps.service.FileIoService; import com.jasonhhouse.gaps.service.RssService; -import com.jasonhhouse.plex.libs.PlexLibrary; import java.util.Map; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; diff --git a/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/RecommendedController.java b/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/RecommendedController.java index 12cca699..af874c89 100755 --- a/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/RecommendedController.java +++ b/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/RecommendedController.java @@ -12,10 +12,11 @@ import com.jasonhhouse.gaps.service.GapsSearch; import com.jasonhhouse.gaps.BasicMovie; import com.jasonhhouse.gaps.Payload; -import com.jasonhhouse.gaps.PlexServer; +import com.jasonhhouse.gaps.plex.PlexServer; import com.jasonhhouse.gaps.properties.PlexProperties; import com.jasonhhouse.gaps.service.FileIoService; -import com.jasonhhouse.plex.libs.PlexLibrary; +import com.jasonhhouse.gaps.plex.PlexLibrary; +import java.util.Collections; import java.util.List; import java.util.Map; import java.util.function.Function; @@ -63,11 +64,11 @@ public ModelAndView getRecommended() { if (CollectionUtils.isNotEmpty(plexProperties.getPlexServers())) { //Read first plex servers movies - plexServer = plexProperties.getPlexServers().stream().findFirst().orElse(new PlexServer()); - plexLibrary = plexServer.getPlexLibraries().stream().findFirst().orElse(new PlexLibrary()); + plexServer = plexProperties.getPlexServers().stream().findFirst().orElse(new PlexServer("", "","", "",-1, Collections.emptySet())); + plexLibrary = plexServer.getPlexLibraries().stream().findFirst().orElse(new PlexLibrary(-1, "","","",false, false)); } else { - plexServer = new PlexServer(); - plexLibrary = new PlexLibrary(); + plexServer = new PlexServer("", "","", "",-1, Collections.emptySet()); + plexLibrary = new PlexLibrary(-1, "","","",false, false); } Map plexServerMap = plexProperties.getPlexServers().stream().collect(Collectors.toMap(PlexServer::getMachineIdentifier, Function.identity())); diff --git a/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/GapsSearchService.java b/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/GapsSearchService.java index e3d961da..35f42cb9 100755 --- a/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/GapsSearchService.java +++ b/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/GapsSearchService.java @@ -18,12 +18,12 @@ import com.jasonhhouse.gaps.BasicMovie; import com.jasonhhouse.gaps.MovieFromCollection; import com.jasonhhouse.gaps.Payload; -import com.jasonhhouse.gaps.PlexServer; +import com.jasonhhouse.gaps.plex.PlexServer; import com.jasonhhouse.gaps.SearchCancelledException; import com.jasonhhouse.gaps.SearchResults; import com.jasonhhouse.gaps.UrlGenerator; import com.jasonhhouse.gaps.properties.PlexProperties; -import com.jasonhhouse.plex.libs.PlexLibrary; +import com.jasonhhouse.gaps.plex.PlexLibrary; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; import java.io.IOException; import java.net.URLEncoder; diff --git a/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/MediaContainerService.java b/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/MediaContainerService.java index f26c5b24..1998d8ee 100644 --- a/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/MediaContainerService.java +++ b/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/MediaContainerService.java @@ -1,7 +1,7 @@ package com.jasonhhouse.gaps.service; import com.jasonhhouse.gaps.sql.MediaContainerRepository; -import com.jasonhhouse.plex.video.MediaContainer; +import com.jasonhhouse.gaps.plex.video.MediaContainer; import java.util.List; import org.springframework.stereotype.Service; diff --git a/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/MislabeledService.java b/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/MislabeledService.java index 45719810..43e7ddee 100755 --- a/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/MislabeledService.java +++ b/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/MislabeledService.java @@ -10,8 +10,8 @@ package com.jasonhhouse.gaps.service; import com.jasonhhouse.gaps.Mislabeled; -import com.jasonhhouse.plex.video.MediaContainer; -import com.jasonhhouse.plex.video.Video; +import com.jasonhhouse.gaps.plex.video.MediaContainer; +import com.jasonhhouse.gaps.plex.video.Video; import java.util.ArrayList; import java.util.List; import org.apache.commons.text.similarity.LevenshteinDistance; diff --git a/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/Notification.java b/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/Notification.java index ae31cec2..536b1fee 100644 --- a/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/Notification.java +++ b/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/Notification.java @@ -1,7 +1,7 @@ package com.jasonhhouse.gaps.service; -import com.jasonhhouse.gaps.PlexServer; -import com.jasonhhouse.plex.libs.PlexLibrary; +import com.jasonhhouse.gaps.plex.PlexServer; +import com.jasonhhouse.gaps.plex.PlexLibrary; public interface Notification { diff --git a/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/NotificationService.java b/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/NotificationService.java index 68624749..c883d80b 100644 --- a/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/NotificationService.java +++ b/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/NotificationService.java @@ -10,10 +10,10 @@ package com.jasonhhouse.gaps.service; import com.jasonhhouse.gaps.NotificationType; -import com.jasonhhouse.gaps.PlexServer; +import com.jasonhhouse.gaps.plex.PlexServer; import com.jasonhhouse.gaps.notifications.NotificationAgent; import com.jasonhhouse.gaps.properties.NotificationProperties; -import com.jasonhhouse.plex.libs.PlexLibrary; +import com.jasonhhouse.gaps.plex.PlexLibrary; import java.util.List; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/PlexQueryImpl.java b/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/PlexQueryImpl.java index d7510375..c95d8ba4 100755 --- a/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/PlexQueryImpl.java +++ b/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/PlexQueryImpl.java @@ -13,11 +13,10 @@ import com.jasonhhouse.gaps.BasicMovie; import com.jasonhhouse.gaps.Pair; import com.jasonhhouse.gaps.Payload; -import com.jasonhhouse.gaps.PlexServer; +import com.jasonhhouse.gaps.plex.PlexServer; import com.jasonhhouse.gaps.UrlGenerator; import com.jasonhhouse.gaps.properties.PlexProperties; -import com.jasonhhouse.plex.libs.MediaContainer; -import com.jasonhhouse.plex.libs.PlexLibrary; +import com.jasonhhouse.gaps.plex.PlexLibrary; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; @@ -26,7 +25,6 @@ import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; @@ -60,8 +58,6 @@ @Service public class PlexQueryImpl implements PlexQuery { - public static final String ID_IDX_START = "://"; - public static final String ID_IDX_END = "?"; private static final long TIMEOUT = 2500; private static final Logger LOGGER = LoggerFactory.getLogger(PlexQueryImpl.class); @@ -76,6 +72,8 @@ public PlexQueryImpl(@Qualifier("real") UrlGenerator urlGenerator) { public @NotNull Payload getLibraries(@NotNull PlexServer plexServer) { LOGGER.info("queryPlexLibraries()"); + List plexLibraries = new ArrayList<>(); + HttpUrl url = new HttpUrl.Builder() .scheme("http") .host(plexServer.getAddress()) @@ -97,22 +95,53 @@ public PlexQueryImpl(@Qualifier("real") UrlGenerator urlGenerator) { .build(); try (Response response = client.newCall(request).execute()) { - String body = response.body() != null ? response.body().string() : null; + NodeList directories = parseXml(response, url, "/MediaContainer/Directory"); - if (StringUtils.isBlank(body)) { - String reason = "Body returned empty from Plex"; - LOGGER.error(reason); - throw new ResponseStatusException(HttpStatus.BAD_REQUEST, reason); + if (directories.getLength() == 0) { + LOGGER.warn("No movies found in url: {}", url); + return Payload.PARSING_PLEX_FAILED.setExtras("url:" + url); } - InputStream inputStream = new ByteArrayInputStream(body.getBytes(StandardCharsets.UTF_8)); - JAXBContext jaxbContext = JAXBContext.newInstance(MediaContainer.class); - Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); - MediaContainer mediaContainer = (MediaContainer) jaxbUnmarshaller.unmarshal(inputStream); + for (int i = 0; i < directories.getLength(); i++) { + Node directory = directories.item(i); - //Remove everything except movie folders - List plexLibraries = mediaContainer.getPlexLibraries().stream().filter(plexLibrary -> plexLibrary.getType().equalsIgnoreCase("movie")).collect(Collectors.toList()); + Node nodeKey = directory.getAttributes().getNamedItem("key"); + Node nodeScanner = directory.getAttributes().getNamedItem("scanner"); + Node nodeTitle = directory.getAttributes().getNamedItem("title"); + Node nodeType = directory.getAttributes().getNamedItem("type"); + + if (nodeTitle == null) { + String reason = "Missing title from Video element in Plex"; + LOGGER.warn(reason); + continue; + } + if(nodeType == null || !"movie".equalsIgnoreCase(nodeType.getNodeValue())) { + LOGGER.info("Skipping library {}, not of type movie",nodeTitle.getNodeValue()); + continue; + } + + if(nodeKey == null) { + LOGGER.warn("Skipping library {}, key missing",nodeTitle.getNodeValue()); + continue; + } + + if(nodeScanner == null) { + LOGGER.warn("Skipping library {}, scanner missing",nodeTitle.getNodeValue()); + continue; + } + + Integer key = Integer.valueOf(nodeKey.getNodeValue()); + String scanner = nodeScanner.getNodeValue(); + String title = nodeTitle.getNodeValue(); + String type = nodeType.getNodeValue(); + + PlexLibrary plexLibrary = new PlexLibrary(key, scanner, title, type, true, false); + plexLibraries.add(plexLibrary); + } + LOGGER.info("{} libraries found on server", plexLibraries.size()); + + //Remove everything except movie folders LOGGER.info("{} Plex libraries found", plexLibraries.size()); plexServer.getPlexLibraries().addAll(plexLibraries); return Payload.PLEX_LIBRARIES_FOUND.setExtras("size():" + plexLibraries.size()); @@ -120,7 +149,7 @@ public PlexQueryImpl(@Qualifier("real") UrlGenerator urlGenerator) { String reason = String.format("Error connecting to Plex to get library list: %s", url); LOGGER.error(reason, e); return Payload.PLEX_CONNECTION_FAILED.setExtras("url:" + url); - } catch (JAXBException e) { + } catch (SAXException|XPathExpressionException|ParserConfigurationException e) { String reason = "Error parsing XML from Plex: " + url; LOGGER.error(reason, e); return Payload.PARSING_PLEX_FAILED.setExtras("url:" + url); @@ -188,10 +217,16 @@ public PlexQueryImpl(@Qualifier("real") UrlGenerator urlGenerator) { String machineIdentifier = machineIdentifierNode.getNodeValue().trim(); LOGGER.info("machineIdentifier:{}", machineIdentifier); - plexServer.setFriendlyName(friendlyName); - plexServer.setMachineIdentifier(machineIdentifier); + //ToDo + //Do I need this anymore + plexServer = new PlexServer(friendlyName, + machineIdentifier, + plexServer.getPlexToken(), + plexServer.getAddress(), + plexServer.getPort(), + plexServer.getPlexLibraries()); - return Payload.PLEX_CONNECTION_SUCCEEDED.setExtras("url:" + url); + return Payload.PLEX_CONNECTION_SUCCEEDED.setExtras(plexServer); } catch (IOException e) { String reason = String.format("Error connecting to Plex to get library list: %s", url); LOGGER.error(reason, e); @@ -209,7 +244,7 @@ public PlexQueryImpl(@Qualifier("real") UrlGenerator urlGenerator) { } @Override - public @NotNull com.jasonhhouse.plex.video.MediaContainer findAllPlexVideos(@NotNull String url) { + public @NotNull com.jasonhhouse.gaps.plex.video.MediaContainer findAllPlexVideos(@NotNull String url) { LOGGER.info("findAllPlexVideos()"); OkHttpClient client = new OkHttpClient.Builder() @@ -220,10 +255,10 @@ public PlexQueryImpl(@Qualifier("real") UrlGenerator urlGenerator) { if (StringUtils.isEmpty(url)) { LOGGER.info("No URL added to findAllPlexVideos()."); - return new com.jasonhhouse.plex.video.MediaContainer(); + return new com.jasonhhouse.gaps.plex.video.MediaContainer(); } - com.jasonhhouse.plex.video.MediaContainer mediaContainer; + com.jasonhhouse.gaps.plex.video.MediaContainer mediaContainer; try { HttpUrl httpUrl = urlGenerator.generatePlexUrl(url); @@ -241,9 +276,9 @@ public PlexQueryImpl(@Qualifier("real") UrlGenerator urlGenerator) { } InputStream inputStream = new ByteArrayInputStream(body.getBytes(StandardCharsets.UTF_8)); - JAXBContext jaxbContext = JAXBContext.newInstance(com.jasonhhouse.plex.video.MediaContainer.class); + JAXBContext jaxbContext = JAXBContext.newInstance(com.jasonhhouse.gaps.plex.video.MediaContainer.class); Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); - mediaContainer = (com.jasonhhouse.plex.video.MediaContainer) jaxbUnmarshaller.unmarshal(inputStream); + mediaContainer = (com.jasonhhouse.gaps.plex.video.MediaContainer) jaxbUnmarshaller.unmarshal(inputStream); } catch (IOException e) { String reason = String.format("Error connecting to Plex to get Movie list: %s", url); diff --git a/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/RssService.java b/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/RssService.java index 3e5af1ce..7d20e441 100755 --- a/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/RssService.java +++ b/GapsWeb/src/main/java/com/jasonhhouse/gaps/service/RssService.java @@ -9,9 +9,9 @@ */ package com.jasonhhouse.gaps.service; -import com.jasonhhouse.gaps.PlexServer; +import com.jasonhhouse.gaps.plex.PlexLibrary; +import com.jasonhhouse.gaps.plex.PlexServer; import com.jasonhhouse.gaps.properties.PlexProperties; -import com.jasonhhouse.plex.libs.PlexLibrary; import java.util.Collections; import java.util.HashMap; import java.util.Map; diff --git a/GapsWeb/src/main/java/com/jasonhhouse/gaps/sql/MediaContainerRepository.java b/GapsWeb/src/main/java/com/jasonhhouse/gaps/sql/MediaContainerRepository.java index 670e1b54..6e679652 100644 --- a/GapsWeb/src/main/java/com/jasonhhouse/gaps/sql/MediaContainerRepository.java +++ b/GapsWeb/src/main/java/com/jasonhhouse/gaps/sql/MediaContainerRepository.java @@ -1,6 +1,6 @@ package com.jasonhhouse.gaps.sql; -import com.jasonhhouse.plex.video.MediaContainer; +import com.jasonhhouse.gaps.plex.video.MediaContainer; import org.springframework.data.jpa.repository.JpaRepository; public interface MediaContainerRepository extends JpaRepository { diff --git a/GapsWeb/src/main/java/com/jasonhhouse/gaps/validator/PlexServerValidator.java b/GapsWeb/src/main/java/com/jasonhhouse/gaps/validator/PlexServerValidator.java index 0d4e783a..914a0736 100755 --- a/GapsWeb/src/main/java/com/jasonhhouse/gaps/validator/PlexServerValidator.java +++ b/GapsWeb/src/main/java/com/jasonhhouse/gaps/validator/PlexServerValidator.java @@ -10,7 +10,7 @@ package com.jasonhhouse.gaps.validator; -import com.jasonhhouse.gaps.PlexServer; +import com.jasonhhouse.gaps.plex.PlexServer; import org.apache.commons.lang3.StringUtils; import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; diff --git a/GapsWeb/src/main/resources/static/css/input.css b/GapsWeb/src/main/resources/static/css/input.css index 40a03f68..d5e38421 100755 --- a/GapsWeb/src/main/resources/static/css/input.css +++ b/GapsWeb/src/main/resources/static/css/input.css @@ -71,6 +71,14 @@ margin-right: auto; } +.material-icons.green600 { + color: #43A047; +} + +.skip-searching-library { + text-decoration: line-through; +} + .list-ul-default { background-color: #fafafa; /* defines the background color of the image */ mask: url(/images/list-ul.svg) no-repeat center / contain; diff --git a/GapsWeb/src/main/resources/static/js/configuration.js b/GapsWeb/src/main/resources/static/js/configuration.js index 93f640d9..2bedb2b4 100755 --- a/GapsWeb/src/main/resources/static/js/configuration.js +++ b/GapsWeb/src/main/resources/static/js/configuration.js @@ -44,6 +44,21 @@ window.addEventListener('load', function () { document.addEventListener('DOMContentLoaded', function () { + Handlebars.registerHelper({ + isEnabled: function (value) { + return value.enabled && !value.defaultLibrary; + }, + isDefaultLibrary: function (value) { + return !value.enabled && value.defaultLibrary; + }, + isBoth: function (value) { + return value.enabled && value.defaultLibrary; + }, + isNone: function (value) { + return !value.enabled && !value.defaultLibrary; + } + }); + plexSpinner = $('#plexSpinner'); plexSaveSuccess = $('#plexSaveSuccess'); plexSaveError = $('#plexSaveError'); diff --git a/GapsWeb/src/main/resources/templates/configuration.html b/GapsWeb/src/main/resources/templates/configuration.html index 4fb658f1..37ba103b 100755 --- a/GapsWeb/src/main/resources/templates/configuration.html +++ b/GapsWeb/src/main/resources/templates/configuration.html @@ -16,6 +16,7 @@ + @@ -421,7 +422,18 @@

Success!

{{friendlyName}}
    {{#each plexLibraries}} -
  • {{title}}
  • + {{#if (isEnabled this)}} +
  • {{title}}
  • + {{/if}} + {{#if (isDefaultLibrary this)}} +
  • {{title}} check
  • + {{/if}} + {{#if (isBoth this)}} +
  • {{title}} check
  • + {{/if}} + {{#if (isNone this)}} +
  • {{title}}
  • + {{/if}} {{/each}}
diff --git a/Plex/pom.xml b/Plex/pom.xml index 431104a6..26a05580 100755 --- a/Plex/pom.xml +++ b/Plex/pom.xml @@ -12,6 +12,12 @@ Plex + + org.springdoc + springdoc-openapi-ui + 1.4.7 + + org.apache.commons commons-text diff --git a/Plex/src/main/java/com/jasonhhouse/gaps/plex/PlexLibrary.java b/Plex/src/main/java/com/jasonhhouse/gaps/plex/PlexLibrary.java new file mode 100644 index 00000000..6c1de83f --- /dev/null +++ b/Plex/src/main/java/com/jasonhhouse/gaps/plex/PlexLibrary.java @@ -0,0 +1,112 @@ +/* + * Copyright 2020 Jason H House + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + */ + +package com.jasonhhouse.gaps.plex; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Objects; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +public final class PlexLibrary { + + @NotNull + private final Integer key; + + @NotNull + private final String scanner; + + @NotNull + private final String title; + + @NotNull + private final String type; + + @NotNull + private final Boolean enabled; + + @NotNull + private final Boolean defaultLibrary; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + public PlexLibrary(@JsonProperty(value = "key") @Nullable Integer key, + @JsonProperty(value = "scanner") @Nullable String scanner, + @JsonProperty(value = "title") @Nullable String title, + @JsonProperty(value = "type") @Nullable String type, + @JsonProperty(value = "enabled") @Nullable Boolean enabled, + @JsonProperty(value = "defaultLibrary") @Nullable Boolean defaultLibrary) { + this.key = key == null ? -1 : key; + this.scanner = scanner == null ? "" : scanner; + this.title = title == null ? "" : title; + this.type = type == null ? "" : type; + this.enabled = enabled == null || enabled; + this.defaultLibrary = defaultLibrary != null && defaultLibrary; + } + + public @NotNull Integer getKey() { + return key; + } + + public @NotNull String getScanner() { + return scanner; + } + + public @NotNull String getTitle() { + return title; + } + + public @NotNull String getType() { + return type; + } + + public @NotNull Boolean getEnabled() { + return enabled; + } + + public @NotNull Boolean getDefaultLibrary() { + return defaultLibrary; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + PlexLibrary that = (PlexLibrary) o; + return Objects.equals(key, that.key) && + Objects.equals(scanner, that.scanner) && + Objects.equals(title, that.title) && + Objects.equals(type, that.type) && + Objects.equals(enabled, that.enabled) && + Objects.equals(defaultLibrary, that.defaultLibrary); + } + + @Override + public int hashCode() { + return Objects.hash(key, scanner, title, type, enabled, defaultLibrary); + } + + @Override + public String toString() { + return "PlexLibrary{" + + "key=" + key + + ", scanner='" + scanner + '\'' + + ", title='" + title + '\'' + + ", type='" + type + '\'' + + ", enabled=" + enabled + + ", defaultLibrary=" + defaultLibrary + + '}'; + } +} diff --git a/Core/src/main/java/com/jasonhhouse/gaps/PlexServer.java b/Plex/src/main/java/com/jasonhhouse/gaps/plex/PlexServer.java similarity index 50% rename from Core/src/main/java/com/jasonhhouse/gaps/PlexServer.java rename to Plex/src/main/java/com/jasonhhouse/gaps/plex/PlexServer.java index 062bb747..18efe94c 100755 --- a/Core/src/main/java/com/jasonhhouse/gaps/PlexServer.java +++ b/Plex/src/main/java/com/jasonhhouse/gaps/plex/PlexServer.java @@ -3,94 +3,92 @@ * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: * - * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.jasonhhouse.gaps; +package com.jasonhhouse.gaps.plex; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; -import com.jasonhhouse.plex.libs.PlexLibrary; import io.swagger.v3.oas.annotations.media.Schema; +import com.fasterxml.jackson.annotation.JsonProperty; import java.util.LinkedHashSet; import java.util.Objects; import java.util.Set; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + @JsonIgnoreProperties(ignoreUnknown = true) @JsonInclude(JsonInclude.Include.NON_NULL) public final class PlexServer { + @NotNull @Schema(description = "Libraries that are of type movie in your Plex Server") private final Set plexLibraries; + + @NotNull @Schema(description = "Human readable way to identify your Plex Server") - private String friendlyName; + private final String friendlyName; + + @NotNull @Schema(description = "UID to identify the Plex Server") - private String machineIdentifier; - @Schema(required = true, description = "Token for your Plex Server. Found via Plex docs.") - private String plexToken; - @Schema(required = true, defaultValue = "localhost", description = "Address of your Plex Server") - private String address; - @Schema(required = true, defaultValue = "32400", description = "Port of your Plex Server") - private Integer port; + private final String machineIdentifier; - public PlexServer() { - plexLibraries = new LinkedHashSet<>(); - } + @NotNull + @Schema(required = true, description = "Token for your Plex Server. Found via Plex docs.") + private final String plexToken; - public PlexServer(String friendlyName, String machineIdentifier, String plexToken, String address, Integer port) { - this.friendlyName = friendlyName; - this.machineIdentifier = machineIdentifier; - this.plexToken = plexToken; - this.address = address; - this.port = port; - plexLibraries = new LinkedHashSet<>(); - } + @NotNull + @Schema(required = true, defaultValue = "localhost", description = "Address of your Plex Server") + private final String address; - public String getFriendlyName() { + @NotNull + @Schema(required = true, defaultValue = "32400", description = "Port of your Plex Server") + private final Integer port; + + @JsonCreator(mode = JsonCreator.Mode.PROPERTIES) + public PlexServer(@JsonProperty(value = "friendlyName") @Nullable String friendlyName, + @JsonProperty(value = "machineIdentifier") @Nullable String machineIdentifier, + @JsonProperty(value = "plexToken") @Nullable String plexToken, + @JsonProperty(value = "address") @Nullable String address, + @JsonProperty(value = "port") @Nullable Integer port, + @JsonProperty(value = "plexLibraries") @Nullable Set plexLibraries) { + this.friendlyName = friendlyName == null ? "" : friendlyName; + this.machineIdentifier = machineIdentifier == null ? "" : machineIdentifier; + this.plexToken = plexToken == null ? "" : plexToken; + this.address = address == null ? "": address; + this.port = port == null ? -1 : port; + this.plexLibraries = plexLibraries == null ? new LinkedHashSet<>() : plexLibraries; + } + + public @NotNull String getFriendlyName() { return friendlyName; } - public void setFriendlyName(String friendlyName) { - this.friendlyName = friendlyName; - } - - public String getMachineIdentifier() { + public @NotNull String getMachineIdentifier() { return machineIdentifier; } - public void setMachineIdentifier(String machineIdentifier) { - this.machineIdentifier = machineIdentifier; - } - - public Set getPlexLibraries() { + public @NotNull Set getPlexLibraries() { return plexLibraries; } - public String getPlexToken() { + public @NotNull String getPlexToken() { return plexToken; } - public void setPlexToken(String plexToken) { - this.plexToken = plexToken; - } - - public String getAddress() { + public @NotNull String getAddress() { return address; } - public void setAddress(String address) { - this.address = address; - } - - public Integer getPort() { + public @NotNull Integer getPort() { return port; } - public void setPort(Integer port) { - this.port = port; - } - @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/Plex/src/main/java/com/jasonhhouse/plex/video/Collection.java b/Plex/src/main/java/com/jasonhhouse/gaps/plex/video/Collection.java similarity index 97% rename from Plex/src/main/java/com/jasonhhouse/plex/video/Collection.java rename to Plex/src/main/java/com/jasonhhouse/gaps/plex/video/Collection.java index fcf9e72e..12f4ba0b 100755 --- a/Plex/src/main/java/com/jasonhhouse/plex/video/Collection.java +++ b/Plex/src/main/java/com/jasonhhouse/gaps/plex/video/Collection.java @@ -7,7 +7,7 @@ * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.jasonhhouse.plex.video; +package com.jasonhhouse.gaps.plex.video; import javax.persistence.Entity; import javax.persistence.GeneratedValue; diff --git a/Plex/src/main/java/com/jasonhhouse/plex/video/Country.java b/Plex/src/main/java/com/jasonhhouse/gaps/plex/video/Country.java similarity index 97% rename from Plex/src/main/java/com/jasonhhouse/plex/video/Country.java rename to Plex/src/main/java/com/jasonhhouse/gaps/plex/video/Country.java index 1476c892..0bf75405 100755 --- a/Plex/src/main/java/com/jasonhhouse/plex/video/Country.java +++ b/Plex/src/main/java/com/jasonhhouse/gaps/plex/video/Country.java @@ -7,7 +7,7 @@ * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.jasonhhouse.plex.video; +package com.jasonhhouse.gaps.plex.video; import javax.persistence.Entity; import javax.persistence.GeneratedValue; diff --git a/Plex/src/main/java/com/jasonhhouse/plex/video/Director.java b/Plex/src/main/java/com/jasonhhouse/gaps/plex/video/Director.java similarity index 97% rename from Plex/src/main/java/com/jasonhhouse/plex/video/Director.java rename to Plex/src/main/java/com/jasonhhouse/gaps/plex/video/Director.java index 05fea36a..e3e1f57f 100755 --- a/Plex/src/main/java/com/jasonhhouse/plex/video/Director.java +++ b/Plex/src/main/java/com/jasonhhouse/gaps/plex/video/Director.java @@ -7,7 +7,7 @@ * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.jasonhhouse.plex.video; +package com.jasonhhouse.gaps.plex.video; import javax.persistence.Entity; import javax.persistence.GeneratedValue; diff --git a/Plex/src/main/java/com/jasonhhouse/plex/video/Genre.java b/Plex/src/main/java/com/jasonhhouse/gaps/plex/video/Genre.java similarity index 97% rename from Plex/src/main/java/com/jasonhhouse/plex/video/Genre.java rename to Plex/src/main/java/com/jasonhhouse/gaps/plex/video/Genre.java index 4ce2baf7..b787e7b8 100755 --- a/Plex/src/main/java/com/jasonhhouse/plex/video/Genre.java +++ b/Plex/src/main/java/com/jasonhhouse/gaps/plex/video/Genre.java @@ -7,7 +7,7 @@ * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.jasonhhouse.plex.video; +package com.jasonhhouse.gaps.plex.video; import javax.persistence.Entity; import javax.persistence.GeneratedValue; diff --git a/Plex/src/main/java/com/jasonhhouse/plex/video/Media.java b/Plex/src/main/java/com/jasonhhouse/gaps/plex/video/Media.java similarity index 99% rename from Plex/src/main/java/com/jasonhhouse/plex/video/Media.java rename to Plex/src/main/java/com/jasonhhouse/gaps/plex/video/Media.java index 0fcfdca7..e7a8cc8c 100755 --- a/Plex/src/main/java/com/jasonhhouse/plex/video/Media.java +++ b/Plex/src/main/java/com/jasonhhouse/gaps/plex/video/Media.java @@ -7,7 +7,7 @@ * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.jasonhhouse.plex.video; +package com.jasonhhouse.gaps.plex.video; import java.util.List; import java.util.Objects; diff --git a/Plex/src/main/java/com/jasonhhouse/plex/video/MediaContainer.java b/Plex/src/main/java/com/jasonhhouse/gaps/plex/video/MediaContainer.java similarity index 99% rename from Plex/src/main/java/com/jasonhhouse/plex/video/MediaContainer.java rename to Plex/src/main/java/com/jasonhhouse/gaps/plex/video/MediaContainer.java index 2092686b..5ad829f9 100755 --- a/Plex/src/main/java/com/jasonhhouse/plex/video/MediaContainer.java +++ b/Plex/src/main/java/com/jasonhhouse/gaps/plex/video/MediaContainer.java @@ -7,7 +7,7 @@ * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.jasonhhouse.plex.video; +package com.jasonhhouse.gaps.plex.video; import java.util.List; import javax.persistence.CascadeType; diff --git a/Plex/src/main/java/com/jasonhhouse/plex/video/Part.java b/Plex/src/main/java/com/jasonhhouse/gaps/plex/video/Part.java similarity index 98% rename from Plex/src/main/java/com/jasonhhouse/plex/video/Part.java rename to Plex/src/main/java/com/jasonhhouse/gaps/plex/video/Part.java index cce13d56..0eb8528c 100755 --- a/Plex/src/main/java/com/jasonhhouse/plex/video/Part.java +++ b/Plex/src/main/java/com/jasonhhouse/gaps/plex/video/Part.java @@ -7,7 +7,7 @@ * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.jasonhhouse.plex.video; +package com.jasonhhouse.gaps.plex.video; import java.util.Objects; import javax.persistence.Entity; diff --git a/Plex/src/main/java/com/jasonhhouse/plex/video/Role.java b/Plex/src/main/java/com/jasonhhouse/gaps/plex/video/Role.java similarity index 97% rename from Plex/src/main/java/com/jasonhhouse/plex/video/Role.java rename to Plex/src/main/java/com/jasonhhouse/gaps/plex/video/Role.java index 787c6440..1a8de480 100755 --- a/Plex/src/main/java/com/jasonhhouse/plex/video/Role.java +++ b/Plex/src/main/java/com/jasonhhouse/gaps/plex/video/Role.java @@ -7,7 +7,7 @@ * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.jasonhhouse.plex.video; +package com.jasonhhouse.gaps.plex.video; import javax.persistence.Entity; import javax.persistence.GeneratedValue; diff --git a/Plex/src/main/java/com/jasonhhouse/plex/video/Video.java b/Plex/src/main/java/com/jasonhhouse/gaps/plex/video/Video.java similarity index 99% rename from Plex/src/main/java/com/jasonhhouse/plex/video/Video.java rename to Plex/src/main/java/com/jasonhhouse/gaps/plex/video/Video.java index 4027ad28..97779b6c 100755 --- a/Plex/src/main/java/com/jasonhhouse/plex/video/Video.java +++ b/Plex/src/main/java/com/jasonhhouse/gaps/plex/video/Video.java @@ -7,7 +7,7 @@ * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.jasonhhouse.plex.video; +package com.jasonhhouse.gaps.plex.video; import java.util.List; import java.util.Objects; diff --git a/Plex/src/main/java/com/jasonhhouse/plex/video/Writer.java b/Plex/src/main/java/com/jasonhhouse/gaps/plex/video/Writer.java similarity index 97% rename from Plex/src/main/java/com/jasonhhouse/plex/video/Writer.java rename to Plex/src/main/java/com/jasonhhouse/gaps/plex/video/Writer.java index 08c5e678..61f950bf 100755 --- a/Plex/src/main/java/com/jasonhhouse/plex/video/Writer.java +++ b/Plex/src/main/java/com/jasonhhouse/gaps/plex/video/Writer.java @@ -7,7 +7,7 @@ * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.jasonhhouse.plex.video; +package com.jasonhhouse.gaps.plex.video; import javax.persistence.Entity; import javax.persistence.GeneratedValue; diff --git a/Plex/src/main/java/com/jasonhhouse/plex/libs/Location.java b/Plex/src/main/java/com/jasonhhouse/plex/libs/Location.java deleted file mode 100644 index d7807051..00000000 --- a/Plex/src/main/java/com/jasonhhouse/plex/libs/Location.java +++ /dev/null @@ -1,128 +0,0 @@ - -package com.jasonhhouse.plex.libs; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; -import javax.xml.bind.annotation.XmlValue; - - -/** - *

Java class for anonymous complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType>
- *   <simpleContent>
- *     <extension base="<http://www.w3.org/2001/XMLSchema>string">
- *       <attribute name="id" type="{http://www.w3.org/2001/XMLSchema}byte" />
- *       <attribute name="path" type="{http://www.w3.org/2001/XMLSchema}string" />
- *     </extension>
- *   </simpleContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "value" -}) -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(JsonInclude.Include.NON_NULL) -@XmlRootElement(name = "Location") -public class Location { - - @XmlValue - protected String value; - @XmlAttribute(name = "id") - protected Byte id; - @XmlAttribute(name = "path") - protected String path; - - /** - * Gets the value of the value property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getValue() { - return value; - } - - /** - * Sets the value of the value property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setValue(String value) { - this.value = value; - } - - /** - * Gets the value of the id property. - * - * @return - * possible object is - * {@link Byte } - * - */ - public Byte getId() { - return id; - } - - /** - * Sets the value of the id property. - * - * @param value - * allowed object is - * {@link Byte } - * - */ - public void setId(Byte value) { - this.id = value; - } - - /** - * Gets the value of the path property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getPath() { - return path; - } - - /** - * Sets the value of the path property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setPath(String value) { - this.path = value; - } - - @Override - public String toString() { - return "Location{" + - "value='" + value + '\'' + - ", id=" + id + - ", path='" + path + '\'' + - '}'; - } -} diff --git a/Plex/src/main/java/com/jasonhhouse/plex/libs/MediaContainer.java b/Plex/src/main/java/com/jasonhhouse/plex/libs/MediaContainer.java deleted file mode 100644 index b50190ca..00000000 --- a/Plex/src/main/java/com/jasonhhouse/plex/libs/MediaContainer.java +++ /dev/null @@ -1,246 +0,0 @@ - -package com.jasonhhouse.plex.libs; - -import java.util.ArrayList; -import java.util.List; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - - -/** - *

Java class for anonymous complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType>
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element ref="{}Directory" maxOccurs="unbounded" minOccurs="0"/>
- *       </sequence>
- *       <attribute name="size" type="{http://www.w3.org/2001/XMLSchema}byte" />
- *       <attribute name="allowSync" type="{http://www.w3.org/2001/XMLSchema}byte" />
- *       <attribute name="identifier" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <attribute name="mediaTagPrefix" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <attribute name="mediaTagVersion" type="{http://www.w3.org/2001/XMLSchema}int" />
- *       <attribute name="title1" type="{http://www.w3.org/2001/XMLSchema}string" />
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- * - * - */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "plexLibrary" -}) -@XmlRootElement(name = "MediaContainer") -public class MediaContainer { - - @XmlElement(name = "Directory") - protected List plexLibrary; - @XmlAttribute(name = "size") - protected Byte size; - @XmlAttribute(name = "allowSync") - protected Byte allowSync; - @XmlAttribute(name = "identifier") - protected String identifier; - @XmlAttribute(name = "mediaTagPrefix") - protected String mediaTagPrefix; - @XmlAttribute(name = "mediaTagVersion") - protected Integer mediaTagVersion; - @XmlAttribute(name = "title1") - protected String title1; - - /** - * Gets the value of the directory property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the directory property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getDirectory().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link PlexLibrary } - * - * - */ - public List getPlexLibraries() { - if (plexLibrary == null) { - plexLibrary = new ArrayList<>(); - } - return this.plexLibrary; - } - - /** - * Gets the value of the size property. - * - * @return - * possible object is - * {@link Byte } - * - */ - public Byte getSize() { - return size; - } - - /** - * Sets the value of the size property. - * - * @param value - * allowed object is - * {@link Byte } - * - */ - public void setSize(Byte value) { - this.size = value; - } - - /** - * Gets the value of the allowSync property. - * - * @return - * possible object is - * {@link Byte } - * - */ - public Byte getAllowSync() { - return allowSync; - } - - /** - * Sets the value of the allowSync property. - * - * @param value - * allowed object is - * {@link Byte } - * - */ - public void setAllowSync(Byte value) { - this.allowSync = value; - } - - /** - * Gets the value of the identifier property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getIdentifier() { - return identifier; - } - - /** - * Sets the value of the identifier property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setIdentifier(String value) { - this.identifier = value; - } - - /** - * Gets the value of the mediaTagPrefix property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getMediaTagPrefix() { - return mediaTagPrefix; - } - - /** - * Sets the value of the mediaTagPrefix property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setMediaTagPrefix(String value) { - this.mediaTagPrefix = value; - } - - /** - * Gets the value of the mediaTagVersion property. - * - * @return - * possible object is - * {@link Integer } - * - */ - public Integer getMediaTagVersion() { - return mediaTagVersion; - } - - /** - * Sets the value of the mediaTagVersion property. - * - * @param value - * allowed object is - * {@link Integer } - * - */ - public void setMediaTagVersion(Integer value) { - this.mediaTagVersion = value; - } - - /** - * Gets the value of the title1 property. - * - * @return - * possible object is - * {@link String } - * - */ - public String getTitle1() { - return title1; - } - - /** - * Sets the value of the title1 property. - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setTitle1(String value) { - this.title1 = value; - } - - @Override - public String toString() { - return "MediaContainer{" + - "plexLibrary=" + plexLibrary + - ", size=" + size + - ", allowSync=" + allowSync + - ", identifier='" + identifier + '\'' + - ", mediaTagPrefix='" + mediaTagPrefix + '\'' + - ", mediaTagVersion=" + mediaTagVersion + - ", title1='" + title1 + '\'' + - '}'; - } -} diff --git a/Plex/src/main/java/com/jasonhhouse/plex/libs/PlexLibrary.java b/Plex/src/main/java/com/jasonhhouse/plex/libs/PlexLibrary.java deleted file mode 100644 index 7ca746a1..00000000 --- a/Plex/src/main/java/com/jasonhhouse/plex/libs/PlexLibrary.java +++ /dev/null @@ -1,549 +0,0 @@ - -package com.jasonhhouse.plex.libs; - -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; -import com.fasterxml.jackson.annotation.JsonInclude; -import javax.xml.bind.annotation.XmlAccessType; -import javax.xml.bind.annotation.XmlAccessorType; -import javax.xml.bind.annotation.XmlAttribute; -import javax.xml.bind.annotation.XmlElement; -import javax.xml.bind.annotation.XmlRootElement; -import javax.xml.bind.annotation.XmlType; - - -/** - *

Java class for anonymous complex type. - * - *

The following schema fragment specifies the expected content contained within this class. - * - *

- * <complexType>
- *   <complexContent>
- *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
- *       <sequence>
- *         <element ref="{}Location"/>
- *       </sequence>
- *       <attribute name="allowSync" type="{http://www.w3.org/2001/XMLSchema}byte" />
- *       <attribute name="art" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <attribute name="composite" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <attribute name="filters" type="{http://www.w3.org/2001/XMLSchema}byte" />
- *       <attribute name="refreshing" type="{http://www.w3.org/2001/XMLSchema}byte" />
- *       <attribute name="thumb" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <attribute name="key" type="{http://www.w3.org/2001/XMLSchema}byte" />
- *       <attribute name="type" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <attribute name="title" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <attribute name="agent" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <attribute name="scanner" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <attribute name="language" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <attribute name="uuid" type="{http://www.w3.org/2001/XMLSchema}string" />
- *       <attribute name="updatedAt" type="{http://www.w3.org/2001/XMLSchema}int" />
- *       <attribute name="createdAt" type="{http://www.w3.org/2001/XMLSchema}int" />
- *       <attribute name="scannedAt" type="{http://www.w3.org/2001/XMLSchema}int" />
- *       <attribute name="content" type="{http://www.w3.org/2001/XMLSchema}byte" />
- *       <attribute name="directory" type="{http://www.w3.org/2001/XMLSchema}byte" />
- *       <attribute name="contentChangedAt" type="{http://www.w3.org/2001/XMLSchema}short" />
- *       <attribute name="hidden" type="{http://www.w3.org/2001/XMLSchema}byte" />
- *     </restriction>
- *   </complexContent>
- * </complexType>
- * 
- */ -@XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "location" -}) -@JsonIgnoreProperties(ignoreUnknown = true) -@JsonInclude(JsonInclude.Include.NON_NULL) -@XmlRootElement(name = "Directory") -public class PlexLibrary { - - @XmlElement(name = "Location", required = true) - protected Location location; - @XmlAttribute(name = "allowSync") - protected Integer allowSync; - @XmlAttribute(name = "art") - protected String art; - @XmlAttribute(name = "composite") - protected String composite; - @XmlAttribute(name = "filters") - protected Integer filters; - @XmlAttribute(name = "refreshing") - protected Integer refreshing; - @XmlAttribute(name = "thumb") - protected String thumb; - @XmlAttribute(name = "key") - protected Integer key; - @XmlAttribute(name = "type") - protected String type; - @XmlAttribute(name = "title") - protected String title; - @XmlAttribute(name = "agent") - protected String agent; - @XmlAttribute(name = "scanner") - protected String scanner; - @XmlAttribute(name = "language") - protected String language; - @XmlAttribute(name = "uuid") - protected String uuid; - @XmlAttribute(name = "updatedAt") - protected Integer updatedAt; - @XmlAttribute(name = "createdAt") - protected Integer createdAt; - @XmlAttribute(name = "scannedAt") - protected Integer scannedAt; - @XmlAttribute(name = "content") - protected Integer content; - @XmlAttribute(name = "directory") - protected Integer directory; - @XmlAttribute(name = "contentChangedAt") - protected Short contentChangedAt; - @XmlAttribute(name = "hidden") - protected Integer hidden; - - /** - * Gets the value of the location property. - * - * @return possible object is - * {@link Location } - */ - public Location getLocation() { - return location; - } - - /** - * Sets the value of the location property. - * - * @param value allowed object is - * {@link Location } - */ - public void setLocation(Location value) { - this.location = value; - } - - /** - * Gets the value of the allowSync property. - * - * @return possible object is - * {@link Integer } - */ - public Integer getAllowSync() { - return allowSync; - } - - /** - * Sets the value of the allowSync property. - * - * @param value allowed object is - * {@link Integer } - */ - public void setAllowSync(Integer value) { - this.allowSync = value; - } - - /** - * Gets the value of the art property. - * - * @return possible object is - * {@link String } - */ - public String getArt() { - return art; - } - - /** - * Sets the value of the art property. - * - * @param value allowed object is - * {@link String } - */ - public void setArt(String value) { - this.art = value; - } - - /** - * Gets the value of the composite property. - * - * @return possible object is - * {@link String } - */ - public String getComposite() { - return composite; - } - - /** - * Sets the value of the composite property. - * - * @param value allowed object is - * {@link String } - */ - public void setComposite(String value) { - this.composite = value; - } - - /** - * Gets the value of the filters property. - * - * @return possible object is - * {@link Integer } - */ - public Integer getFilters() { - return filters; - } - - /** - * Sets the value of the filters property. - * - * @param value allowed object is - * {@link Integer } - */ - public void setFilters(Integer value) { - this.filters = value; - } - - /** - * Gets the value of the refreshing property. - * - * @return possible object is - * {@link Integer } - */ - public Integer getRefreshing() { - return refreshing; - } - - /** - * Sets the value of the refreshing property. - * - * @param value allowed object is - * {@link Integer } - */ - public void setRefreshing(Integer value) { - this.refreshing = value; - } - - /** - * Gets the value of the thumb property. - * - * @return possible object is - * {@link String } - */ - public String getThumb() { - return thumb; - } - - /** - * Sets the value of the thumb property. - * - * @param value allowed object is - * {@link String } - */ - public void setThumb(String value) { - this.thumb = value; - } - - /** - * Gets the value of the key property. - * - * @return possible object is - * {@link Integer } - */ - public Integer getKey() { - return key; - } - - /** - * Sets the value of the key property. - * - * @param value allowed object is - * {@link Integer } - */ - public void setKey(Integer value) { - this.key = value; - } - - /** - * Gets the value of the type property. - * - * @return possible object is - * {@link String } - */ - public String getType() { - return type; - } - - /** - * Sets the value of the type property. - * - * @param value allowed object is - * {@link String } - */ - public void setType(String value) { - this.type = value; - } - - /** - * Gets the value of the title property. - * - * @return possible object is - * {@link String } - */ - public String getTitle() { - return title; - } - - /** - * Sets the value of the title property. - * - * @param value allowed object is - * {@link String } - */ - public void setTitle(String value) { - this.title = value; - } - - /** - * Gets the value of the agent property. - * - * @return possible object is - * {@link String } - */ - public String getAgent() { - return agent; - } - - /** - * Sets the value of the agent property. - * - * @param value allowed object is - * {@link String } - */ - public void setAgent(String value) { - this.agent = value; - } - - /** - * Gets the value of the scanner property. - * - * @return possible object is - * {@link String } - */ - public String getScanner() { - return scanner; - } - - /** - * Sets the value of the scanner property. - * - * @param value allowed object is - * {@link String } - */ - public void setScanner(String value) { - this.scanner = value; - } - - /** - * Gets the value of the language property. - * - * @return possible object is - * {@link String } - */ - public String getLanguage() { - return language; - } - - /** - * Sets the value of the language property. - * - * @param value allowed object is - * {@link String } - */ - public void setLanguage(String value) { - this.language = value; - } - - /** - * Gets the value of the uuid property. - * - * @return possible object is - * {@link String } - */ - public String getUuid() { - return uuid; - } - - /** - * Sets the value of the uuid property. - * - * @param value allowed object is - * {@link String } - */ - public void setUuid(String value) { - this.uuid = value; - } - - /** - * Gets the value of the updatedAt property. - * - * @return possible object is - * {@link Integer } - */ - public Integer getUpdatedAt() { - return updatedAt; - } - - /** - * Sets the value of the updatedAt property. - * - * @param value allowed object is - * {@link Integer } - */ - public void setUpdatedAt(Integer value) { - this.updatedAt = value; - } - - /** - * Gets the value of the createdAt property. - * - * @return possible object is - * {@link Integer } - */ - public Integer getCreatedAt() { - return createdAt; - } - - /** - * Sets the value of the createdAt property. - * - * @param value allowed object is - * {@link Integer } - */ - public void setCreatedAt(Integer value) { - this.createdAt = value; - } - - /** - * Gets the value of the scannedAt property. - * - * @return possible object is - * {@link Integer } - */ - public Integer getScannedAt() { - return scannedAt; - } - - /** - * Sets the value of the scannedAt property. - * - * @param value allowed object is - * {@link Integer } - */ - public void setScannedAt(Integer value) { - this.scannedAt = value; - } - - /** - * Gets the value of the content property. - * - * @return possible object is - * {@link Integer } - */ - public Integer getContent() { - return content; - } - - /** - * Sets the value of the content property. - * - * @param value allowed object is - * {@link Integer } - */ - public void setContent(Integer value) { - this.content = value; - } - - /** - * Gets the value of the directory property. - * - * @return possible object is - * {@link Integer } - */ - public Integer getDirectory() { - return directory; - } - - /** - * Sets the value of the directory property. - * - * @param value allowed object is - * {@link Integer } - */ - public void setDirectory(Integer value) { - this.directory = value; - } - - /** - * Gets the value of the contentChangedAt property. - * - * @return possible object is - * {@link Short } - */ - public Short getContentChangedAt() { - return contentChangedAt; - } - - /** - * Sets the value of the contentChangedAt property. - * - * @param value allowed object is - * {@link Short } - */ - public void setContentChangedAt(Short value) { - this.contentChangedAt = value; - } - - /** - * Gets the value of the hidden property. - * - * @return possible object is - * {@link Integer } - */ - public Integer getHidden() { - return hidden; - } - - /** - * Sets the value of the hidden property. - * - * @param value allowed object is - * {@link Integer } - */ - public void setHidden(Integer value) { - this.hidden = value; - } - - @Override - public String toString() { - return "PlexLibrary{" + - "location=" + location + - ", allowSync=" + allowSync + - ", art='" + art + '\'' + - ", composite='" + composite + '\'' + - ", filters=" + filters + - ", refreshing=" + refreshing + - ", thumb='" + thumb + '\'' + - ", key=" + key + - ", type='" + type + '\'' + - ", title='" + title + '\'' + - ", agent='" + agent + '\'' + - ", scanner='" + scanner + '\'' + - ", language='" + language + '\'' + - ", uuid='" + uuid + '\'' + - ", updatedAt=" + updatedAt + - ", createdAt=" + createdAt + - ", scannedAt=" + scannedAt + - ", content=" + content + - ", directory=" + directory + - ", contentChangedAt=" + contentChangedAt + - ", hidden=" + hidden + - '}'; - } -} diff --git a/Plex/src/main/java/com/jasonhhouse/plex/libs/libraries.xsd b/Plex/src/main/java/com/jasonhhouse/plex/libs/libraries.xsd deleted file mode 100644 index 427561c9..00000000 --- a/Plex/src/main/java/com/jasonhhouse/plex/libs/libraries.xsd +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Plex/src/test/java/com/jasonhhouse/plex/PlexTest.java b/Plex/src/test/java/com/jasonhhouse/gaps/plex/PlexTest.java similarity index 96% rename from Plex/src/test/java/com/jasonhhouse/plex/PlexTest.java rename to Plex/src/test/java/com/jasonhhouse/gaps/plex/PlexTest.java index 0b85e105..517c6e60 100644 --- a/Plex/src/test/java/com/jasonhhouse/plex/PlexTest.java +++ b/Plex/src/test/java/com/jasonhhouse/gaps/plex/PlexTest.java @@ -7,9 +7,9 @@ * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -package com.jasonhhouse.plex; +package com.jasonhhouse.gaps.plex; -import com.jasonhhouse.plex.video.MediaContainer; +import com.jasonhhouse.gaps.plex.video.MediaContainer; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; diff --git a/Plex/src/test/resources/com/jasonhhouse/plex/plex_videos.xml b/Plex/src/test/resources/com/jasonhhouse/gaps/plex/plex_videos.xml similarity index 100% rename from Plex/src/test/resources/com/jasonhhouse/plex/plex_videos.xml rename to Plex/src/test/resources/com/jasonhhouse/gaps/plex/plex_videos.xml From 9a5cd2d11339977f405775815b678d95dd8fa398 Mon Sep 17 00:00:00 2001 From: Jason House Date: Wed, 23 Sep 2020 23:21:48 +0900 Subject: [PATCH 2/3] Adding modal and controller --- .../controller/ConfigurationController.java | 8 +++ .../main/resources/static/js/configuration.js | 3 ++ .../static/js/modules/plex-configuration.js | 49 +++++++++++++++++++ .../resources/templates/configuration.html | 45 +++++++++++++++-- build.bat | 1 + minify | 3 +- package.json | 3 +- 7 files changed, 106 insertions(+), 6 deletions(-) create mode 100644 GapsWeb/src/main/resources/static/js/modules/plex-configuration.js diff --git a/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/ConfigurationController.java b/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/ConfigurationController.java index db7d2d58..5cb2e9aa 100755 --- a/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/ConfigurationController.java +++ b/GapsWeb/src/main/java/com/jasonhhouse/gaps/controller/ConfigurationController.java @@ -203,4 +203,12 @@ public ResponseEntity postSaveTmdbKey(@PathVariable("tmdbKey") final St return ResponseEntity.ok().body(payload); } + @PutMapping(value = "/update/plex/library", + produces = MediaType.APPLICATION_JSON_VALUE) + @ResponseBody + public ResponseEntity putPlexLibrary(final Object object) { + LOGGER.info("putPlexLibrary( {} )", object); + + return ResponseEntity.ok().body(Payload.PLEX_CONNECTION_SUCCEEDED); + } } diff --git a/GapsWeb/src/main/resources/static/js/configuration.js b/GapsWeb/src/main/resources/static/js/configuration.js index 2bedb2b4..f6c1c824 100755 --- a/GapsWeb/src/main/resources/static/js/configuration.js +++ b/GapsWeb/src/main/resources/static/js/configuration.js @@ -20,6 +20,7 @@ import {saveEmailNotifications, testEmailNotifications} from "./modules/email-no import {saveSchedule} from "./modules/schedule.min.js"; import {getSoundOptions, savePushOverNotifications, testPushOverNotifications} from "./modules/push-over-notifications.min.js"; import {saveDiscordNotifications, testDiscordNotifications} from "./modules/discord-notifications.min.js"; +import {openPlexLibraryConfigurationModel, savePlexLibraryConfiguration} from "./modules/plex-configuration.min.js" let plexSpinner, plexSaveSuccess, plexSaveError, plexTestSuccess, plexTestError, plexDeleteSuccess, plexDeleteError, plexDuplicateError; @@ -137,6 +138,8 @@ document.addEventListener('DOMContentLoaded', function () { window.testPushOver = testPushOverNotifications; window.savePushOver = savePushOverNotifications; window.saveSchedule = saveSchedule; + window.openPlexLibraryConfigurationModel = openPlexLibraryConfigurationModel; + window.savePlexLibraryConfiguration = savePlexLibraryConfiguration; getSoundOptions(); }); diff --git a/GapsWeb/src/main/resources/static/js/modules/plex-configuration.js b/GapsWeb/src/main/resources/static/js/modules/plex-configuration.js new file mode 100644 index 00000000..c7b56225 --- /dev/null +++ b/GapsWeb/src/main/resources/static/js/modules/plex-configuration.js @@ -0,0 +1,49 @@ +/* + * Copyright 2020 Jason H House + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + */ + +export function openPlexLibraryConfigurationModel(machineIdentifier, key) { + const obj = { + 'machineIdentifier': machineIdentifier, + 'key': key + } + const plexLibraryButtonConfiguration = $("#plexLibraryButtonConfiguration").html(); + const theTemplate = Handlebars.compile(plexLibraryButtonConfiguration); + const theCompiledHtml = theTemplate(obj); + const buttonHolder = document.getElementById('buttonHolder'); + buttonHolder.innerHTML = theCompiledHtml; + $('#plexLibraryConfigurationModal').modal('show'); +} + +export async function savePlexLibraryConfiguration(machineIdentifier, key) { + const obj = { + 'machineIdentifier': machineIdentifier, + 'key': key, + 'enabled': document.getElementById('libraryEnabled').value, + 'defaultLibrary': document.getElementById('defaultLibrary').value + } + + let response = await fetch(`/configuration/update/plex/library`, { + method: 'put', + headers: { + 'Accept': 'application/json', + 'Content-Type': 'application/json' + }, + body: JSON.stringify(obj) + }) + const put = await response.json(); + /*if (put.code && put.code === Payload.SCHEDULE_UPDATED) { + hideAllAlertsAndSpinners(); + document.getElementById('scheduleSaveSuccess').style.display = 'block'; + } else { + hideAllAlertsAndSpinners(); + document.getElementById('scheduleSaveError').style.display = 'block'; + }*/ +} \ No newline at end of file diff --git a/GapsWeb/src/main/resources/templates/configuration.html b/GapsWeb/src/main/resources/templates/configuration.html index 37ba103b..7ce8beb0 100755 --- a/GapsWeb/src/main/resources/templates/configuration.html +++ b/GapsWeb/src/main/resources/templates/configuration.html @@ -415,6 +415,41 @@

Success!

+ + + +