
mServer.crawler.sender.dw.DwVideoDeserializer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of MServer Show documentation
Show all versions of MServer Show documentation
The crawler for mediathekview/MediathekView
package mServer.crawler.sender.dw;
import com.google.gson.JsonArray;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import java.lang.reflect.Type;
import mServer.crawler.sender.newsearch.Qualities;
public class DwVideoDeserializer implements JsonDeserializer {
private static final String JSON_ELEMENT_FILE = "file";
@Override
public DwVideoDTO deserialize(JsonElement aJsonElement, Type aType, JsonDeserializationContext aContext) throws JsonParseException {
DwVideoDTO dto = new DwVideoDTO();
if (aJsonElement.isJsonArray()) {
JsonArray jsonArray = aJsonElement.getAsJsonArray();
jsonArray.forEach(itemElement -> {
JsonObject item = itemElement.getAsJsonObject();
String file = item.get(JSON_ELEMENT_FILE).getAsString();
Qualities quality = getQuality(file);
if (quality != null) {
dto.addVideo(quality, file);
}
});
}
return dto;
}
private static Qualities getQuality(String file) {
if (file.endsWith("sor.mp4")) {
return Qualities.NORMAL;
}
if (file.endsWith("avc.mp4")) {
return Qualities.HD;
}
return null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy