Refactored Identifiers (#1205)

Extractor.pageFetched -> Extractor.isPageFetched
Stream.equalStats(Stream) is renamed to Stream.areStatsEqual(Stream)
Stream.getBitrate() is renamed to Stream.getBitRate()
This commit is contained in:
congyuluo 2024-11-13 01:01:20 -08:00 committed by GitHub
parent 169098432b
commit 0de224124b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 17 additions and 17 deletions

View File

@ -28,7 +28,7 @@ public abstract class Extractor {
@Nullable @Nullable
private ContentCountry forcedContentCountry = null; private ContentCountry forcedContentCountry = null;
private boolean pageFetched = false; private boolean isPageFetched = false;
// called like this to prevent checkstyle errors about "hiding a field" // called like this to prevent checkstyle errors about "hiding a field"
private final Downloader downloader; private final Downloader downloader;
@ -54,21 +54,21 @@ public abstract class Extractor {
* @throws ExtractionException if the pages content is not understood * @throws ExtractionException if the pages content is not understood
*/ */
public void fetchPage() throws IOException, ExtractionException { public void fetchPage() throws IOException, ExtractionException {
if (pageFetched) { if (isPageFetched) {
return; return;
} }
onFetchPage(downloader); onFetchPage(downloader);
pageFetched = true; isPageFetched = true;
} }
protected void assertPageFetched() { protected void assertPageFetched() {
if (!pageFetched) { if (!isPageFetched) {
throw new IllegalStateException("Page is not fetched. Make sure you call fetchPage()"); throw new IllegalStateException("Page is not fetched. Make sure you call fetchPage()");
} }
} }
protected boolean isPageFetched() { protected boolean isPageFetched() {
return pageFetched; return isPageFetched;
} }
/** /**

View File

@ -35,7 +35,7 @@ public final class AudioStream extends Stream {
// Fields for DASH // Fields for DASH
private int itag = ITAG_NOT_AVAILABLE_OR_NOT_APPLICABLE; private int itag = ITAG_NOT_AVAILABLE_OR_NOT_APPLICABLE;
private int bitrate; private int bitRate;
private int initStart; private int initStart;
private int initEnd; private int initEnd;
private int indexStart; private int indexStart;
@ -351,7 +351,7 @@ public final class AudioStream extends Stream {
this.itagItem = itagItem; this.itagItem = itagItem;
this.itag = itagItem.id; this.itag = itagItem.id;
this.quality = itagItem.getQuality(); this.quality = itagItem.getQuality();
this.bitrate = itagItem.getBitrate(); this.bitRate = itagItem.getBitrate();
this.initStart = itagItem.getInitStart(); this.initStart = itagItem.getInitStart();
this.initEnd = itagItem.getInitEnd(); this.initEnd = itagItem.getInitEnd();
this.indexStart = itagItem.getIndexStart(); this.indexStart = itagItem.getIndexStart();
@ -369,8 +369,8 @@ public final class AudioStream extends Stream {
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public boolean equalStats(final Stream cmp) { public boolean areStatsEqual(final Stream cmp) {
return super.equalStats(cmp) && cmp instanceof AudioStream return super.areStatsEqual(cmp) && cmp instanceof AudioStream
&& averageBitrate == ((AudioStream) cmp).averageBitrate && averageBitrate == ((AudioStream) cmp).averageBitrate
&& Objects.equals(audioTrackId, ((AudioStream) cmp).audioTrackId) && Objects.equals(audioTrackId, ((AudioStream) cmp).audioTrackId)
&& audioTrackType == ((AudioStream) cmp).audioTrackType && 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. * @return the bitrate set from the {@link ItagItem} passed in the constructor of the stream.
*/ */
public int getBitrate() { public int getBitRate() {
return bitrate; return bitRate;
} }
/** /**

View File

@ -74,7 +74,7 @@ public abstract class Stream implements Serializable {
return false; return false;
} }
for (final Stream cmpStream : streamList) { for (final Stream cmpStream : streamList) {
if (stream.equalStats(cmpStream)) { if (stream.areStatsEqual(cmpStream)) {
return true; return true;
} }
} }
@ -97,7 +97,7 @@ public abstract class Stream implements Serializable {
* @param other the stream object to be compared to this stream object * @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 * @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) { if (other == null || mediaFormat == null || other.mediaFormat == null) {
return false; return false;
} }

View File

@ -265,8 +265,8 @@ public final class SubtitlesStream extends Stream {
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public boolean equalStats(final Stream cmp) { public boolean areStatsEqual(final Stream cmp) {
return super.equalStats(cmp) return super.areStatsEqual(cmp)
&& cmp instanceof SubtitlesStream && cmp instanceof SubtitlesStream
&& code.equals(((SubtitlesStream) cmp).code) && code.equals(((SubtitlesStream) cmp).code)
&& autoGenerated == ((SubtitlesStream) cmp).autoGenerated; && autoGenerated == ((SubtitlesStream) cmp).autoGenerated;

View File

@ -326,8 +326,8 @@ public final class VideoStream extends Stream {
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public boolean equalStats(final Stream cmp) { public boolean areStatsEqual(final Stream cmp) {
return super.equalStats(cmp) return super.areStatsEqual(cmp)
&& cmp instanceof VideoStream && cmp instanceof VideoStream
&& resolution.equals(((VideoStream) cmp).resolution) && resolution.equals(((VideoStream) cmp).resolution)
&& isVideoOnly == ((VideoStream) cmp).isVideoOnly; && isVideoOnly == ((VideoStream) cmp).isVideoOnly;