AudioStream: remove unused youtube-specific fields
These fields were added in https://github.com/TeamNewPipe/NewPipeExtractor/pull/810 in preparation for a DASH support that never materialized … well it did materialize, but did not use any of these variables. Since they are youtube-specific, it does not make much sense to export them in the generic API, lest people start depending on them as if they belonged to all backends. Well, 4 variables are actually already depended on in places, they will have to be checked separately. But this is the low-hanging fruit.
This commit is contained in:
parent
3402cdb666
commit
8448f0af14
|
@ -33,16 +33,6 @@ public final class AudioStream extends Stream {
|
||||||
|
|
||||||
private final int averageBitrate;
|
private final int averageBitrate;
|
||||||
|
|
||||||
// Fields for DASH
|
|
||||||
private int itag = ITAG_NOT_AVAILABLE_OR_NOT_APPLICABLE;
|
|
||||||
private int bitrate;
|
|
||||||
private int initStart;
|
|
||||||
private int initEnd;
|
|
||||||
private int indexStart;
|
|
||||||
private int indexEnd;
|
|
||||||
private String quality;
|
|
||||||
private String codec;
|
|
||||||
|
|
||||||
// Fields about the audio track id/name
|
// Fields about the audio track id/name
|
||||||
@Nullable
|
@Nullable
|
||||||
private final String audioTrackId;
|
private final String audioTrackId;
|
||||||
|
@ -53,6 +43,7 @@ public final class AudioStream extends Stream {
|
||||||
@Nullable
|
@Nullable
|
||||||
private final AudioTrackType audioTrackType;
|
private final AudioTrackType audioTrackType;
|
||||||
|
|
||||||
|
// * Youtube-backend-specific data
|
||||||
@Nullable
|
@Nullable
|
||||||
private ItagItem itagItem;
|
private ItagItem itagItem;
|
||||||
|
|
||||||
|
@ -307,8 +298,7 @@ public final class AudioStream extends Stream {
|
||||||
}
|
}
|
||||||
|
|
||||||
return new AudioStream(id, content, isUrl, mediaFormat, deliveryMethod, averageBitrate,
|
return new AudioStream(id, content, isUrl, mediaFormat, deliveryMethod, averageBitrate,
|
||||||
manifestUrl, audioTrackId, audioTrackName, audioLocale, audioTrackType,
|
manifestUrl, audioTrackId, audioTrackName, audioLocale, audioTrackType);
|
||||||
itagItem);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -329,7 +319,6 @@ public final class AudioStream extends Stream {
|
||||||
* @param audioTrackId the id of the audio track
|
* @param audioTrackId the id of the audio track
|
||||||
* @param audioTrackName the name of the audio track
|
* @param audioTrackName the name of the audio track
|
||||||
* @param audioLocale the {@link Locale} of the audio stream, representing its language
|
* @param audioLocale the {@link Locale} of the audio stream, representing its language
|
||||||
* @param itagItem the {@link ItagItem} corresponding to the stream, which cannot be null
|
|
||||||
* @param manifestUrl the URL of the manifest this stream comes from (if applicable,
|
* @param manifestUrl the URL of the manifest this stream comes from (if applicable,
|
||||||
* otherwise null)
|
* otherwise null)
|
||||||
*/
|
*/
|
||||||
|
@ -344,20 +333,9 @@ public final class AudioStream extends Stream {
|
||||||
@Nullable final String audioTrackId,
|
@Nullable final String audioTrackId,
|
||||||
@Nullable final String audioTrackName,
|
@Nullable final String audioTrackName,
|
||||||
@Nullable final Locale audioLocale,
|
@Nullable final Locale audioLocale,
|
||||||
@Nullable final AudioTrackType audioTrackType,
|
@Nullable final AudioTrackType audioTrackType
|
||||||
@Nullable final ItagItem itagItem) {
|
) {
|
||||||
super(id, content, isUrl, format, deliveryMethod, manifestUrl);
|
super(id, content, isUrl, format, deliveryMethod, manifestUrl);
|
||||||
if (itagItem != null) {
|
|
||||||
this.itagItem = itagItem;
|
|
||||||
this.itag = itagItem.id;
|
|
||||||
this.quality = itagItem.getQuality();
|
|
||||||
this.bitrate = itagItem.getBitrate();
|
|
||||||
this.initStart = itagItem.getInitStart();
|
|
||||||
this.initEnd = itagItem.getInitEnd();
|
|
||||||
this.indexStart = itagItem.getIndexStart();
|
|
||||||
this.indexEnd = itagItem.getIndexEnd();
|
|
||||||
this.codec = itagItem.getCodec();
|
|
||||||
}
|
|
||||||
this.averageBitrate = averageBitrate;
|
this.averageBitrate = averageBitrate;
|
||||||
this.audioTrackId = audioTrackId;
|
this.audioTrackId = audioTrackId;
|
||||||
this.audioTrackName = audioTrackName;
|
this.audioTrackName = audioTrackName;
|
||||||
|
@ -386,88 +364,6 @@ public final class AudioStream extends Stream {
|
||||||
return averageBitrate;
|
return averageBitrate;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the itag identifier of the stream.
|
|
||||||
*
|
|
||||||
* <p>
|
|
||||||
* Always equals to {@link #ITAG_NOT_AVAILABLE_OR_NOT_APPLICABLE} for other streams than the
|
|
||||||
* ones of the YouTube service.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @return the number of the {@link ItagItem} passed in the constructor of the audio stream.
|
|
||||||
*/
|
|
||||||
public int getItag() {
|
|
||||||
return itag;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the bitrate of the stream.
|
|
||||||
*
|
|
||||||
* @return the bitrate set from the {@link ItagItem} passed in the constructor of the stream.
|
|
||||||
*/
|
|
||||||
public int getBitrate() {
|
|
||||||
return bitrate;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the initialization start of the stream.
|
|
||||||
*
|
|
||||||
* @return the initialization start value set from the {@link ItagItem} passed in the
|
|
||||||
* constructor of the stream.
|
|
||||||
*/
|
|
||||||
public int getInitStart() {
|
|
||||||
return initStart;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the initialization end of the stream.
|
|
||||||
*
|
|
||||||
* @return the initialization end value set from the {@link ItagItem} passed in the constructor
|
|
||||||
* of the stream.
|
|
||||||
*/
|
|
||||||
public int getInitEnd() {
|
|
||||||
return initEnd;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the index start of the stream.
|
|
||||||
*
|
|
||||||
* @return the index start value set from the {@link ItagItem} passed in the constructor of the
|
|
||||||
* stream.
|
|
||||||
*/
|
|
||||||
public int getIndexStart() {
|
|
||||||
return indexStart;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the index end of the stream.
|
|
||||||
*
|
|
||||||
* @return the index end value set from the {@link ItagItem} passed in the constructor of the
|
|
||||||
* stream.
|
|
||||||
*/
|
|
||||||
public int getIndexEnd() {
|
|
||||||
return indexEnd;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the quality of the stream.
|
|
||||||
*
|
|
||||||
* @return the quality label set from the {@link ItagItem} passed in the constructor of the
|
|
||||||
* stream.
|
|
||||||
*/
|
|
||||||
public String getQuality() {
|
|
||||||
return quality;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the codec of the stream.
|
|
||||||
*
|
|
||||||
* @return the codec set from the {@link ItagItem} passed in the constructor of the stream.
|
|
||||||
*/
|
|
||||||
public String getCodec() {
|
|
||||||
return codec;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the id of the audio track.
|
* Get the id of the audio track.
|
||||||
*
|
*
|
||||||
|
|
|
@ -22,6 +22,7 @@ import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
@ -123,12 +124,17 @@ class YoutubeDashManifestCreatorsTest {
|
||||||
for (final Stream stream : assertFilterStreams(streams, DeliveryMethod.DASH)) {
|
for (final Stream stream : assertFilterStreams(streams, DeliveryMethod.DASH)) {
|
||||||
//noinspection ConstantConditions
|
//noinspection ConstantConditions
|
||||||
final String manifest = YoutubeOtfDashManifestCreator.fromOtfStreamingUrl(
|
final String manifest = YoutubeOtfDashManifestCreator.fromOtfStreamingUrl(
|
||||||
stream.getContent(), stream.getItagItem(), videoLength);
|
stream.getContent(),
|
||||||
|
// We know that itagItem has to be set, because it’s youtube-specific
|
||||||
|
Objects.requireNonNull(stream.getItagItem()),
|
||||||
|
videoLength
|
||||||
|
);
|
||||||
assertNotBlank(manifest);
|
assertNotBlank(manifest);
|
||||||
|
|
||||||
assertManifestGenerated(
|
assertManifestGenerated(
|
||||||
manifest,
|
manifest,
|
||||||
stream.getItagItem(),
|
// We know that itagItem has to be set, because it’s youtube-specific
|
||||||
|
Objects.requireNonNull(stream.getItagItem()),
|
||||||
document -> assertAll(
|
document -> assertAll(
|
||||||
() -> assertSegmentTemplateElement(document),
|
() -> assertSegmentTemplateElement(document),
|
||||||
() -> assertSegmentTimelineAndSElements(document)
|
() -> assertSegmentTimelineAndSElements(document)
|
||||||
|
@ -143,16 +149,22 @@ class YoutubeDashManifestCreatorsTest {
|
||||||
//noinspection ConstantConditions
|
//noinspection ConstantConditions
|
||||||
final String manifest =
|
final String manifest =
|
||||||
YoutubeProgressiveDashManifestCreator.fromProgressiveStreamingUrl(
|
YoutubeProgressiveDashManifestCreator.fromProgressiveStreamingUrl(
|
||||||
stream.getContent(), stream.getItagItem(), videoLength);
|
stream.getContent(),
|
||||||
|
// We know that itagItem has to be set, because it’s youtube-specific
|
||||||
|
Objects.requireNonNull(stream.getItagItem()),
|
||||||
|
videoLength);
|
||||||
assertNotBlank(manifest);
|
assertNotBlank(manifest);
|
||||||
|
|
||||||
|
@Nonnull final ItagItem itagItem =
|
||||||
|
// We know that itagItem has to be set, because it’s youtube-specific
|
||||||
|
Objects.requireNonNull(stream.getItagItem());
|
||||||
assertManifestGenerated(
|
assertManifestGenerated(
|
||||||
manifest,
|
manifest,
|
||||||
stream.getItagItem(),
|
itagItem,
|
||||||
document -> assertAll(
|
document -> assertAll(
|
||||||
() -> assertBaseUrlElement(document),
|
() -> assertBaseUrlElement(document),
|
||||||
() -> assertSegmentBaseElement(document, stream.getItagItem()),
|
() -> assertSegmentBaseElement(document, itagItem),
|
||||||
() -> assertInitializationElement(document, stream.getItagItem())
|
() -> assertInitializationElement(document, itagItem)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -171,7 +183,9 @@ class YoutubeDashManifestCreatorsTest {
|
||||||
assertAll(filteredStreams.stream()
|
assertAll(filteredStreams.stream()
|
||||||
.flatMap(stream -> java.util.stream.Stream.of(
|
.flatMap(stream -> java.util.stream.Stream.of(
|
||||||
() -> assertNotBlank(stream.getContent()),
|
() -> assertNotBlank(stream.getContent()),
|
||||||
() -> assertNotNull(stream.getItagItem())
|
() ->
|
||||||
|
// We know that itagItem has to be set, because it’s youtube-specific
|
||||||
|
assertNotNull(stream.getItagItem())
|
||||||
))
|
))
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -179,7 +193,7 @@ class YoutubeDashManifestCreatorsTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertManifestGenerated(final String dashManifest,
|
private void assertManifestGenerated(final String dashManifest,
|
||||||
final ItagItem itagItem,
|
@Nonnull final ItagItem itagItem,
|
||||||
final Consumer<Document> additionalAsserts)
|
final Consumer<Document> additionalAsserts)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue