|
| 1 | +package org.schabi.newpipe.extractor.services.media_ccc.extractors; |
| 2 | + |
| 3 | +import com.grack.nanojson.JsonObject; |
| 4 | +import org.schabi.newpipe.extractor.exceptions.ParsingException; |
| 5 | +import org.schabi.newpipe.extractor.localization.DateWrapper; |
| 6 | +import org.schabi.newpipe.extractor.stream.StreamInfoItemExtractor; |
| 7 | +import org.schabi.newpipe.extractor.stream.StreamType; |
| 8 | + |
| 9 | +import javax.annotation.Nullable; |
| 10 | + |
| 11 | +public class MediaCCCLiveStreamExtractor implements StreamInfoItemExtractor { |
| 12 | + |
| 13 | + private final JsonObject conferenceInfo; |
| 14 | + private final String group; |
| 15 | + private final JsonObject roomInfo; |
| 16 | + |
| 17 | + public MediaCCCLiveStreamExtractor(JsonObject conferenceInfo, String group, JsonObject roomInfo) { |
| 18 | + this.conferenceInfo = conferenceInfo; |
| 19 | + this.group = group; |
| 20 | + this.roomInfo = roomInfo; |
| 21 | + } |
| 22 | + |
| 23 | + @Override |
| 24 | + public String getName() throws ParsingException { |
| 25 | + return roomInfo.getString("schedulename"); |
| 26 | + } |
| 27 | + |
| 28 | + @Override |
| 29 | + public String getUrl() throws ParsingException { |
| 30 | + return roomInfo.getString("link"); |
| 31 | + } |
| 32 | + |
| 33 | + @Override |
| 34 | + public String getThumbnailUrl() throws ParsingException { |
| 35 | + return roomInfo.getString("thumb"); |
| 36 | + } |
| 37 | + |
| 38 | + @Override |
| 39 | + public StreamType getStreamType() throws ParsingException { |
| 40 | + boolean isVideo = false; |
| 41 | + for (Object stream : roomInfo.getArray("streams")) { |
| 42 | + if ("video".equals(((JsonObject) stream).getString("type"))) { |
| 43 | + isVideo = true; |
| 44 | + break; |
| 45 | + } |
| 46 | + } |
| 47 | + return isVideo ? StreamType.LIVE_STREAM : StreamType.AUDIO_LIVE_STREAM; |
| 48 | + } |
| 49 | + |
| 50 | + @Override |
| 51 | + public boolean isAd() throws ParsingException { |
| 52 | + return false; |
| 53 | + } |
| 54 | + |
| 55 | + @Override |
| 56 | + public long getDuration() throws ParsingException { |
| 57 | + return 0; |
| 58 | + } |
| 59 | + |
| 60 | + @Override |
| 61 | + public long getViewCount() throws ParsingException { |
| 62 | + return -1; |
| 63 | + } |
| 64 | + |
| 65 | + @Override |
| 66 | + public String getUploaderName() throws ParsingException { |
| 67 | + return conferenceInfo.getString("conference"); |
| 68 | + } |
| 69 | + |
| 70 | + @Override |
| 71 | + public String getUploaderUrl() throws ParsingException { |
| 72 | + return "https://media.ccc.de/c/" + conferenceInfo.getString("slug"); |
| 73 | + } |
| 74 | + |
| 75 | + @Nullable |
| 76 | + @Override |
| 77 | + public String getTextualUploadDate() throws ParsingException { |
| 78 | + return null; |
| 79 | + } |
| 80 | + |
| 81 | + @Nullable |
| 82 | + @Override |
| 83 | + public DateWrapper getUploadDate() throws ParsingException { |
| 84 | + return null; |
| 85 | + } |
| 86 | +} |
0 commit comments