Skip to content

Commit

Permalink
1.5.1 <=> TMDB Fallback for new movie agent
Browse files Browse the repository at this point in the history
  • Loading branch information
mynttt committed Mar 11, 2021
1 parent b975e01 commit c8c6cdc
Show file tree
Hide file tree
Showing 29 changed files with 793 additions and 656 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.5.1
- TVDB fallback for movies in the new Plex Movie Agent
- Refactoring to support TVDB v4 in a future update

## 1.5.0
- First support for new TV Show Agent (right now only items that have the IMDB ID embedded within the Plex database will be changed -> support for TVDB/TMDB only resolvable items will come soon as for the TVDB resolvable items an update to the new v4 API has to be implemented first).
- This feature is opt-in which means you'll have to add the library IDs to the environment variable `UNLOCK_FOR_NEW_TV_AGENT`. Refer to more information to the main README.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.5.0
1.5.1
5 changes: 4 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ plugins {
id 'com.github.spotbugs' version '2.0.1'
}

version = '1.5.0'
version = '1.5.1'
sourceCompatibility = '11'

new File(projectDir, "VERSION").text = version;
Expand All @@ -18,6 +18,9 @@ repositories {
dependencies {
implementation 'com.google.guava:guava:28.0-jre'

// https://mvnrepository.com/artifact/com.jayway.jsonpath/json-path
implementation group: 'com.jayway.jsonpath', name: 'json-path', version: '2.5.0'

// https://mvnrepository.com/artifact/com.google.code.gson/gson
implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.6'

Expand Down
43 changes: 43 additions & 0 deletions src/main/java/updatetool/Globals.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package updatetool;

import java.util.List;
import updatetool.common.Pair;
import updatetool.imdb.ImdbDatabaseSupport.ImdbMetadataResult;

public final class Globals {

private Globals() {}

/*
* Badges
*/

public static final Pair<String, String>
NEW_TMDB = Pair.of("at:audienceRatingImage", "themoviedb://image.rating"),
NEW_IMDB = Pair.of("at:audienceRatingImage", "imdb://image.rating"),
NEW_TVDB = Pair.of("at:audienceRatingImage", "thetvdb://image.rating"),
ROTTEN_A = Pair.of("at:audienceRatingImage", "rottentomatoes://image.rating.upright"),
ROTTEN_R = Pair.of("at:ratingImage", "rottentomatoes://image.rating.ripe"),
OLD_IMDB = Pair.of("at:ratingImage", "imdb://image.rating");

public static final List<Pair<String, String>> STRIP = List.of(NEW_TMDB, ROTTEN_A, ROTTEN_R, NEW_TVDB);

/*
* Agents
*/

private static final List<String> NEW_AGENTS = List.of(
"plex://movie/",
"plex://season/",
"plex://episode/",
"plex://show/"
);

public static boolean isNewAgent(ImdbMetadataResult meta) {
for(String newagent : NEW_AGENTS) {
if(meta.guid.startsWith(newagent))
return true;
}
return false;
}
}
33 changes: 0 additions & 33 deletions src/main/java/updatetool/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@
import de.mynttt.ezconf.EzConf;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import updatetool.api.Implementation;
import updatetool.common.AbstractApi;
import updatetool.common.TmdbApi;
import updatetool.common.TvdbApi;
import updatetool.common.Utility;
import updatetool.exceptions.ApiCallFailedException;

public class Main {
public static final Path PWD = Paths.get(".");
Expand Down Expand Up @@ -200,35 +196,6 @@ static void rollingLogPurge() throws IOException {
Files.delete(f);
}
}

public static void testApiTmdb(String apikeyTmdb) throws Exception {
Logger.info("Testing TMDB API key: " + apikeyTmdb);
var api = new TmdbApi(apikeyTmdb);
genericApiTest(api);
}

public static void testApiTvdb(String key) {
Logger.info("Testing TVDB API authorization: apikey={}", key);
try {
new TvdbApi(key);
} catch(ApiCallFailedException e) {
Logger.error("API Test failed: " + e.getMessage());
Logger.error("Keys available under: https://thetvdb.com/");
System.exit(-1);
}
Logger.info("Test passed. API Key is valid.");
}

private static void genericApiTest(AbstractApi api) throws Exception {
var response = api.testApi();
if(response.statusCode() != 200) {
Logger.error("API Test failed: Code " + response.statusCode());
Logger.error("Payload:" + response.body());
Logger.error("Key available under:" + api.keysWhere());
System.exit(-1);
}
Logger.info("Test passed. API Key is valid.");
}
}

class Scheduler {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/updatetool/common/Capabilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
public enum Capabilities {
TMDB, TVDB, NO_TV, NO_MOVIE, VERBOSE_XML_ERROR_LOG;

private static List<Capabilities> USER_FLAGS = List.of(NO_MOVIE, NO_TV);
private static final List<Capabilities> USER_FLAGS = List.of(NO_MOVIE, NO_TV);

public static List<Capabilities> getUserFlags() {
return USER_FLAGS;
Expand Down
126 changes: 0 additions & 126 deletions src/main/java/updatetool/common/TmdbApi.java

This file was deleted.

101 changes: 0 additions & 101 deletions src/main/java/updatetool/common/TvdbApi.java

This file was deleted.

Loading

0 comments on commit c8c6cdc

Please sign in to comment.