[media.ccc.de] Fix NPE in search results if they contain a future talk
This commit is contained in:
parent
3c8c8e7307
commit
edf8dd0e92
|
@ -28,9 +28,9 @@ public final class MediaCCCParsingHelper {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isLiveStreamId(final String url) {
|
public static boolean isLiveStreamId(final String id) {
|
||||||
final String pattern = "\\w+/\\w+";
|
final String pattern = "\\w+/\\w+";
|
||||||
return Pattern.matches(pattern, url); // {conference_slug}/{room_slug}
|
return Pattern.matches(pattern, id); // {conference_slug}/{room_slug}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static JsonArray getLiveStreams(final Downloader downloader, final Localization localization) throws ExtractionException {
|
public static JsonArray getLiveStreams(final Downloader downloader, final Localization localization) throws ExtractionException {
|
||||||
|
|
|
@ -81,10 +81,15 @@ public class MediaCCCSearchExtractor extends SearchExtractor {
|
||||||
|| getLinkHandler().getContentFilters().isEmpty()) {
|
|| getLinkHandler().getContentFilters().isEmpty()) {
|
||||||
JsonArray events = doc.getArray("events");
|
JsonArray events = doc.getArray("events");
|
||||||
for (int i = 0; i < events.size(); i++) {
|
for (int i = 0; i < events.size(); i++) {
|
||||||
|
// Ensure only uploaded talks are shown in the search results.
|
||||||
|
// If the release date is null, the talk has not been held or uploaded yet
|
||||||
|
// and no streams are going to be available anyway.
|
||||||
|
if (events.getObject(i).getString("release_date") != null) {
|
||||||
searchItems.commit(new MediaCCCStreamInfoItemExtractor(
|
searchItems.commit(new MediaCCCStreamInfoItemExtractor(
|
||||||
events.getObject(i)));
|
events.getObject(i)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return new InfoItemsPage<>(searchItems, null);
|
return new InfoItemsPage<>(searchItems, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,7 +110,7 @@ public class MediaCCCSearchExtractor extends SearchExtractor {
|
||||||
try {
|
try {
|
||||||
doc = JsonParser.object().from(site);
|
doc = JsonParser.object().from(site);
|
||||||
} catch (JsonParserException jpe) {
|
} catch (JsonParserException jpe) {
|
||||||
throw new ExtractionException("Could not parse json.", jpe);
|
throw new ExtractionException("Could not parse JSON.", jpe);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (getLinkHandler().getContentFilters().contains(CONFERENCES)
|
if (getLinkHandler().getContentFilters().contains(CONFERENCES)
|
||||||
|
|
|
@ -56,7 +56,11 @@ public class MediaCCCStreamInfoItemExtractor implements StreamInfoItemExtractor
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public DateWrapper getUploadDate() throws ParsingException {
|
public DateWrapper getUploadDate() throws ParsingException {
|
||||||
return new DateWrapper(MediaCCCParsingHelper.parseDateFrom(getTextualUploadDate()));
|
final String date = getTextualUploadDate();
|
||||||
|
if (date == null) {
|
||||||
|
return null; // event is in the future...
|
||||||
|
}
|
||||||
|
return new DateWrapper(MediaCCCParsingHelper.parseDateFrom(date));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class MediaCCCSearchQueryHandlerFactory extends SearchQueryHandlerFactory
|
||||||
return "https://media.ccc.de/public/events/search?q="
|
return "https://media.ccc.de/public/events/search?q="
|
||||||
+ URLEncoder.encode(query, "UTF-8");
|
+ URLEncoder.encode(query, "UTF-8");
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
throw new ParsingException("Could not create search string with querry: " + query, e);
|
throw new ParsingException("Could not create search string with query: " + query, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue