Skip to content

Commit

Permalink
fix arte removed api /v1/config
Browse files Browse the repository at this point in the history
  • Loading branch information
alex1702 committed May 7, 2022
2 parents 3e873c2 + 709d48e commit 1a8a93d
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 37 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ sourceCompatibility = 1.8
targetCompatibility = 1.8
group = 'de.mediathekview'
archivesBaseName = "MServer"
version = '3.1.193'
version = '3.1.194'

def jarName = 'MServer.jar'
def mainClass = 'mServer.Main'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public static <T> T executeRequest(final String sender, Logger logger, Gson gson
} else {
if (response.code() != 429) {
logger.error(String.format("ARTE Request '%s' failed: %s", aUrl, response.code()));
Log.sysLog(String.format("ARTE Request '%s' failed: %s", aUrl, response.code()));
FilmeSuchen.listeSenderLaufen.inc(sender, RunSender.Count.FEHLER);
stop = true;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class ArteProgramIdToDatenFilmCallable implements Callable<Set<DatenFilm>

private static final Logger LOG = LogManager.getLogger(ArteProgramIdToDatenFilmCallable.class);

private static final String ARTE_VIDEO_INFORMATION_URL_PATTERN = "https://api.arte.tv/api/player/v1/config/%s/%s?platform=ARTE_NEXT";
private static final String ARTE_VIDEO_INFORMATION_URL_PATTERN = "https://api.arte.tv/api/opa/v3/videoStreams?programId=%s&mediaType=mp4&limit=100&language=%s";
private static final String ARTE_VIDEO_INFORMATION_URL_PATTERN_2 = "https://api.arte.tv/api/opa/v3/programs/%s/%s"; // Für broadcastBeginRounded

private final FastDateFormat broadcastDateFormat = FastDateFormat.getInstance("yyyy-MM-dd'T'HH:mm:ssX");//2016-10-29T16:15:00Z
Expand All @@ -52,7 +52,7 @@ public Set<DatenFilm> call() throws Exception {
.registerTypeAdapter(ArteVideoDetailsDTO.class, new ArteVideoDetailsDeserializer(today))
.create();

String videosUrl = String.format(ARTE_VIDEO_INFORMATION_URL_PATTERN, langCode, programId);
String videosUrl = String.format(ARTE_VIDEO_INFORMATION_URL_PATTERN, programId, langCode);
ArteVideoDTO video = ArteHttpClient.executeRequest(senderName, LOG, gson, videosUrl, ArteVideoDTO.class);

if (video != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,22 @@
package mServer.crawler.sender.arte;

import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.*;
import mServer.crawler.sender.base.Qualities;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.lang.reflect.Type;
import java.time.Duration;
import java.util.Map;
import java.util.Optional;
import java.util.Set;

public class ArteVideoDeserializer
implements JsonDeserializer<ArteVideoDTO> {

private static final Logger LOG = LogManager.getLogger(ArteVideoDeserializer.class);

private static final String JSON_OBJECT_KEY_PLAYER = "videoJsonPlayer";
private static final String JSON_OBJECT_KEY_VSR = "VSR";
private static final String ATTRIBUTE_DURATION = "videoDurationSeconds";
private static final String JSON_OBJECT_KEY_PLAYER = "videoStreams";
private static final String ATTRIBUTE_URL = "url";
private static final String ATTRIBUTE_QUALITY = "quality";
private static final String ATTRIBUTE_VERSION_CODE = "versionCode";
private static final String ATTRIBUTE_VERSION_CODE = "audioCode";

private final String sender;

Expand All @@ -38,29 +30,13 @@ public ArteVideoDTO deserialize(
ArteVideoDTO arteVideoDTO = new ArteVideoDTO();
if (aJsonElement.isJsonObject()
&& aJsonElement.getAsJsonObject().has(JSON_OBJECT_KEY_PLAYER)
&& aJsonElement.getAsJsonObject().get(JSON_OBJECT_KEY_PLAYER).isJsonObject()
&& aJsonElement
.getAsJsonObject()
.get(JSON_OBJECT_KEY_PLAYER)
.getAsJsonObject()
.has(JSON_OBJECT_KEY_VSR)
&& aJsonElement
.getAsJsonObject()
.get(JSON_OBJECT_KEY_PLAYER)
.getAsJsonObject()
.get(JSON_OBJECT_KEY_VSR)
.isJsonObject()) {
JsonObject playerObject =
aJsonElement.getAsJsonObject().get(JSON_OBJECT_KEY_PLAYER).getAsJsonObject();
JsonObject vsrJsonObject = playerObject.get(JSON_OBJECT_KEY_VSR).getAsJsonObject();
&& aJsonElement.getAsJsonObject().get(JSON_OBJECT_KEY_PLAYER).isJsonArray()) {
JsonArray videoStreams =
aJsonElement.getAsJsonObject().get(JSON_OBJECT_KEY_PLAYER).getAsJsonArray();

final long duration = playerObject.has(ATTRIBUTE_DURATION) ? playerObject.get(ATTRIBUTE_DURATION).getAsLong() : 0;
arteVideoDTO.setDuration(Duration.ofSeconds(duration));

final Set<Map.Entry<String, JsonElement>> entries = vsrJsonObject.entrySet();
entries.forEach(
videoStreams.forEach(
entry -> {
final JsonObject value = entry.getValue().getAsJsonObject();
final JsonObject value = entry.getAsJsonObject();

final String code = value.get(ATTRIBUTE_VERSION_CODE).getAsString();
final String quality = value.get(ATTRIBUTE_QUALITY).getAsString();
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/mServer/crawler/sender/arte/MediathekArte.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@ protected synchronized void meldungStart() {

senderLanguages.put(Const.ARTE_DE, "de");
senderLanguages.put(Const.ARTE_FR, "fr");
if (LocalDate.now().getDayOfYear() % 2 == 0) {
/*if (LocalDate.now().getDayOfYear() % 2 == 0) {
senderLanguages.put(ARTE_EN, "en");
senderLanguages.put(ARTE_ES, "es");
} else {
senderLanguages.put(ARTE_IT, "it");
senderLanguages.put(ARTE_PL, "pl");
}
}*/

// starte Sprachen Sender, da es sonst zu doppelten Sendern kommen kann
senderLanguages.keySet().forEach(sender -> mlibFilmeSuchen.melden(sender, getMax(), getProgress(), ""));
Expand Down

0 comments on commit 1a8a93d

Please sign in to comment.