From 0de224124be656b5792235303b7ce4dd0063165f Mon Sep 17 00:00:00 2001 From: congyuluo <78986434+congyuluo@users.noreply.github.com> Date: Wed, 13 Nov 2024 01:01:20 -0800 Subject: [PATCH] Refactored Identifiers (#1205) Extractor.pageFetched -> Extractor.isPageFetched Stream.equalStats(Stream) is renamed to Stream.areStatsEqual(Stream) Stream.getBitrate() is renamed to Stream.getBitRate() --- .../java/org/schabi/newpipe/extractor/Extractor.java | 10 +++++----- .../schabi/newpipe/extractor/stream/AudioStream.java | 12 ++++++------ .../org/schabi/newpipe/extractor/stream/Stream.java | 4 ++-- .../newpipe/extractor/stream/SubtitlesStream.java | 4 ++-- .../schabi/newpipe/extractor/stream/VideoStream.java | 4 ++-- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/Extractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/Extractor.java index e973b4416..ca77c8229 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/Extractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/Extractor.java @@ -28,7 +28,7 @@ public abstract class Extractor { @Nullable private ContentCountry forcedContentCountry = null; - private boolean pageFetched = false; + private boolean isPageFetched = false; // called like this to prevent checkstyle errors about "hiding a field" private final Downloader downloader; @@ -54,21 +54,21 @@ public abstract class Extractor { * @throws ExtractionException if the pages content is not understood */ public void fetchPage() throws IOException, ExtractionException { - if (pageFetched) { + if (isPageFetched) { return; } onFetchPage(downloader); - pageFetched = true; + isPageFetched = true; } protected void assertPageFetched() { - if (!pageFetched) { + if (!isPageFetched) { throw new IllegalStateException("Page is not fetched. Make sure you call fetchPage()"); } } protected boolean isPageFetched() { - return pageFetched; + return isPageFetched; } /** 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 e31e1aff3..d7c0bb5d4 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 @@ -35,7 +35,7 @@ public final class AudioStream extends Stream { // Fields for DASH private int itag = ITAG_NOT_AVAILABLE_OR_NOT_APPLICABLE; - private int bitrate; + private int bitRate; private int initStart; private int initEnd; private int indexStart; @@ -351,7 +351,7 @@ public final class AudioStream extends Stream { this.itagItem = itagItem; this.itag = itagItem.id; this.quality = itagItem.getQuality(); - this.bitrate = itagItem.getBitrate(); + this.bitRate = itagItem.getBitrate(); this.initStart = itagItem.getInitStart(); this.initEnd = itagItem.getInitEnd(); this.indexStart = itagItem.getIndexStart(); @@ -369,8 +369,8 @@ public final class AudioStream extends Stream { * {@inheritDoc} */ @Override - public boolean equalStats(final Stream cmp) { - return super.equalStats(cmp) && cmp instanceof AudioStream + public boolean areStatsEqual(final Stream cmp) { + return super.areStatsEqual(cmp) && cmp instanceof AudioStream && averageBitrate == ((AudioStream) cmp).averageBitrate && Objects.equals(audioTrackId, ((AudioStream) cmp).audioTrackId) && audioTrackType == ((AudioStream) cmp).audioTrackType @@ -405,8 +405,8 @@ public final class AudioStream extends Stream { * * @return the bitrate set from the {@link ItagItem} passed in the constructor of the stream. */ - public int getBitrate() { - return bitrate; + public int getBitRate() { + return bitRate; } /** diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/Stream.java b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/Stream.java index 04d2b3fac..67595e6a1 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/Stream.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/Stream.java @@ -74,7 +74,7 @@ public abstract class Stream implements Serializable { return false; } for (final Stream cmpStream : streamList) { - if (stream.equalStats(cmpStream)) { + if (stream.areStatsEqual(cmpStream)) { return true; } } @@ -97,7 +97,7 @@ public abstract class Stream implements Serializable { * @param other the stream object to be compared to this stream object * @return whether the stream have the same stats or not, based on the criteria above */ - public boolean equalStats(@Nullable final Stream other) { + public boolean areStatsEqual(@Nullable final Stream other) { if (other == null || mediaFormat == null || other.mediaFormat == null) { return false; } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/SubtitlesStream.java b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/SubtitlesStream.java index 08886dcac..ce78ec453 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/SubtitlesStream.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/SubtitlesStream.java @@ -265,8 +265,8 @@ public final class SubtitlesStream extends Stream { * {@inheritDoc} */ @Override - public boolean equalStats(final Stream cmp) { - return super.equalStats(cmp) + public boolean areStatsEqual(final Stream cmp) { + return super.areStatsEqual(cmp) && cmp instanceof SubtitlesStream && code.equals(((SubtitlesStream) cmp).code) && autoGenerated == ((SubtitlesStream) cmp).autoGenerated; 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 170cd7df1..1aa8e4ad7 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 @@ -326,8 +326,8 @@ public final class VideoStream extends Stream { * {@inheritDoc} */ @Override - public boolean equalStats(final Stream cmp) { - return super.equalStats(cmp) + public boolean areStatsEqual(final Stream cmp) { + return super.areStatsEqual(cmp) && cmp instanceof VideoStream && resolution.equals(((VideoStream) cmp).resolution) && isVideoOnly == ((VideoStream) cmp).isVideoOnly;