Skip to content

Commit

Permalink
parameterize sender in topic url
Browse files Browse the repository at this point in the history
  • Loading branch information
pidoubleyou committed Feb 7, 2024
1 parent 5921d9e commit 041e336
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class ArdConstants {
public static final String ITEM_URL = API_URL + "/page-gateway/pages/ard/item/";

public static final String TOPICS_URL = API_URL + "/page-gateway/pages/%s/editorial/experiment-a-z?embedded=false";
public static final String TOPICS_COMPILATION_URL = API_URL + "/page-gateway/widgets/radiobremen/editorials/%s?pageNumber=0&pageSize=%s";
public static final String TOPICS_COMPILATION_URL = API_URL + "/page-gateway/widgets/%s/editorials/%s?pageNumber=0&pageSize=%s";
public static final String TOPIC_URL = API_URL + "/page-gateway/widgets/ard/asset/%s?pageSize=%d";
public static final String DAY_PAGE_URL = API_URL + "/page-gateway/compilations/%s/pastbroadcasts?startDateTime=%sT00:00:00.000Z&endDateTime=%sT23:59:59.000Z&pageNumber=0&pageSize=%d";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ public class ArdTopicsDeserializer implements JsonDeserializer<Set<CrawlerUrlDTO
private static final String ELEMENT_SELF = "self";

private static final String ATTRIBUTE_ID = "id";
private final String sender;

public ArdTopicsDeserializer(String sender) {
this.sender = sender;
}

@Override
public Set<CrawlerUrlDTO> deserialize(
Expand All @@ -41,6 +46,7 @@ private Optional<CrawlerUrlDTO> parseWidget(final JsonElement compilation) {
new CrawlerUrlDTO(
String.format(
ArdConstants.TOPICS_COMPILATION_URL,
sender,
id.get(),
ArdConstants.TOPICS_COMPILATION_PAGE_SIZE)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class ArdTopicsTask extends ArdTaskBase<CrawlerUrlDTO, CrawlerUrlDTO> {
public ArdTopicsTask(AbstractCrawler aCrawler, String sender, Queue<CrawlerUrlDTO> urlToCrawlDTOs) {
super(aCrawler, urlToCrawlDTOs);
this.sender = sender;
registerJsonDeserializer(SET_CRAWLER_URL_TYPE_TOKEN, new ArdTopicsDeserializer());
registerJsonDeserializer(SET_CRAWLER_URL_TYPE_TOKEN, new ArdTopicsDeserializer(sender));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void testDeserialize() {
"https://api.ardmediathek.de/page-gateway/widgets/radiobremen/editorials/UmFkaW9CcmVtZW4uIw?pageNumber=0&pageSize=200")
};

final ArdTopicsDeserializer target = new ArdTopicsDeserializer();
final ArdTopicsDeserializer target = new ArdTopicsDeserializer("radiobremen");
final Set<CrawlerUrlDTO> actual = target.deserialize(jsonElement, null, null);

assertEquals(expected.length, actual.size());
Expand Down

0 comments on commit 041e336

Please sign in to comment.