@@ -51,7 +51,7 @@ public class ArdFilmDeserializer implements JsonDeserializer<List<ArdFilmDto>> {
5151 private static final String ELEMENT_SHOW = "show" ;
5252 private static final String ELEMENT_TEASERS = "teasers" ;
5353 private static final String ELEMENT_WIDGETS = "widgets" ;
54- private static final String [] ELEMENT_SUBTITLES = {"mediaCollection" , "embedded" ,"subtitles" };
54+ private static final String [] ELEMENT_SUBTITLES = {ELEMENT_MEDIA_COLLECTION , ELEMENT_EMBEDDED ,"subtitles" };
5555 private static final String ELEMENT_SOURCES = "sources" ;
5656 private static final String ELEMENT_STREAMS = "streams" ;
5757 private static final String ELEMENT_MEDIA = "media" ;
@@ -71,6 +71,7 @@ public class ArdFilmDeserializer implements JsonDeserializer<List<ArdFilmDto>> {
7171 private static final String ATTRIBUTE_MIME = "mimeType" ;
7272 private static final String ATTRIBUTE_KIND = "kind" ;
7373 private static final String ATTRIBUTE_ADUIO_LANG = "languageCode" ;
74+ private static final String ATTRIBUTE_GEO_BLOCKED = "isGeoBlocked" ;
7475
7576 private static final String MARKER_VIDEO_MP4 = "video/mp4" ;
7677 private static final String MARKER_VIDEO_STANDARD = "standard" ;
@@ -229,6 +230,7 @@ public List<ArdFilmDto> deserialize(
229230 final Optional <LocalDateTime > date = parseDate (itemObject );
230231 final Optional <Duration > duration = parseDuration (itemObject );
231232 final Optional <String > partner = parsePartner (itemObject );
233+ final Optional <Boolean > geoBlocked = parseGeoBlocked (itemObject );
232234 Optional <Map <Qualities , String >> videoInfoStandard = parseVideoUrls (itemObject , MARKER_VIDEO_CATEGORY_MAIN , MARKER_VIDEO_STANDARD , MARKER_VIDEO_MP4 , MARKER_VIDEO_DE );
233235 Optional <Map <Qualities , String >> videoInfoAdaptive = parseVideoUrls (itemObject , MARKER_VIDEO_CATEGORY_MAIN , MARKER_VIDEO_STANDARD , MARKER_VIDEO_CATEGORY_MPEG , MARKER_VIDEO_DE );
234236 Optional <Map <Qualities , String >> videoInfoAD = parseVideoUrls (itemObject , MARKER_VIDEO_CATEGORY_MAIN , MARKER_VIDEO_AD , MARKER_VIDEO_MP4 , MARKER_VIDEO_DE );
@@ -276,7 +278,8 @@ public List<ArdFilmDto> deserialize(
276278 date ,
277279 duration ,
278280 videoInfoStandard .get (),
279- subtitles ));
281+ subtitles ,
282+ geoBlocked .orElse (false )));
280283 films .add (filmDto );
281284 if (widgets .size () > 1 ) {
282285 parseRelatedFilms (filmDto , widgets .get (1 ).getAsJsonObject ());
@@ -295,7 +298,8 @@ public List<ArdFilmDto> deserialize(
295298 date ,
296299 duration ,
297300 vid ,
298- subtitles ));
301+ subtitles ,
302+ geoBlocked .orElse (false )));
299303 films .add (filmDto );
300304 }
301305 //
@@ -311,7 +315,8 @@ public List<ArdFilmDto> deserialize(
311315 date ,
312316 duration ,
313317 videoInfoAD .get (),
314- subtitles ));
318+ subtitles ,
319+ geoBlocked .orElse (false )));
315320 films .add (filmDto );
316321 }
317322 //
@@ -327,13 +332,27 @@ public List<ArdFilmDto> deserialize(
327332 date ,
328333 duration ,
329334 videoInfoDGS .get (),
330- subtitles ));
335+ subtitles ,
336+ geoBlocked .orElse (false )));
331337 films .add (filmDto );
332338 }
333339
334340 return films ;
335341 }
336342
343+ private Optional <Boolean > parseGeoBlocked (final JsonObject playerPageObject ) {
344+ final Optional <JsonObject > mediaCollectionObject = getMediaCollectionObject (playerPageObject );
345+ if (mediaCollectionObject .isEmpty ()) {
346+ return Optional .empty ();
347+ }
348+ final Optional <JsonElement > geoBlockedElement =
349+ JsonUtils .getElement (mediaCollectionObject .get (), ATTRIBUTE_GEO_BLOCKED );
350+ if (geoBlockedElement .isPresent () && geoBlockedElement .get ().isJsonPrimitive ()) {
351+ return Optional .of (geoBlockedElement .get ().getAsBoolean ());
352+ }
353+ return Optional .empty ();
354+ }
355+
337356 private Optional <String > parsePartner (JsonObject playerPageObject ) {
338357 if (playerPageObject .has (ELEMENT_PUBLICATION_SERVICE )) {
339358 JsonObject publicationServiceObject
@@ -379,7 +398,8 @@ private DatenFilm createFilm(
379398 final Optional <LocalDateTime > date ,
380399 final Optional <Duration > duration ,
381400 final Map <Qualities , String > videoUrls ,
382- final Optional <String > sub ) {
401+ final Optional <String > sub ,
402+ final boolean geoBlocking ) {
383403
384404 LocalDateTime time = date .orElse (LocalDateTime .now ());
385405
@@ -397,6 +417,9 @@ private DatenFilm createFilm(
397417 if (sub .isPresent ()) {
398418 CrawlerTool .addUrlSubtitle (film , sub .get ());
399419 }
420+ if (geoBlocking ) {
421+ film .arr [DatenFilm .FILM_GEO ] = DatenFilm .GEO_DE ;
422+ }
400423
401424 return film ;
402425 }
0 commit comments