Fix requested changes.

This commit is contained in:
FireMasterK 2021-02-11 20:47:58 +05:30
parent 0c0f2d74bc
commit a7c9905183
3 changed files with 40 additions and 46 deletions

View File

@ -502,7 +502,7 @@ public class YoutubeStreamExtractor extends StreamExtractor {
for (Map.Entry<String, ItagItem> entry : getItags(ADAPTIVE_FORMATS, ItagItem.ItagType.AUDIO).entrySet()) { for (Map.Entry<String, ItagItem> entry : getItags(ADAPTIVE_FORMATS, ItagItem.ItagType.AUDIO).entrySet()) {
ItagItem itag = entry.getValue(); ItagItem itag = entry.getValue();
AudioStream audioStream = new AudioStream(entry.getKey(), itag.getMediaFormat(), itag.avgBitrate, itag.bitrate, itag.initStart, itag.initEnd, itag.indexStart, itag.indexEnd, itag.codec); AudioStream audioStream = new AudioStream(entry.getKey(), itag);
if (!Stream.containSimilarStream(audioStream, audioStreams)) { if (!Stream.containSimilarStream(audioStream, audioStreams)) {
audioStreams.add(audioStream); audioStreams.add(audioStream);
} }
@ -542,7 +542,7 @@ public class YoutubeStreamExtractor extends StreamExtractor {
for (Map.Entry<String, ItagItem> entry : getItags(ADAPTIVE_FORMATS, ItagItem.ItagType.VIDEO_ONLY).entrySet()) { for (Map.Entry<String, ItagItem> entry : getItags(ADAPTIVE_FORMATS, ItagItem.ItagType.VIDEO_ONLY).entrySet()) {
ItagItem itag = entry.getValue(); ItagItem itag = entry.getValue();
VideoStream videoStream = new VideoStream(entry.getKey(), itag.getMediaFormat(), itag.resolutionString, true, itag.bitrate, itag.initStart, itag.initEnd, itag.indexStart, itag.indexEnd, itag.codec, itag.width, itag.height); VideoStream videoStream = new VideoStream(entry.getKey(), true, itag);
if (!Stream.containSimilarStream(videoStream, videoOnlyStreams)) { if (!Stream.containSimilarStream(videoStream, videoOnlyStreams)) {
videoOnlyStreams.add(videoStream); videoOnlyStreams.add(videoStream);
} }
@ -949,27 +949,19 @@ public class YoutubeStreamExtractor extends StreamExtractor {
+ deobfuscateSignature(cipher.get("s")); + deobfuscateSignature(cipher.get("s"));
} }
int bitrate = formatData.getInt("bitrate");
int width = formatData.getInt("width");
int height = formatData.getInt("height");
JsonObject initRange = formatData.getObject("initRange"); JsonObject initRange = formatData.getObject("initRange");
JsonObject indexRange = formatData.getObject("indexRange"); JsonObject indexRange = formatData.getObject("indexRange");
int initStart = Integer.parseInt(initRange.getString("start", "-1"));
int initEnd = Integer.parseInt(initRange.getString("end", "-1"));
int indexStart = Integer.parseInt(indexRange.getString("start", "-1"));
int indexEnd = Integer.parseInt(indexRange.getString("end", "-1"));
int fps = formatData.getInt("fps");
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 = bitrate; itagItem.bitrate = formatData.getInt("bitrate");
itagItem.width = width; itagItem.width = formatData.getInt("width");
itagItem.height = height; itagItem.height = formatData.getInt("height");
itagItem.initStart = initStart; itagItem.initStart = Integer.parseInt(initRange.getString("start", "-1"));
itagItem.initEnd = initEnd; itagItem.initEnd = Integer.parseInt(initRange.getString("end", "-1"));
itagItem.indexStart = indexStart; itagItem.indexStart = Integer.parseInt(indexRange.getString("start", "-1"));
itagItem.indexEnd = indexEnd; itagItem.indexEnd = Integer.parseInt(indexRange.getString("end", "-1"));
itagItem.fps = fps; itagItem.fps = formatData.getInt("fps");
itagItem.codec = codec; itagItem.codec = codec;
urlAndItags.put(streamUrl, itagItem); urlAndItags.put(streamUrl, itagItem);

View File

@ -21,6 +21,7 @@ package org.schabi.newpipe.extractor.stream;
*/ */
import org.schabi.newpipe.extractor.MediaFormat; import org.schabi.newpipe.extractor.MediaFormat;
import org.schabi.newpipe.extractor.services.youtube.ItagItem;
public class AudioStream extends Stream { public class AudioStream extends Stream {
public int average_bitrate = -1; public int average_bitrate = -1;
@ -50,15 +51,15 @@ public class AudioStream extends Stream {
* @param format the format * @param format the format
* @param averageBitrate the average bitrate * @param averageBitrate the average bitrate
*/ */
public AudioStream(String url, MediaFormat format, int averageBitrate, int bitrate, int initStart, int initEnd, int indexStart, int indexEnd, String codec) { public AudioStream(String url, ItagItem itag) {
super(url, format); super(url, itag.getMediaFormat());
this.average_bitrate = averageBitrate; this.average_bitrate = itag.avgBitrate;
this.bitrate = bitrate; this.bitrate = itag.bitrate;
this.initStart = initStart; this.initStart = itag.initStart;
this.initEnd = initEnd; this.initEnd = itag.initEnd;
this.indexStart = indexStart; this.indexStart = itag.indexStart;
this.indexEnd = indexEnd; this.indexEnd = itag.indexEnd;
this.codec = codec; this.codec = itag.codec;
} }
@Override @Override

View File

@ -21,20 +21,21 @@ package org.schabi.newpipe.extractor.stream;
*/ */
import org.schabi.newpipe.extractor.MediaFormat; import org.schabi.newpipe.extractor.MediaFormat;
import org.schabi.newpipe.extractor.services.youtube.ItagItem;
public class VideoStream extends Stream { public class VideoStream extends Stream {
public final String resolution; public final String resolution;
public final boolean isVideoOnly; public final boolean isVideoOnly;
// Fields for Dash // Fields for Dash
public int bitrate; private int bitrate;
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 int width; private int width;
public int height; private int height;
public String codec; private String codec;
public VideoStream(String url, MediaFormat format, String resolution) { public VideoStream(String url, MediaFormat format, String resolution) {
this(url, format, resolution, false); this(url, format, resolution, false);
@ -46,18 +47,18 @@ public class VideoStream extends Stream {
this.isVideoOnly = isVideoOnly; this.isVideoOnly = isVideoOnly;
} }
public VideoStream(String url, MediaFormat format, String resolution, boolean isVideoOnly, int bitrate, int initStart, int initEnd, int indexStart, int indexEnd, String codec, int width, int height) { public VideoStream(String url, boolean isVideoOnly, ItagItem itag) {
super(url, format); super(url, itag.getMediaFormat());
this.resolution = resolution; this.resolution = itag.resolutionString;
this.isVideoOnly = isVideoOnly; this.isVideoOnly = isVideoOnly;
this.bitrate = bitrate; this.bitrate = itag.bitrate;
this.initStart = initStart; this.initStart = itag.initStart;
this.initEnd = initEnd; this.initEnd = itag.initEnd;
this.indexStart = indexStart; this.indexStart = itag.indexStart;
this.indexEnd = indexEnd; this.indexEnd = itag.indexEnd;
this.codec = codec; this.codec = itag.codec;
this.height = height; this.height = itag.height;
this.width = width; this.width = itag.width;
} }
public VideoStream(String url, String torrentUrl, MediaFormat format, String resolution) { public VideoStream(String url, String torrentUrl, MediaFormat format, String resolution) {