Skip to content

Commit

Permalink
sonar
Browse files Browse the repository at this point in the history
  • Loading branch information
codingPF committed Feb 18, 2024
1 parent c4c67ad commit d231fb6
Show file tree
Hide file tree
Showing 13 changed files with 41 additions and 87 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public final class OrfOnConstants {
//
public static final String EPISODE = HOST + "/episode";
//
public static final String bearer = "Basic b3JmX29uX3Y0MzpqRlJzYk5QRmlQU3h1d25MYllEZkNMVU41WU5aMjhtdA==";
public static final String AUTH = "Basic b3JmX29uX3Y0MzpqRlJzYk5QRmlQU3h1d25MYllEZkNMVU41WU5aMjhtdA==";
//
private OrfOnConstants() {}
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ private Queue<OrfOnBreadCrumsUrlDTO> createDayUrlsToCrawl() {

private Set<OrfOnVideoInfoDTO> processAZUrlsToCrawl() throws InterruptedException, ExecutionException {
final ForkJoinTask<Set<OrfOnBreadCrumsUrlDTO>> letterTask = forkJoinPool.submit(new OrfOnAZTask(this, createAZUrlsToCrawl()));
final Set<OrfOnBreadCrumsUrlDTO> LetterTaskTopics = letterTask.get();
final ForkJoinTask<Set<OrfOnVideoInfoDTO>> videosFromTopicsTask = forkJoinPool.submit(new OrfOnEpisodesTask(this, new ConcurrentLinkedQueue<>(LetterTaskTopics)));
final Set<OrfOnBreadCrumsUrlDTO> letterTaskTopics = letterTask.get();
final ForkJoinTask<Set<OrfOnVideoInfoDTO>> videosFromTopicsTask = forkJoinPool.submit(new OrfOnEpisodesTask(this, new ConcurrentLinkedQueue<>(letterTaskTopics)));
return videosFromTopicsTask.get();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,11 @@ public int hashCode() {
return super.hashCode();
}


@Override
public boolean equals(final Object obj) {
if (obj == null || getClass() != obj.getClass()) {
return false;
}
return this.hashCode() == obj.hashCode();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
Expand Down Expand Up @@ -121,12 +122,12 @@ private Optional<URL> parseSubtitleSource(Optional<String> text) {

private Optional<Set<URL>> parseSubtitleUrls(JsonElement element) {
Set<URL> urls = new HashSet<>();
JsonUtils.getElementValueAsString(element, TAG_SUBTITLE_SMI).ifPresent( stringUrl -> toURL(stringUrl).ifPresent(url -> urls.add(url)));
JsonUtils.getElementValueAsString(element, TAG_SUBTITLE_SRT).ifPresent( stringUrl -> toURL(stringUrl).ifPresent(url -> urls.add(url)));
JsonUtils.getElementValueAsString(element, TAG_SUBTITLE_TTML).ifPresent( stringUrl -> toURL(stringUrl).ifPresent(url -> urls.add(url)));
JsonUtils.getElementValueAsString(element, TAG_SUBTITLE_VTT).ifPresent( stringUrl -> toURL(stringUrl).ifPresent(url -> urls.add(url)));
JsonUtils.getElementValueAsString(element, TAG_SUBTITLE_XML).ifPresent( stringUrl -> toURL(stringUrl).ifPresent(url -> urls.add(url)));
if (urls.size() == 0) {
JsonUtils.getElementValueAsString(element, TAG_SUBTITLE_SMI).ifPresent( stringUrl -> toURL(stringUrl).ifPresent(urls::add));
JsonUtils.getElementValueAsString(element, TAG_SUBTITLE_SRT).ifPresent( stringUrl -> toURL(stringUrl).ifPresent(urls::add));
JsonUtils.getElementValueAsString(element, TAG_SUBTITLE_TTML).ifPresent( stringUrl -> toURL(stringUrl).ifPresent(urls::add));
JsonUtils.getElementValueAsString(element, TAG_SUBTITLE_VTT).ifPresent( stringUrl -> toURL(stringUrl).ifPresent(urls::add));
JsonUtils.getElementValueAsString(element, TAG_SUBTITLE_XML).ifPresent( stringUrl -> toURL(stringUrl).ifPresent(urls::add));
if (urls.isEmpty()) {
return Optional.empty();
}
return Optional.of(urls);
Expand Down Expand Up @@ -170,7 +171,7 @@ private Optional<Map<Resolution, FilmUrl>> parseUrl(JsonElement jsonElement) {
codec = Optional.of("dash");
}
if (codec.isPresent()) {
urls = Optional.of(new HashMap<Resolution, FilmUrl>());
urls = Optional.of(new EnumMap<>(Resolution.class));
for (JsonElement codecUrls : jsonElement.getAsJsonObject().getAsJsonObject(TAG_VIDEO).getAsJsonArray(codec.get())) {
try {
String qualityString = codecUrls.getAsJsonObject().get(TAG_VIDEO_QUALITY).getAsString();
Expand Down Expand Up @@ -210,11 +211,11 @@ private Optional<URL> parseWebsite(Optional<String> text) {
private Optional<Collection<GeoLocations>> parseGeoLocations(Optional<String> text) {
if (text.isPresent()) {
if (text.get().equalsIgnoreCase("worldwide")) {
ArrayList<GeoLocations> a = new ArrayList<GeoLocations>();
ArrayList<GeoLocations> a = new ArrayList<>();
a.add(GeoLocations.GEO_NONE);
return Optional.of(a);
} else if (text.get().equalsIgnoreCase("austria")) {
ArrayList<GeoLocations> a = new ArrayList<GeoLocations>();
ArrayList<GeoLocations> a = new ArrayList<>();
a.add(GeoLocations.GEO_AT);
return Optional.of(a);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public PagedElementListDTO<OrfOnVideoInfoDTO> deserialize(
throws JsonParseException {
JsonObject jsonPage = jsonElement.getAsJsonObject();
//
PagedElementListDTO<OrfOnVideoInfoDTO> page = new PagedElementListDTO<OrfOnVideoInfoDTO>();
PagedElementListDTO<OrfOnVideoInfoDTO> page = new PagedElementListDTO<>();
page.setNextPage(JsonUtils.getElementValueAsString(jsonElement, TAG_NEXT_PAGE));
//
final Optional<JsonElement> items = JsonUtils.getElement(jsonPage, TAG_ITEMS);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@

public class OrfOnHistoryChildrenDeserializer implements JsonDeserializer<PagedElementListDTO<OrfOnBreadCrumsUrlDTO>> {
private static final Logger LOG = LogManager.getLogger(OrfOnHistoryChildrenDeserializer.class);
private String[] TAG_NEXT_PAGE = { "next" };
private String[] TAG_ITEM_ARRAY = { "_items" };
private String[] TAG_ITEM_TITLE = {"title"};
private String[] TAG_TARGET_URL = {"_links", "video_items", "href"};
private String[] TAG_TARGET_URL2 = {"_links", "children", "href"};
private static final String[] TAG_NEXT_PAGE = { "next" };
private static final String[] TAG_ITEM_ARRAY = { "_items" };
private static final String[] TAG_ITEM_TITLE = {"title"};
private static final String[] TAG_TARGET_URL = {"_links", "video_items", "href"};
private static final String[] TAG_TARGET_URL2 = {"_links", "children", "href"};

@Override
public PagedElementListDTO<OrfOnBreadCrumsUrlDTO> deserialize(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@

public class OrfOnHistoryDeserializer implements JsonDeserializer<PagedElementListDTO<OrfOnBreadCrumsUrlDTO>> {
private static final Logger LOG = LogManager.getLogger(OrfOnHistoryDeserializer.class);
private String[] TAG_NEXT_PAGE = {};
private String[] TAG_ITEM_ARRAY_TOP = {"history_highlights"};
private String[] TAG_ITEM_TITLE = {"title"};
private String[] TAG_ITEM_ARRAY_BUTTOM = {"history_items"};
private String[] TAG_TARGET_URL = {"_links", "children", "href"};
private static final String[] TAG_NEXT_PAGE = {};
private static final String[] TAG_ITEM_ARRAY_TOP = {"history_highlights"};
private static final String[] TAG_ITEM_TITLE = {"title"};
private static final String[] TAG_ITEM_ARRAY_BUTTOM = {"history_items"};
private static final String[] TAG_TARGET_URL = {"_links", "children", "href"};

@Override
public PagedElementListDTO<OrfOnBreadCrumsUrlDTO> deserialize(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
import org.apache.logging.log4j.Logger;

public class OrfOnHistoryVideoItemDeserializer implements JsonDeserializer<PagedElementListDTO<OrfOnBreadCrumsUrlDTO>> {
private String[] TAG_NEXT_PAGE = { "next" };
private String[] TAG_ITEM_ARRAY = { "_items" };
private String[] TAG_ITEM_TITLE = {"title"};
private String[] TAG_TARGET_URL = {"_links", "self", "href"};
private String[] TAG_TARGET_URL_EPISODE = {"_links", "episode", "href"};
private static final String[] TAG_NEXT_PAGE = { "next" };
private static final String[] TAG_ITEM_ARRAY = { "_items" };
private static final String[] TAG_ITEM_TITLE = {"title"};
private static final String[] TAG_TARGET_URL = {"_links", "self", "href"};
private static final String[] TAG_TARGET_URL_EPISODE = {"_links", "episode", "href"};

protected final Logger LOG = LogManager.getLogger(this.getClass());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class OrfOnScheduleDeserializer implements JsonDeserializer<PagedElementL
public PagedElementListDTO<OrfOnBreadCrumsUrlDTO> deserialize(
final JsonElement jsonElement, final Type typeOfT, final JsonDeserializationContext context)
throws JsonParseException {
PagedElementListDTO<OrfOnBreadCrumsUrlDTO> collectIds = new PagedElementListDTO<OrfOnBreadCrumsUrlDTO>();
PagedElementListDTO<OrfOnBreadCrumsUrlDTO> collectIds = new PagedElementListDTO<>();
final JsonArray elements = jsonElement.getAsJsonArray();
for (JsonElement element : elements) {
final Optional<String> name = JsonUtils.getElementValueAsString(element, TAG_FILM_NAME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.lang.reflect.Type;
import java.net.URI;
import java.util.Optional;
import java.util.Queue;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
Expand All @@ -26,7 +25,7 @@ public class OrfOnEpisodeTask extends AbstractJsonRestTask<OrfOnVideoInfoDTO, Or
private static final Logger LOG = LogManager.getLogger(OrfOnEpisodeTask.class);

public OrfOnEpisodeTask(AbstractCrawler crawler, Queue<OrfOnBreadCrumsUrlDTO> urlToCrawlDTOs) {
super(crawler, urlToCrawlDTOs, OrfOnConstants.bearer);
super(crawler, urlToCrawlDTOs, OrfOnConstants.AUTH);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class OrfOnEpisodesTask extends AbstractJsonRestTask<OrfOnVideoInfoDTO, P
private static final Logger LOG = LogManager.getLogger(OrfOnEpisodesTask.class);

public OrfOnEpisodesTask(AbstractCrawler crawler, Queue<OrfOnBreadCrumsUrlDTO> urlToCrawlDTOs) {
super(crawler, urlToCrawlDTOs, OrfOnConstants.bearer);
super(crawler, urlToCrawlDTOs, OrfOnConstants.AUTH);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public abstract class OrfOnPagedTask extends AbstractJsonRestTask<OrfOnBreadCrum
protected final Logger LOG = LogManager.getLogger(this.getClass());
protected Optional<AbstractRecursiveConverterTask<OrfOnBreadCrumsUrlDTO, OrfOnBreadCrumsUrlDTO>> nextPageTask = Optional.empty();

public OrfOnPagedTask(AbstractCrawler crawler, Queue<OrfOnBreadCrumsUrlDTO> urlToCrawlDTOs) {
super(crawler, urlToCrawlDTOs, OrfOnConstants.bearer);
protected OrfOnPagedTask(AbstractCrawler crawler, Queue<OrfOnBreadCrumsUrlDTO> urlToCrawlDTOs) {
super(crawler, urlToCrawlDTOs, OrfOnConstants.AUTH);
}

protected void postProcessingNextPage(PagedElementListDTO<OrfOnBreadCrumsUrlDTO> aResponseObj, OrfOnBreadCrumsUrlDTO aDTO) {
Expand Down

0 comments on commit d231fb6

Please sign in to comment.