Skip to content

Commit

Permalink
fixed: ZDF Crawler läuft mal wieder nicht
Browse files Browse the repository at this point in the history
  • Loading branch information
alex1702 committed Jul 31, 2017
2 parents 0b10bb6 + fe436a7 commit 834d262
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ apply from: "${project.rootDir}/gradle/eclipse.gradle"
sourceCompatibility = 1.8
targetCompatibility = 1.8
group = 'de.mediathekview'
version = '3.1.13'
version = '3.1.14'

def jarName = 'MServer.jar'
def mainClass = 'mServer.Main'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import java.lang.reflect.Type;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
Expand All @@ -14,7 +17,8 @@
* A JSON deserializer to gather the needed information for a {@link ZDFConfigurationDTO}.
*/
public class ZDFConfigurationDTODeserializer implements JsonDeserializer<ZDFConfigurationDTO> {

private static final Logger LOG = LogManager.getLogger(ZDFConfigurationDTODeserializer.class);
private static final String FALLBACK_TOKEN = "d2726b6c8c655e42b68b0db26131b15b22bd1a32";
public static final String JSON_ELEMENT_API_TOKEN = "apiToken";

@Override
Expand All @@ -23,8 +27,18 @@ public ZDFConfigurationDTO deserialize(final JsonElement aJsonElement, final Typ
try {
JsonObject targetObject = aJsonElement.getAsJsonObject();
JsonElement apiTokenElement = targetObject.get(JSON_ELEMENT_API_TOKEN);

String apiToken = apiTokenElement.getAsString();

String apiToken;
if(apiTokenElement == null || apiTokenElement.isJsonNull())
{
LOG.error("Can't load the API Token for ZDF. Using the fallback.");
apiToken = FALLBACK_TOKEN;
}else {
apiToken = apiTokenElement.getAsString();

}



dto = new ZDFConfigurationDTO(apiToken);
} catch (Exception ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,14 @@ protected Collection<VideoDTO> compute()
if(baseObject != null) {
ZDFSearchPageTask task = new ZDFSearchPageTask(baseObject);
subTasks.add(task);
task.fork();
if (MserverDaten.debug)
Log.sysLog("SearchTask " + task.hashCode() + " added.");
}

page++;
} while(!Config.getStop() && baseObject != null && baseObject.has(JSON_ELEMENT_NEXT));
filmList.addAll(invokeAll(subTasks).parallelStream()
filmList.addAll(subTasks.parallelStream()
.map(ForkJoinTask::join)
.flatMap(Collection::stream)
.collect(Collectors.toList())
Expand Down

0 comments on commit 834d262

Please sign in to comment.