use getters/setters.

This commit is contained in:
FireMasterK 2021-02-11 21:42:24 +05:30
parent d4945ac55c
commit f31b2a68fd
4 changed files with 95 additions and 34 deletions

View file

@ -8,7 +8,7 @@ import static org.schabi.newpipe.extractor.services.youtube.ItagItem.ItagType.*;
public class ItagItem { 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 = { private static final ItagItem[] ITAG_LIST = {
///////////////////////////////////////////////////// /////////////////////////////////////////////////////
@ -156,13 +156,76 @@ public class ItagItem {
public int fps = -1; public int fps = -1;
// Fields for Dash // Fields for Dash
public int bitrate; private int bitrate;
public int width; private int width;
public int height; private int height;
public int initStart; private int initStart;
public int initEnd; private int initEnd;
public int indexStart; private int indexStart;
public int indexEnd; private int indexEnd;
public String codec; 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;
}
} }

View file

@ -954,15 +954,15 @@ public class YoutubeStreamExtractor extends StreamExtractor {
String mimeType = formatData.getString("mimeType", EMPTY_STRING); String mimeType = formatData.getString("mimeType", EMPTY_STRING);
String codec = mimeType.contains("codecs") ? mimeType.split("\"")[1] : EMPTY_STRING; String codec = mimeType.contains("codecs") ? mimeType.split("\"")[1] : EMPTY_STRING;
itagItem.bitrate = formatData.getInt("bitrate"); itagItem.setBitrate(formatData.getInt("bitrate"));
itagItem.width = formatData.getInt("width"); itagItem.setWidth(formatData.getInt("width"));
itagItem.height = formatData.getInt("height"); itagItem.setHeight(formatData.getInt("height"));
itagItem.initStart = Integer.parseInt(initRange.getString("start", "-1")); itagItem.setInitStart(Integer.parseInt(initRange.getString("start", "-1")));
itagItem.initEnd = Integer.parseInt(initRange.getString("end", "-1")); itagItem.setInitEnd(Integer.parseInt(initRange.getString("end", "-1")));
itagItem.indexStart = Integer.parseInt(indexRange.getString("start", "-1")); itagItem.setIndexStart(Integer.parseInt(indexRange.getString("start", "-1")));
itagItem.indexEnd = Integer.parseInt(indexRange.getString("end", "-1")); itagItem.setIndexEnd(Integer.parseInt(indexRange.getString("end", "-1")));
itagItem.fps = formatData.getInt("fps"); itagItem.fps = formatData.getInt("fps");
itagItem.codec = codec; itagItem.setCodec(codec);
urlAndItags.put(streamUrl, itagItem); urlAndItags.put(streamUrl, itagItem);
} }

View file

@ -52,12 +52,12 @@ public class AudioStream extends Stream {
*/ */
public AudioStream(String url, ItagItem itag) { public AudioStream(String url, ItagItem itag) {
this(url, itag.getMediaFormat(), itag.avgBitrate); this(url, itag.getMediaFormat(), itag.avgBitrate);
this.bitrate = itag.bitrate; this.bitrate = itag.getBitrate();
this.initStart = itag.initStart; this.initStart = itag.getInitStart();
this.initEnd = itag.initEnd; this.initEnd = itag.getInitEnd();
this.indexStart = itag.indexStart; this.indexStart = itag.getIndexStart();
this.indexEnd = itag.indexEnd; this.indexEnd = itag.getIndexEnd();
this.codec = itag.codec; this.codec = itag.getCodec();
} }
@Override @Override

View file

@ -42,21 +42,19 @@ public class VideoStream extends Stream {
} }
public VideoStream(String url, MediaFormat format, String resolution, boolean isVideoOnly) { public VideoStream(String url, MediaFormat format, String resolution, boolean isVideoOnly) {
super(url, format); this(url, null, format, resolution, isVideoOnly);
this.resolution = resolution;
this.isVideoOnly = isVideoOnly;
} }
public VideoStream(String url, boolean isVideoOnly, ItagItem itag) { public VideoStream(String url, boolean isVideoOnly, ItagItem itag) {
this(url, itag.getMediaFormat(), itag.resolutionString, isVideoOnly); this(url, itag.getMediaFormat(), itag.resolutionString, isVideoOnly);
this.bitrate = itag.bitrate; this.bitrate = itag.getBitrate();
this.initStart = itag.initStart; this.initStart = itag.getInitStart();
this.initEnd = itag.initEnd; this.initEnd = itag.getInitEnd();
this.indexStart = itag.indexStart; this.indexStart = itag.getIndexStart();
this.indexEnd = itag.indexEnd; this.indexEnd = itag.getIndexEnd();
this.codec = itag.codec; this.codec = itag.getCodec();
this.height = itag.height; this.height = itag.getHeight();
this.width = itag.width; this.width = itag.getWidth();
} }
public VideoStream(String url, String torrentUrl, MediaFormat format, String resolution) { public VideoStream(String url, String torrentUrl, MediaFormat format, String resolution) {