Skip to content

Commit

Permalink
1.7.1 - reinistated TVDB v3 API
Browse files Browse the repository at this point in the history
  • Loading branch information
mynttt committed Feb 16, 2023
1 parent 9adaa3d commit 5280e3c
Show file tree
Hide file tree
Showing 10 changed files with 7 additions and 153 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,6 @@ Flag | Description
:-------------------------:|:-------------------------:|
`NO_TV` |Ignore all TV Show libraries
`NO_MOVIE` | Ignore all Movie libraries
`VERBOSE_XML_ERROR_LOG` | Enable verbose XML error output logging
`DONT_THROW_ON_ENCODING_ERROR` | Supress forced quits if decoding errors of extra data are encountered due to corrupt items in the library
`IGNORE_NO_MATCHING_RESOLVER_LOG`|Supresses printing items that have no matching resolver to the log
`IGNORE_SCRAPER_NO_RESULT_LOG`|Supresses printing web scraper no-match results that either have no rating on the IMDB website or are not allowed to be rated by anyone on the IMDB website and thus will never have ratings
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.7.0
1.7.1
2 changes: 1 addition & 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.7.0'
version = '1.7.1'
sourceCompatibility = '11'

new File(projectDir, "VERSION").text = version;
Expand Down
6 changes: 1 addition & 5 deletions src/main/java/updatetool/api/Pipeline.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
public abstract class Pipeline<T extends Job> {

public enum PipelineStage {
CREATED, ANALYSED_DB, ACCUMULATED_META, TRANSFORMED_META, DB_UPDATED, COMPLETED
CREATED, ANALYSED_DB, ACCUMULATED_META, TRANSFORMED_META, COMPLETED
}

public final void invoke(T job) throws Exception {
Expand All @@ -19,9 +19,6 @@ public final void invoke(T job) throws Exception {
case CREATED:
analyseDatabase(job);
break;
case DB_UPDATED:
updateXML(job);
break;
case TRANSFORMED_META:
updateDatabase(job);
break;
Expand All @@ -34,5 +31,4 @@ public final void invoke(T job) throws Exception {
public abstract void accumulateMetadata(T job) throws Exception;
public abstract void transformMetadata(T job) throws Exception;
public abstract void updateDatabase(T job) throws Exception;
public abstract void updateXML(T job) throws Exception;
}
3 changes: 1 addition & 2 deletions src/main/java/updatetool/common/Capabilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,13 @@ public enum Capabilities {
TVDB,
NO_TV,
NO_MOVIE,
VERBOSE_XML_ERROR_LOG,
DONT_THROW_ON_ENCODING_ERROR,
IGNORE_SCRAPER_NO_RESULT_LOG,
IGNORE_NO_MATCHING_RESOLVER_LOG,
DISABLE_SCREEN_SCRAPE,
PRINT_SQLITE_BINARY_EXECUTE_STATEMENTS;

private static final List<Capabilities> USER_FLAGS = List.of(NO_MOVIE, NO_TV, DONT_THROW_ON_ENCODING_ERROR, VERBOSE_XML_ERROR_LOG, IGNORE_NO_MATCHING_RESOLVER_LOG, IGNORE_SCRAPER_NO_RESULT_LOG, DISABLE_SCREEN_SCRAPE, PRINT_SQLITE_BINARY_EXECUTE_STATEMENTS);
private static final List<Capabilities> USER_FLAGS = List.of(NO_MOVIE, NO_TV, DONT_THROW_ON_ENCODING_ERROR, IGNORE_NO_MATCHING_RESOLVER_LOG, IGNORE_SCRAPER_NO_RESULT_LOG, DISABLE_SCREEN_SCRAPE, PRINT_SQLITE_BINARY_EXECUTE_STATEMENTS);

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

This file was deleted.

49 changes: 2 additions & 47 deletions src/main/java/updatetool/imdb/ImdbPipeline.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.EnumMap;
import java.util.EnumSet;
import java.util.HashMap;
Expand All @@ -12,26 +11,21 @@
import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentLinkedDeque;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Predicate;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import javax.xml.parsers.DocumentBuilderFactory;
import org.sqlite.SQLiteException;
import org.tinylog.Logger;
import com.google.common.collect.Lists;
import updatetool.api.AgentResolvementStrategy;
import updatetool.api.ExportedRating;
import updatetool.api.Pipeline;
import updatetool.common.Capabilities;
import updatetool.common.DatabaseSupport.LibraryType;
import updatetool.common.ErrorReports;
import updatetool.common.KeyValueStore;
import updatetool.common.SqliteDatabaseProvider;
import updatetool.common.Utility;
Expand All @@ -57,7 +51,6 @@ public class ImdbPipeline extends Pipeline<ImdbJob> {
+ "|(?<TVDB>agents.thetvdb:\\/\\/)"
);

private static final int LIST_PARTITIONS = 16;
private static final int RETRY_N_SECONDS_IF_DB_LOCKED = 20;
private static final int ABORT_DB_LOCK_WAITING_AFTER_N_RETRIES = 500;

Expand Down Expand Up @@ -217,7 +210,7 @@ public void transformMetadata(ImdbJob job) throws Exception {
public void updateDatabase(ImdbJob job) throws Exception {
if(job.items.isEmpty()) {
Logger.info("Nothing to update. Skipping...");
job.stage = PipelineStage.DB_UPDATED;
job.stage = PipelineStage.COMPLETED;
return;
}
Logger.info("Updating " + job.items.size() + " via batch request...");
Expand All @@ -238,48 +231,10 @@ public void updateDatabase(ImdbJob job) throws Exception {
}
}
Logger.info("Batch request finished successfully. Database is now up to date!");
job.stage = PipelineStage.DB_UPDATED;
job.stage = PipelineStage.COMPLETED;
} catch(Exception e) {
throw Utility.rethrow(e);
}
}

@Override
public void updateXML(ImdbJob job) throws Exception {
Logger.info("Updating XML fallback files for " + job.items.size() + " item(s).");
int n = job.items.size()/LIST_PARTITIONS;
var sublists = Lists.partition(job.items, n == 0 ? 1 : n);
var factory = DocumentBuilderFactory.newInstance();
AtomicInteger counter = new AtomicInteger();
HashMap<Future<Void>, ImdbXmlWorker> map = new HashMap<>();
var nofile = Collections.synchronizedCollection(new ArrayList<String>());
for(var sub : sublists) {
var worker = new ImdbXmlWorker(sub, factory.newDocumentBuilder(), counter, job.items.size(), nofile, configuration.metadataRoot);
map.put(service.submit(worker), worker);
}
Throwable t = null;
List<List<ImdbMetadataResult>> cleanup = new ArrayList<>();
for(var entry : map.entrySet()) {
try {
entry.getKey().get();
} catch(ExecutionException e) {
t = e.getCause();
}
cleanup.add(entry.getValue().completed);
}
for(var c : cleanup)
job.items.removeAll(c);
if(nofile.size() > 0 && configuration.capabilities.contains(Capabilities.VERBOSE_XML_ERROR_LOG)) {
String errorFile = "xml-error-" + job.uuid + "-" + job.library + ".log";
Logger.warn(nofile.size() + " XML file(s) have failed to be updated due to them not being present on the file system.");
Logger.warn("This is not an issue as they're not important for Plex as it reads the ratings from the database.");
Logger.warn("The files have been dumped as " + errorFile + " in the PWD.");
ErrorReports.fileReport(nofile, errorFile);
}
if(t != null)
throw Utility.rethrow(t);
Logger.info("Completed updating of XML fallback files.");
job.stage = PipelineStage.COMPLETED;
}

}
79 changes: 0 additions & 79 deletions src/main/java/updatetool/imdb/ImdbXmlWorker.java

This file was deleted.

2 changes: 1 addition & 1 deletion src/main/resources/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.7.0
1.7.1
1 change: 0 additions & 1 deletion src/main/resources/desc/imdb-docker.ez
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ meta {
| Currently available:
| - NO_TV => Ignore all TV Show libraries
| - NO_MOVIE => Ignore all Movie libraries
| - VERBOSE_XML_ERROR_LOG => Enable verbose XML error output logging
| - DONT_THROW_ON_ENCODING_ERROR => Supress forced quits if decoding errors of extra data are encountered due to corrupt items in the library
| - IGNORE_NO_MATCHING_RESOLVER_LOG => Supresses printing items that have no matching resolver to the log
| - IGNORE_SCRAPER_NO_RESULT_LOG => Supresses printing web scraper no-match results that either have no rating on the IMDB website or are not allowed to be rated by anyone on the IMDB website and thus will never have ratings
Expand Down

0 comments on commit 5280e3c

Please sign in to comment.