diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/ItagItem.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/ItagItem.java index 749429e4..3b736c11 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/ItagItem.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/ItagItem.java @@ -8,7 +8,7 @@ import static org.schabi.newpipe.extractor.services.youtube.ItagItem.ItagType.*; public class ItagItem { /** - * List can be found here https://github.com/rg3/youtube-dl/blob/master/youtube_dl/extractor/youtube.py#L360 + * List can be found here https://github.com/ytdl-org/youtube-dl/blob/master/youtube_dl/extractor/youtube.py#L1046 */ private static final ItagItem[] ITAG_LIST = { ///////////////////////////////////////////////////// @@ -156,13 +156,76 @@ public class ItagItem { public int fps = -1; // Fields for Dash - public int bitrate; - public int width; - public int height; - public int initStart; - public int initEnd; - public int indexStart; - public int indexEnd; - public String codec; + private int bitrate; + private int width; + private int height; + private int initStart; + private int initEnd; + private int indexStart; + private int indexEnd; + private String codec; + public int getBitrate() { + return bitrate; + } + + public void setBitrate(int bitrate) { + this.bitrate = bitrate; + } + + public int getWidth() { + return width; + } + + public void setWidth(int width) { + this.width = width; + } + + public int getHeight() { + return height; + } + + public void setHeight(int height) { + this.height = height; + } + + public int getInitStart() { + return initStart; + } + + public void setInitStart(int initStart) { + this.initStart = initStart; + } + + public int getInitEnd() { + return initEnd; + } + + public void setInitEnd(int initEnd) { + this.initEnd = initEnd; + } + + public int getIndexStart() { + return indexStart; + } + + public void setIndexStart(int indexStart) { + this.indexStart = indexStart; + } + + public int getIndexEnd() { + return indexEnd; + } + + public void setIndexEnd(int indexEnd) { + this.indexEnd = indexEnd; + } + + public String getCodec() { + return codec; + } + + public void setCodec(String codec) { + this.codec = codec; + } } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java index e7ea4cee..b19d1641 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java @@ -954,15 +954,15 @@ public class YoutubeStreamExtractor extends StreamExtractor { String mimeType = formatData.getString("mimeType", EMPTY_STRING); String codec = mimeType.contains("codecs") ? mimeType.split("\"")[1] : EMPTY_STRING; - itagItem.bitrate = formatData.getInt("bitrate"); - itagItem.width = formatData.getInt("width"); - itagItem.height = formatData.getInt("height"); - itagItem.initStart = Integer.parseInt(initRange.getString("start", "-1")); - itagItem.initEnd = Integer.parseInt(initRange.getString("end", "-1")); - itagItem.indexStart = Integer.parseInt(indexRange.getString("start", "-1")); - itagItem.indexEnd = Integer.parseInt(indexRange.getString("end", "-1")); + itagItem.setBitrate(formatData.getInt("bitrate")); + itagItem.setWidth(formatData.getInt("width")); + itagItem.setHeight(formatData.getInt("height")); + itagItem.setInitStart(Integer.parseInt(initRange.getString("start", "-1"))); + itagItem.setInitEnd(Integer.parseInt(initRange.getString("end", "-1"))); + itagItem.setIndexStart(Integer.parseInt(indexRange.getString("start", "-1"))); + itagItem.setIndexEnd(Integer.parseInt(indexRange.getString("end", "-1"))); itagItem.fps = formatData.getInt("fps"); - itagItem.codec = codec; + itagItem.setCodec(codec); urlAndItags.put(streamUrl, itagItem); } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/AudioStream.java b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/AudioStream.java index 1b335420..b079f618 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/AudioStream.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/AudioStream.java @@ -52,12 +52,12 @@ public class AudioStream extends Stream { */ public AudioStream(String url, ItagItem itag) { this(url, itag.getMediaFormat(), itag.avgBitrate); - this.bitrate = itag.bitrate; - this.initStart = itag.initStart; - this.initEnd = itag.initEnd; - this.indexStart = itag.indexStart; - this.indexEnd = itag.indexEnd; - this.codec = itag.codec; + this.bitrate = itag.getBitrate(); + this.initStart = itag.getInitStart(); + this.initEnd = itag.getInitEnd(); + this.indexStart = itag.getIndexStart(); + this.indexEnd = itag.getIndexEnd(); + this.codec = itag.getCodec(); } @Override diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/VideoStream.java b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/VideoStream.java index 7198f4fa..cce5dcfe 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/VideoStream.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/VideoStream.java @@ -42,21 +42,19 @@ public class VideoStream extends Stream { } public VideoStream(String url, MediaFormat format, String resolution, boolean isVideoOnly) { - super(url, format); - this.resolution = resolution; - this.isVideoOnly = isVideoOnly; + this(url, null, format, resolution, isVideoOnly); } public VideoStream(String url, boolean isVideoOnly, ItagItem itag) { this(url, itag.getMediaFormat(), itag.resolutionString, isVideoOnly); - this.bitrate = itag.bitrate; - this.initStart = itag.initStart; - this.initEnd = itag.initEnd; - this.indexStart = itag.indexStart; - this.indexEnd = itag.indexEnd; - this.codec = itag.codec; - this.height = itag.height; - this.width = itag.width; + this.bitrate = itag.getBitrate(); + this.initStart = itag.getInitStart(); + this.initEnd = itag.getInitEnd(); + this.indexStart = itag.getIndexStart(); + this.indexEnd = itag.getIndexEnd(); + this.codec = itag.getCodec(); + this.height = itag.getHeight(); + this.width = itag.getWidth(); } public VideoStream(String url, String torrentUrl, MediaFormat format, String resolution) {