Merge pull request #607 from TeamNewPipe/bandcamp_radio_segments
[Bandcamp] Add Radio stream segments
This commit is contained in:
commit
82d11386df
|
@ -1,5 +1,6 @@
|
|||
package org.schabi.newpipe.extractor.services.bandcamp.extractors;
|
||||
|
||||
import com.grack.nanojson.JsonArray;
|
||||
import com.grack.nanojson.JsonObject;
|
||||
import com.grack.nanojson.JsonParser;
|
||||
import com.grack.nanojson.JsonParserException;
|
||||
|
@ -15,6 +16,7 @@ import org.schabi.newpipe.extractor.exceptions.ReCaptchaException;
|
|||
import org.schabi.newpipe.extractor.linkhandler.LinkHandler;
|
||||
import org.schabi.newpipe.extractor.stream.AudioStream;
|
||||
import org.schabi.newpipe.extractor.stream.Description;
|
||||
import org.schabi.newpipe.extractor.stream.StreamSegment;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
import javax.annotation.Nullable;
|
||||
|
@ -123,6 +125,23 @@ public class BandcampRadioStreamExtractor extends BandcampStreamExtractor {
|
|||
return list;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public List<StreamSegment> getStreamSegments() throws ParsingException {
|
||||
final JsonArray tracks = showInfo.getArray("tracks");
|
||||
final List<StreamSegment> segments = new ArrayList<>(tracks.size());
|
||||
for (final Object t : tracks) {
|
||||
final JsonObject track = (JsonObject) t;
|
||||
final StreamSegment segment = new StreamSegment(
|
||||
track.getString("title"), track.getInt("timecode"));
|
||||
// "track art" is the track's album cover
|
||||
segment.setPreviewUrl(getImageUrl(track.getLong("track_art_id"), true));
|
||||
segment.setChannelName(track.getString("artist"));
|
||||
segments.add(segment);
|
||||
}
|
||||
return segments;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getLicence() {
|
||||
|
|
|
@ -10,6 +10,11 @@ public class StreamSegment implements Serializable {
|
|||
*/
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* The channel or creator linked to this segment
|
||||
*/
|
||||
private String channelName;
|
||||
|
||||
/**
|
||||
* Timestamp of the starting point in seconds
|
||||
*/
|
||||
|
@ -49,6 +54,15 @@ public class StreamSegment implements Serializable {
|
|||
this.startTimeSeconds = startTimeSeconds;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getChannelName() {
|
||||
return channelName;
|
||||
}
|
||||
|
||||
public void setChannelName(@Nullable final String channelName) {
|
||||
this.channelName = channelName;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getUrl() {
|
||||
return url;
|
||||
|
|
|
@ -54,6 +54,7 @@ public class BandcampRadioStreamExtractorTest extends DefaultStreamExtractorTest
|
|||
@Override public StreamType expectedStreamType() { return StreamType.AUDIO_STREAM; }
|
||||
@Override public StreamingService expectedService() { return Bandcamp; }
|
||||
@Override public String expectedUploaderName() { return "Andrew Jervis"; }
|
||||
@Override public int expectedStreamSegmentsCount() { return 30; }
|
||||
|
||||
@Test(expected = ContentNotSupportedException.class)
|
||||
public void testGetUploaderUrl() throws ParsingException {
|
||||
|
|
Loading…
Reference in New Issue