Skip to content

Commit

Permalink
Adress new requested changes
Browse files Browse the repository at this point in the history
  • Loading branch information
AudricV committed Feb 26, 2022
1 parent 3bec1f0 commit bc33879
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ public DateWrapper getUploadDate() throws ParsingException {
public String getThumbnailUrl() throws ParsingException {
if (albumJson.isNull("art_id")) {
return EMPTY_STRING;
} else {
return getImageUrl(albumJson.getLong("art_id"), true);
}

return getImageUrl(albumJson.getLong("art_id"), true);
}

@Nonnull
Expand Down Expand Up @@ -178,11 +178,9 @@ public StreamType getStreamType() {
public PlaylistInfoItemsCollector getRelatedItems() {
final PlaylistInfoItemsCollector collector =
new PlaylistInfoItemsCollector(getServiceId());
final Elements recommendedAlbums = document.getElementsByClass("recommended-album");

for (final Element album : recommendedAlbums) {
collector.commit(new BandcampRelatedPlaylistInfoItemExtractor(album));
}
document.getElementsByClass("recommended-album").stream()
.map(BandcampRelatedPlaylistInfoItemExtractor::new)
.forEach(collector::commit);

return collector;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,19 @@ public String getUploaderName() throws ParsingException {
@Nonnull
@Override
public String getDashMpdUrl() throws ParsingException {
if (firstDashUrlFound == null) {
for (int s = 0; s < room.getArray("streams").size(); s++) {
final JsonObject stream = room.getArray("streams").getObject(s);
final JsonObject urls = stream.getObject("urls");
if (urls.has("dash")) {
firstDashUrlFound = urls.getObject("dash").getString("url", EMPTY_STRING);
return firstDashUrlFound;
}
if (firstDashUrlFound != null) {
return firstDashUrlFound;
}

for (int s = 0; s < room.getArray("streams").size(); s++) {
final JsonObject stream = room.getArray("streams").getObject(s);
final JsonObject urls = stream.getObject("urls");
if (urls.has("dash")) {
firstDashUrlFound = urls.getObject("dash").getString("url", EMPTY_STRING);
return firstDashUrlFound;
}
firstDashUrlFound = EMPTY_STRING;
}
firstDashUrlFound = EMPTY_STRING;
return firstDashUrlFound;
}

Expand All @@ -129,17 +131,19 @@ public String getDashMpdUrl() throws ParsingException {
@Nonnull
@Override
public String getHlsUrl() {
if (firstHlsUrlFound == null) {
for (int s = 0; s < room.getArray("streams").size(); s++) {
final JsonObject stream = room.getArray("streams").getObject(s);
final JsonObject urls = stream.getObject("urls");
if (urls.has("hls")) {
firstHlsUrlFound = urls.getObject("hls").getString("url", EMPTY_STRING);
return firstHlsUrlFound;
}
if (firstHlsUrlFound != null) {
return firstHlsUrlFound;
}

for (int s = 0; s < room.getArray("streams").size(); s++) {
final JsonObject stream = room.getArray("streams").getObject(s);
final JsonObject urls = stream.getObject("urls");
if (urls.has("hls")) {
firstHlsUrlFound = urls.getObject("hls").getString("url", EMPTY_STRING);
return firstHlsUrlFound;
}
firstHlsUrlFound = EMPTY_STRING;
}
firstHlsUrlFound = EMPTY_STRING;
return firstHlsUrlFound;
}

Expand All @@ -149,7 +153,7 @@ public List<AudioStream> getAudioStreams() throws IOException, ExtractionExcepti
audioStreams = new ArrayList<>();
IntStream.range(0, room.getArray("streams").size())
.mapToObj(s -> room.getArray("streams").getObject(s))
.filter(stream -> stream.getString("type").equals("audio"))
.filter(streamJsonObject -> streamJsonObject.getString("type").equals("audio"))
.forEachOrdered(stream -> {
for (final String type : stream.getObject("urls").keySet()) {
final JsonObject urlObject = stream.getObject("urls").getObject(type);
Expand Down Expand Up @@ -186,11 +190,11 @@ public List<VideoStream> getVideoStreams() throws IOException, ExtractionExcepti
IntStream.range(0, room.getArray("streams").size())
.mapToObj(s -> room.getArray("streams").getObject(s))
.filter(stream -> stream.getString("type").equals("video"))
.forEachOrdered(stream -> {
final String resolution = stream.getArray("videoSize").getInt(0) + "x"
+ stream.getArray("videoSize").getInt(1);
for (final String type : stream.getObject("urls").keySet()) {
final JsonObject urlObject = stream.getObject("urls").getObject(type);
.forEachOrdered(streamJsonObject -> {
final String resolution = streamJsonObject.getArray("videoSize").getInt(0)
+ "x" + streamJsonObject.getArray("videoSize").getInt(1);
for (final String type : streamJsonObject.getObject("urls").keySet()) {
final JsonObject urlObject = streamJsonObject.getObject("urls").getObject(type);
// The DASH manifest will be extracted with getDashMpdUrl
if (!type.equals("dash")) {
if (type.equals("hls")) {
Expand Down

0 comments on commit bc33879

Please sign in to comment.