-
-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add custom / private emby functionality
- Loading branch information
Showing
13 changed files
with
270 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
core/src/main/java/org/nzbhydra/config/safeconfig/SafeEmbyConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.nzbhydra.config.safeconfig; | ||
|
||
import lombok.Getter; | ||
import org.nzbhydra.config.emby.EmbyConfig; | ||
|
||
|
||
@Getter | ||
public class SafeEmbyConfig { | ||
|
||
private final String embyBaseUrl; | ||
private final String embyApiKey; | ||
|
||
public SafeEmbyConfig(EmbyConfig embyConfig) { | ||
embyBaseUrl = embyConfig.getEmbyBaseUrl(); | ||
embyApiKey = embyConfig.getEmbyApiKey(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* (C) Copyright 2025 TheOtherP ([email protected]) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.nzbhydra.emby; | ||
|
||
import com.fasterxml.jackson.core.type.TypeReference; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.nzbhydra.config.ConfigProvider; | ||
import org.nzbhydra.mapping.emby.EmbyItemsResponse; | ||
import org.nzbhydra.webaccess.WebAccess; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.security.access.annotation.Secured; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import org.springframework.web.util.UriComponentsBuilder; | ||
|
||
import java.io.IOException; | ||
|
||
@RestController | ||
public class EmbyWeb { | ||
|
||
private static final Logger logger = LoggerFactory.getLogger(EmbyWeb.class); | ||
|
||
@Autowired | ||
private WebAccess webAccess; | ||
@Autowired | ||
private ConfigProvider configProvider; | ||
|
||
@Secured({"ROLE_USER"}) | ||
@RequestMapping(value = "/internalapi/emby/isSeriesAvailable", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) | ||
public boolean isSeriesAvailable(@RequestParam String tvdbId) { | ||
final String uriString = getUriBuilder() | ||
.queryParam("IncludeItemTypes", "Series") | ||
.queryParam("AnyProviderIdEquals", "tvdb." + tvdbId).toUriString(); | ||
try { | ||
final EmbyItemsResponse response = webAccess.callUrl(uriString, new TypeReference<>() { | ||
}); | ||
return response.getTotalRecordCount() > 0; | ||
} catch (IOException e) { | ||
logger.error("Error calling Emby API", e); | ||
return false; | ||
} | ||
} | ||
|
||
@Secured({"ROLE_USER"}) | ||
@RequestMapping(value = "/internalapi/emby/isMovieAvailable", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) | ||
public boolean isMovieAvailable(@RequestParam String tmdbId) { | ||
final String uriString = getUriBuilder() | ||
.queryParam("IncludeItemTypes", "Movies") | ||
.queryParam("AnyProviderIdEquals", "tmdb." + tmdbId).toUriString(); | ||
try { | ||
final EmbyItemsResponse response = webAccess.callUrl(uriString, new TypeReference<>() { | ||
}); | ||
return response.getTotalRecordCount() > 0; | ||
} catch (IOException e) { | ||
logger.error("Error calling Emby API", e); | ||
return false; | ||
} | ||
} | ||
|
||
@NotNull | ||
private UriComponentsBuilder getUriBuilder() { | ||
return UriComponentsBuilder.fromHttpUrl(configProvider.getBaseConfig().getEmby().getEmbyBaseUrl()) | ||
.pathSegment("emby", "Items") | ||
.queryParam("Recursive", "true") | ||
.queryParam("api_key", configProvider.getBaseConfig().getEmby().getEmbyApiKey()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
shared/mapping/src/main/java/org/nzbhydra/config/emby/EmbyConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* (C) Copyright 2025 TheOtherP ([email protected]) | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.nzbhydra.config.emby; | ||
|
||
import lombok.Data; | ||
import org.nzbhydra.springnative.ReflectionMarker; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
|
||
@Data | ||
@ReflectionMarker | ||
@ConfigurationProperties(prefix = "downloading") | ||
public class EmbyConfig { | ||
|
||
private String embyBaseUrl; | ||
private String embyApiKey; | ||
|
||
} |
Oops, something went wrong.