Skip to content

Commit

Permalink
1.3.7 <=> TVDB_API_KEY variable added; TVDB_AUTH_STRING deprecated
Browse files Browse the repository at this point in the history
  • Loading branch information
mynttt committed Apr 3, 2020
1 parent f00ec5b commit 0f91acd
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 36 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 1.3.7
- Deprecated environment variable TVDB_AUTH_STRING as TVDB API only requires the API Key
- TVDB_AUTH_STRING can still be used, the API Key will be extracted automatically
- New variable TVDB_API_KEY introduced which only takes the TVDB API Key

## 1.3.6
- Asynchronous resolvement => faster HTTP processing with APIs
- If TMDB capability exists (TMDB API key set) the tool will also go after movie libraries with the TMDB agent (com.plexapp.agents.themoviedb)
Expand Down
15 changes: 11 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,17 @@ Docker is on [dockerhub](https://hub.docker.com/r/mynttt/updatetool) | [UnRaid i
Name | Description
:-------------------------:|:-------------------------:|
TMDB_API_KEY|Enables TMDB Movie/Series library processing
TVDB_AUTH_STRING|Enables TVDB Series library processing
TVDB_API_KEY|Enables TVDB Series library processing
IGNORE_LIBS|Ignore libraries with certain IDs ([more here](#Ignore-libraries-from-being-updated))
CAPABILITIES|Custom flags for the tool ([more here](#supply-custom-capability-flags))

Deprecated variables can still be used although their usage is discouraged.

### Deprecated Environment Variables
Name | Description | Deprecation
:-------------------------:|:-------------------------:|:-------------------------:|
TVDB_AUTH_STRING|Enables TVDB Series library processing|API Key is enough for this tool to work

## To run your docker:

```bash
Expand All @@ -76,7 +83,7 @@ docker run -dit -e RUN_EVERY_N_HOURS=12 \

docker run -dit -e RUN_EVERY_N_HOURS=12 \
-e TMDB_API_KEY=yourkey \
-e TVDB_AUTH_STRING="tvdbusername;tvdbuserid;tvdbapikey" \
-e TVDB_API_KEY=tvdbapikey \
-v "/mnt/data/Plex Media Server":/plexdata \
-v "/mnt/data/imdpupdaterconfig":/config \
mynttt/updatetool
Expand All @@ -92,7 +99,7 @@ docker run -dit
-e TMDB_API_KEY=yourkey \
# Three items are required to auth with TVDB username, userkey, apikey
# Supply these as semicolon seperated values. Example: username;DAWIDK9CJKWFJAWKF;e33914feabd52e8192011b0ce6c8
-e TVDB_AUTH_STRING="tvdbusername;tvdbuserkey;tvdbapikey" \
-e TVDB_API_KEY=tvdbapikey \
# The plex data root (that contains Plug-ins, Metadata, ...
# https://support.plex.tv/articles/202915258-where-is-the-plex-media-server-data-directory-located/
-v "/mnt/data/Plex Media Server":/plexdata \
Expand All @@ -101,7 +108,7 @@ docker run -dit
mynttt/updatetool
```

[TVDB User Key](https://thetvdb.com/dashboard/account/editinfo) - [TVDB API Key](https://thetvdb.com/dashboard/account/apikey)
[TVDB API Key](https://thetvdb.com/dashboard/account/apikey)

*"/mnt/data/Plex Media Server" and "/mnt/data/imdpupdaterconfig" are just sample paths! Set your own paths there or it will probably not work!*

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.3.6
1.3.7
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
id 'eclipse'
}

version = '1.3.6'
version = '1.3.7'
sourceCompatibility = '11'

new File(projectDir, "VERSION").text = version;
Expand Down
Binary file modified img/unraidv3.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 4 additions & 5 deletions src/main/java/updatetool/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ public enum Implementations {
"PLEX_DATA_DIR: Used for the data directory of plex",
"The following environment variables are optional and enhance the tool in certain ways.",
"(Optional) TMDB_API_KEY: Used to convert TMDB matched items to IMDB items. The fallback will only be available if this is set.",
"(Optional) TVDB_AUTH_STRING: Used to auth with the TVDB API. Must be entered as a ';' seperated string of username, userid, apikey",
" Example: username;DAWIDK9CJKWFJAWKF;e33914feabd52e8192011b0ce6c8",
"(Optional) TVDB_API_KEY: Used to auth with the TVDB API.",
"(Optional) IGNORE_LIBS: Ignore libraries from being touched by this tool by supplying a set of library ids as a semicolon ';' seperated string.",
" Example: Ignoring 1 => IGNORE_LIBS=1 | Ignoring 1, 2, 3 => IGNORE_LIBS=1;2;3",
"(Optional) CAPABILITIES: Specify special settings for the tool. Must be entered as a ';' seperated string.",
Expand Down Expand Up @@ -172,10 +171,10 @@ public static void testApiTmdb(String apikeyTmdb) throws Exception {
genericApiTest(api);
}

public static void testApiTvdb(String[] credentials) {
Logger.info("Testing TVDB API authorization: username={} | userkey={} | apikey={}", credentials[0], credentials[1], credentials[2]);
public static void testApiTvdb(String key) {
Logger.info("Testing TVDB API authorization: apikey={}", key);
try {
new TvdbApi(credentials);
new TvdbApi(key);
} catch(ApiCallFailedException e) {
Logger.error("API Test failed: " + e.getMessage());
Logger.error("Keys available under: https://thetvdb.com/");
Expand Down
10 changes: 4 additions & 6 deletions src/main/java/updatetool/common/TvdbApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,18 @@ public String getImdbId() {
}
}

public TvdbApi(String[] credentials) throws ApiCallFailedException {
public TvdbApi(String key) throws ApiCallFailedException {
super();
authToken = "Bearer " + auth(credentials);
authToken = "Bearer " + auth(key);
}

private class Token { String token; };

private String auth(String[] credentials) throws ApiCallFailedException {
private String auth(String key) throws ApiCallFailedException {
try {
var response = send(
postJson(BASE_URL + "/login", gson.toJson(Map.of(
"username", credentials[0],
"userkey", credentials[1],
"apikey", credentials[2])
"apikey", key)
))
);
if(response.statusCode() != 200) {
Expand Down
29 changes: 16 additions & 13 deletions src/main/java/updatetool/imdb/ImdbDockerImplementation.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,14 @@ public class ImdbDockerImplementation implements Implementation {
private static final Set<Long> IGNORE_LIBRARIES = new HashSet<>();

public int RUN_EVERY_N_HOUR = 12;
private String apikeyTmdb;

//Format: <USERNAME>;<USERKEY>;<APIKEY> for ENV
private String[] apiauthTvdb;
private String apikeyTmdb, apiauthTvdb;
private Path plexdata;

@Override
public void invoke(String[] args) throws Exception {
apikeyTmdb = System.getenv("TMDB_API_KEY");
String tvdbAuth = System.getenv("TVDB_AUTH_STRING");
String tvdbAuthLegacy = System.getenv("TVDB_AUTH_STRING");
String tvdbApiKey = System.getenv("TVDB_API_KEY");
String data = System.getenv("PLEX_DATA_DIR");
String ignore = System.getenv("IGNORE_LIBS");
String capabilitiesEnv = System.getenv("CAPABILITIES");
Expand Down Expand Up @@ -112,19 +110,24 @@ public void invoke(String[] args) throws Exception {
Logger.info("TMDB API key enabled TMDB <=> IMDB matching. Will process TMDB backed Movie and TV Series libraries and TMDB orphans.");
}

if(tvdbAuth == null || tvdbAuth.isBlank()) {
Logger.info("No TVDB API authorization string detected. Will process TVDB backed TV Series libraries.");
capabilities.remove(Capabilities.TVDB);
} else {
String[] info = tvdbAuth.split(";");
if(tvdbAuthLegacy != null && !tvdbAuthLegacy.isBlank()) {
Logger.warn("Don't use legacy environment variable TVDB_AUTH_STRING. Use TVDB_API_KEY instead by only providing the TVDB API key.");
String[] info = tvdbAuthLegacy.split(";");
if(info.length == 3) {
Main.testApiTvdb(info);
apiauthTvdb = info;
Logger.info("TVDB API authorization enabled IMDB rating update for TV Series with the TVDB agent.");
tvdbApiKey = info[2];
} else {
Logger.error("Invalid TVDB API authorization string given. Must contain 3 items seperated by a ';'. Will ignore TV Series with the TVDB agent.");
}
}

if(tvdbApiKey == null || tvdbApiKey.isBlank()) {
Logger.info("No TVDB API authorization string detected. Will process TVDB backed TV Series libraries.");
capabilities.remove(Capabilities.TVDB);
} else {
Main.testApiTvdb(tvdbApiKey);
apiauthTvdb = tvdbApiKey;
Logger.info("TVDB API authorization enabled IMDB rating update for TV Series with the TVDB agent.");
}

if(args.length >= 2) {
RUN_EVERY_N_HOUR = parseCommandInt(args[1], i -> i > 0, "Invalid parameter for: RUN_EVERY_N_HOUR (must be number and > 0)");
Expand Down
9 changes: 4 additions & 5 deletions src/main/java/updatetool/imdb/ImdbPipeline.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,12 @@ public class ImdbPipeline extends Pipeline<ImdbJob> {

public static class ImdbPipelineConfiguration {
private final EnumSet<Capabilities> capabilities;
public final String tmdbApiKey, dbLocation;
public final String[] apiauthTvdb;
public final String tmdbApiKey, tvdbApiKey, dbLocation;
public final Path metadataRoot;

public ImdbPipelineConfiguration(String tmdbApiKey, String[] apiauthTvdb, Path metadataRoot, String dbLocation, EnumSet<Capabilities> capabilities) {
public ImdbPipelineConfiguration(String tmdbApiKey, String tvdbApiKey, Path metadataRoot, String dbLocation, EnumSet<Capabilities> capabilities) {
this.tmdbApiKey = tmdbApiKey;
this.apiauthTvdb = apiauthTvdb;
this.tvdbApiKey = tvdbApiKey;
this.metadataRoot = metadataRoot;
this.dbLocation = dbLocation;
this.capabilities = capabilities;
Expand All @@ -93,7 +92,7 @@ public ImdbPipeline(ImdbLibraryMetadata metadata, ExecutorService service, Map<S
resolveMovies.put("IMDB", new ImdbResolvement());
resolveMovies.put("TMDB", configuration.resolveTmdb() ? new TmdbMovieToImdbResolvement(caches.get("tmdb"), new TmdbApi(configuration.tmdbApiKey)) : resolveDefault);

resolveSeries.put("TVDB", configuration.resolveTvdb() ? new TvdbToImdbResolvement(caches.get("tvdb"), caches.get("tvdb-blacklist"), new TvdbApi(configuration.apiauthTvdb)) : resolveDefault);
resolveSeries.put("TVDB", configuration.resolveTvdb() ? new TvdbToImdbResolvement(caches.get("tvdb"), caches.get("tvdb-blacklist"), new TvdbApi(configuration.tvdbApiKey)) : resolveDefault);
resolveSeries.put("TMDB", configuration.resolveTmdb() ? new TmdbSeriesToImdbResolvement(caches.get("tmdb-series"), caches.get("tmdb-series-blacklist"), new TmdbApi(configuration.tmdbApiKey)) : resolveDefault);
resolveSeries.put("IMDB", new ImdbResolvement());

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.3.6
1.3.7

0 comments on commit 0f91acd

Please sign in to comment.