Rename Stream's baseUrl to manifestUrl

This commit is contained in:
Stypox 2022-05-01 20:57:51 +02:00 committed by TiA4f8R
parent cfc13f4a6f
commit 2321822844
No known key found for this signature in database
GPG key ID: E6D3E7F5949450DD
5 changed files with 54 additions and 86 deletions

View file

@ -570,7 +570,7 @@ public class PeertubeStreamExtractor extends StreamExtractor {
.setDeliveryMethod(DeliveryMethod.HLS) .setDeliveryMethod(DeliveryMethod.HLS)
.setMediaFormat(format) .setMediaFormat(format)
.setAverageBitrate(UNKNOWN_BITRATE) .setAverageBitrate(UNKNOWN_BITRATE)
.setBaseUrl(playlistUrl) .setManifestUrl(playlistUrl)
.build(); .build();
if (!Stream.containSimilarStream(audioStream, audioStreams)) { if (!Stream.containSimilarStream(audioStream, audioStreams)) {
audioStreams.add(audioStream); audioStreams.add(audioStream);
@ -623,7 +623,7 @@ public class PeertubeStreamExtractor extends StreamExtractor {
.setDeliveryMethod(DeliveryMethod.HLS) .setDeliveryMethod(DeliveryMethod.HLS)
.setResolution(resolution) .setResolution(resolution)
.setMediaFormat(format) .setMediaFormat(format)
.setBaseUrl(playlistUrl) .setManifestUrl(playlistUrl)
.build(); .build();
if (!Stream.containSimilarStream(videoStream, videoStreams)) { if (!Stream.containSimilarStream(videoStream, videoStreams)) {
videoStreams.add(videoStream); videoStreams.add(videoStream);

View file

@ -56,7 +56,7 @@ public final class AudioStream extends Stream {
@Nullable @Nullable
private MediaFormat mediaFormat; private MediaFormat mediaFormat;
@Nullable @Nullable
private String baseUrl; private String manifestUrl;
private int averageBitrate = UNKNOWN_BITRATE; private int averageBitrate = UNKNOWN_BITRATE;
@Nullable @Nullable
private ItagItem itagItem; private ItagItem itagItem;
@ -148,22 +148,13 @@ public final class AudioStream extends Stream {
} }
/** /**
* Set the base URL of the {@link AudioStream}. * Sets the URL of the manifest this stream comes from (if applicable, otherwise null).
* *
* <p> * @param manifestUrl the URL of the manifest this stream comes from or {@code null}
* For non-URL contents, the base URL is, for instance, a link to the DASH or HLS manifest
* from which the URLs have been parsed.
* </p>
*
* <p>
* The default value is {@code null}.
* </p>
*
* @param baseUrl the base URL of the {@link AudioStream}, which can be null
* @return this {@link Builder} instance * @return this {@link Builder} instance
*/ */
public Builder setBaseUrl(@Nullable final String baseUrl) { public Builder setManifestUrl(@Nullable final String manifestUrl) {
this.baseUrl = baseUrl; this.manifestUrl = manifestUrl;
return this; return this;
} }
@ -236,7 +227,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,
baseUrl, itagItem); manifestUrl, itagItem);
} }
} }
@ -255,8 +246,8 @@ public final class AudioStream extends Stream {
* @param averageBitrate the average bitrate of the stream (which can be unknown, see * @param averageBitrate the average bitrate of the stream (which can be unknown, see
* {@link #UNKNOWN_BITRATE}) * {@link #UNKNOWN_BITRATE})
* @param itagItem the {@link ItagItem} corresponding to the stream, which cannot be null * @param itagItem the {@link ItagItem} corresponding to the stream, which cannot be null
* @param baseUrl the base URL of the stream (see {@link Stream#getBaseUrl()} for more * @param manifestUrl the URL of the manifest this stream comes from (if applicable,
* information) * otherwise null)
*/ */
@SuppressWarnings("checkstyle:ParameterNumber") @SuppressWarnings("checkstyle:ParameterNumber")
private AudioStream(@Nonnull final String id, private AudioStream(@Nonnull final String id,
@ -265,9 +256,9 @@ public final class AudioStream extends Stream {
@Nullable final MediaFormat format, @Nullable final MediaFormat format,
@Nonnull final DeliveryMethod deliveryMethod, @Nonnull final DeliveryMethod deliveryMethod,
final int averageBitrate, final int averageBitrate,
@Nullable final String baseUrl, @Nullable final String manifestUrl,
@Nullable final ItagItem itagItem) { @Nullable final ItagItem itagItem) {
super(id, content, isUrl, format, deliveryMethod, baseUrl); super(id, content, isUrl, format, deliveryMethod, manifestUrl);
if (itagItem != null) { if (itagItem != null) {
this.itagItem = itagItem; this.itagItem = itagItem;
this.itag = itagItem.id; this.itag = itagItem.id;

View file

@ -33,7 +33,7 @@ public abstract class Stream implements Serializable {
private final String content; private final String content;
private final boolean isUrl; private final boolean isUrl;
private final DeliveryMethod deliveryMethod; private final DeliveryMethod deliveryMethod;
@Nullable private final String baseUrl; @Nullable private final String manifestUrl;
/** /**
* Instantiates a new {@code Stream} object. * Instantiates a new {@code Stream} object.
@ -45,21 +45,21 @@ public abstract class Stream implements Serializable {
* manifest * manifest
* @param format the {@link MediaFormat}, which can be null * @param format the {@link MediaFormat}, which can be null
* @param deliveryMethod the delivery method of the stream * @param deliveryMethod the delivery method of the stream
* @param baseUrl the base URL of the content if the stream is a DASH or an HLS * @param manifestUrl the URL of the manifest this stream comes from (if applicable,
* manifest, which can be null * otherwise null)
*/ */
public Stream(final String id, public Stream(final String id,
final String content, final String content,
final boolean isUrl, final boolean isUrl,
@Nullable final MediaFormat format, @Nullable final MediaFormat format,
final DeliveryMethod deliveryMethod, final DeliveryMethod deliveryMethod,
@Nullable final String baseUrl) { @Nullable final String manifestUrl) {
this.id = id; this.id = id;
this.content = content; this.content = content;
this.isUrl = isUrl; this.isUrl = isUrl;
this.mediaFormat = format; this.mediaFormat = format;
this.deliveryMethod = deliveryMethod; this.deliveryMethod = deliveryMethod;
this.baseUrl = baseUrl; this.manifestUrl = manifestUrl;
} }
/** /**
@ -184,7 +184,7 @@ public abstract class Stream implements Serializable {
} }
/** /**
* Gets the delivery method. * Gets the {@link DeliveryMethod}.
* *
* @return the delivery method * @return the delivery method
*/ */
@ -194,18 +194,13 @@ public abstract class Stream implements Serializable {
} }
/** /**
* Gets the base URL of a stream. * Gets the URL of the manifest this stream comes from (if applicable, otherwise null).
* *
* <p> * @return the URL of the manifest this stream comes from or {@code null}
* If the stream is not a DASH stream or an HLS stream, this value will always be null.
* It may also be null for these streams too.
* </p>
*
* @return the base URL of the stream or {@code null}
*/ */
@Nullable @Nullable
public String getBaseUrl() { public String getManifestUrl() {
return baseUrl; return manifestUrl;
} }
/** /**
@ -235,11 +230,11 @@ public abstract class Stream implements Serializable {
&& deliveryMethod == stream.deliveryMethod && deliveryMethod == stream.deliveryMethod
&& content.equals(stream.content) && content.equals(stream.content)
&& isUrl == stream.isUrl && isUrl == stream.isUrl
&& Objects.equals(baseUrl, stream.baseUrl); && Objects.equals(manifestUrl, stream.manifestUrl);
} }
@Override @Override
public int hashCode() { public int hashCode() {
return Objects.hash(id, mediaFormat, deliveryMethod, content, isUrl, baseUrl); return Objects.hash(id, mediaFormat, deliveryMethod, content, isUrl, manifestUrl);
} }
} }

View file

@ -29,7 +29,7 @@ public final class SubtitlesStream extends Stream {
@Nullable @Nullable
private MediaFormat mediaFormat; private MediaFormat mediaFormat;
@Nullable @Nullable
private String baseUrl; private String manifestUrl;
private String languageCode; private String languageCode;
// Use of the Boolean class instead of the primitive type needed for setter call check // Use of the Boolean class instead of the primitive type needed for setter call check
private Boolean autoGenerated; private Boolean autoGenerated;
@ -116,22 +116,13 @@ public final class SubtitlesStream extends Stream {
} }
/** /**
* Set the base URL of the {@link SubtitlesStream}. * Sets the URL of the manifest this stream comes from (if applicable, otherwise null).
* *
* <p> * @param manifestUrl the URL of the manifest this stream comes from or {@code null}
* For non-URL contents, the base URL is, for instance, a link to the DASH or HLS manifest
* from which the URLs have been parsed.
* </p>
*
* <p>
* The default value is {@code null}.
* </p>
*
* @param baseUrl the base URL of the {@link SubtitlesStream}, which can be null
* @return this {@link Builder} instance * @return this {@link Builder} instance
*/ */
public Builder setBaseUrl(@Nullable final String baseUrl) { public Builder setManifestUrl(@Nullable final String manifestUrl) {
this.baseUrl = baseUrl; this.manifestUrl = manifestUrl;
return this; return this;
} }
@ -212,25 +203,25 @@ public final class SubtitlesStream extends Stream {
} }
return new SubtitlesStream(id, content, isUrl, mediaFormat, deliveryMethod, return new SubtitlesStream(id, content, isUrl, mediaFormat, deliveryMethod,
languageCode, autoGenerated, baseUrl); languageCode, autoGenerated, manifestUrl);
} }
} }
/** /**
* Create a new subtitles stream. * Create a new subtitles stream.
* *
* @param id the identifier which uniquely identifies the stream, e.g. for YouTube * @param id the identifier which uniquely identifies the stream, e.g. for YouTube
* this would be the itag * this would be the itag
* @param content the content or the URL of the stream, depending on whether isUrl is * @param content the content or the URL of the stream, depending on whether isUrl is
* true * true
* @param isUrl whether content is the URL or the actual content of e.g. a DASH * @param isUrl whether content is the URL or the actual content of e.g. a DASH
* manifest * manifest
* @param mediaFormat the {@link MediaFormat} used by the stream * @param mediaFormat the {@link MediaFormat} used by the stream
* @param deliveryMethod the {@link DeliveryMethod} of the stream * @param deliveryMethod the {@link DeliveryMethod} of the stream
* @param languageCode the language code of the stream * @param languageCode the language code of the stream
* @param autoGenerated whether the subtitles are auto-generated by the streaming service * @param autoGenerated whether the subtitles are auto-generated by the streaming service
* @param baseUrl the base URL of the stream (see {@link Stream#getBaseUrl()} for more * @param manifestUrl the URL of the manifest this stream comes from (if applicable,
* information) * otherwise null)
*/ */
@SuppressWarnings("checkstyle:ParameterNumber") @SuppressWarnings("checkstyle:ParameterNumber")
private SubtitlesStream(@Nonnull final String id, private SubtitlesStream(@Nonnull final String id,
@ -240,8 +231,8 @@ public final class SubtitlesStream extends Stream {
@Nonnull final DeliveryMethod deliveryMethod, @Nonnull final DeliveryMethod deliveryMethod,
@Nonnull final String languageCode, @Nonnull final String languageCode,
final boolean autoGenerated, final boolean autoGenerated,
@Nullable final String baseUrl) { @Nullable final String manifestUrl) {
super(id, content, isUrl, mediaFormat, deliveryMethod, baseUrl); super(id, content, isUrl, mediaFormat, deliveryMethod, manifestUrl);
/* /*
* Locale.forLanguageTag only for Android API >= 21 * Locale.forLanguageTag only for Android API >= 21

View file

@ -64,7 +64,7 @@ public final class VideoStream extends Stream {
@Nullable @Nullable
private MediaFormat mediaFormat; private MediaFormat mediaFormat;
@Nullable @Nullable
private String baseUrl; private String manifestUrl;
// Use of the Boolean class instead of the primitive type needed for setter call check // Use of the Boolean class instead of the primitive type needed for setter call check
private Boolean isVideoOnly; private Boolean isVideoOnly;
private String resolution; private String resolution;
@ -157,22 +157,13 @@ public final class VideoStream extends Stream {
} }
/** /**
* Set the base URL of the {@link VideoStream}. * Sets the URL of the manifest this stream comes from (if applicable, otherwise null).
* *
* <p> * @param manifestUrl the URL of the manifest this stream comes from or {@code null}
* For non-URL contents, the base URL is, for instance, a link to the DASH or HLS manifest
* from which the URLs have been parsed.
* </p>
*
* <p>
* The default value is {@code null}.
* </p>
*
* @param baseUrl the base URL of the {@link VideoStream}, which can be null
* @return this {@link Builder} instance * @return this {@link Builder} instance
*/ */
public Builder setBaseUrl(@Nullable final String baseUrl) { public Builder setManifestUrl(@Nullable final String manifestUrl) {
this.baseUrl = baseUrl; this.manifestUrl = manifestUrl;
return this; return this;
} }
@ -282,7 +273,7 @@ public final class VideoStream extends Stream {
} }
return new VideoStream(id, content, isUrl, mediaFormat, deliveryMethod, resolution, return new VideoStream(id, content, isUrl, mediaFormat, deliveryMethod, resolution,
isVideoOnly, baseUrl, itagItem); isVideoOnly, manifestUrl, itagItem);
} }
} }
@ -300,8 +291,8 @@ public final class VideoStream extends Stream {
* @param resolution the resolution of the stream * @param resolution the resolution of the stream
* @param isVideoOnly whether the stream is video-only * @param isVideoOnly whether the stream is video-only
* @param itagItem the {@link ItagItem} corresponding to the stream, which cannot be null * @param itagItem the {@link ItagItem} corresponding to the stream, which cannot be null
* @param baseUrl the base URL of the stream (see {@link Stream#getBaseUrl()} for more * @param manifestUrl the URL of the manifest this stream comes from (if applicable,
* information) * otherwise null)
*/ */
@SuppressWarnings("checkstyle:ParameterNumber") @SuppressWarnings("checkstyle:ParameterNumber")
private VideoStream(@Nonnull final String id, private VideoStream(@Nonnull final String id,
@ -311,9 +302,9 @@ public final class VideoStream extends Stream {
@Nonnull final DeliveryMethod deliveryMethod, @Nonnull final DeliveryMethod deliveryMethod,
@Nonnull final String resolution, @Nonnull final String resolution,
final boolean isVideoOnly, final boolean isVideoOnly,
@Nullable final String baseUrl, @Nullable final String manifestUrl,
@Nullable final ItagItem itagItem) { @Nullable final ItagItem itagItem) {
super(id, content, isUrl, format, deliveryMethod, baseUrl); super(id, content, isUrl, format, deliveryMethod, manifestUrl);
if (itagItem != null) { if (itagItem != null) {
this.itagItem = itagItem; this.itagItem = itagItem;
this.itag = itagItem.id; this.itag = itagItem.id;