From c87771264792fa565b9fae90a7142ac936d51d16 Mon Sep 17 00:00:00 2001 From: Fynn Godau Date: Thu, 1 Apr 2021 22:31:01 +0200 Subject: [PATCH] Add deprecated old method calls to avoid breaking API --- .../extractor/stream/StreamExtractor.java | 16 ++++++++++++++++ .../newpipe/extractor/stream/StreamInfo.java | 16 ++++++++++++++++ .../newpipe/extractor/utils/ExtractorHelper.java | 8 ++++++++ 3 files changed, 40 insertions(+) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamExtractor.java index 4a7ef4002..8eeb1b49b 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamExtractor.java @@ -337,6 +337,22 @@ public abstract class StreamExtractor extends Extractor { public abstract InfoItemsCollector getRelatedItems() throws IOException, ExtractionException; + /** + * @deprecated Use {@link #getRelatedItems()}. May be removed in a future version. + * @return The result of {@link #getRelatedItems()} if it is a + * StreamInfoItemsCollector, null otherwise + * @throws IOException + * @throws ExtractionException + */ + @Deprecated + @Nullable + public StreamInfoItemsCollector getRelatedStreams() throws IOException, ExtractionException { + InfoItemsCollector collector = getRelatedItems(); + if (collector instanceof StreamInfoItemsCollector) { + return (StreamInfoItemsCollector) collector; + } else return null; + } + /** * Should return a list of Frameset object that contains preview of stream frames * diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfo.java b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfo.java index 88d01fa06..cfd118bcb 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfo.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfo.java @@ -606,10 +606,26 @@ public class StreamInfo extends Info { return relatedItems; } + /** + * @deprecated Use {@link #getRelatedItems()} + */ + @Deprecated + public List getRelatedStreams() { + return getRelatedItems(); + } + public void setRelatedItems(List relatedItems) { this.relatedItems = relatedItems; } + /** + * @deprecated Use {@link #setRelatedItems(List)} + */ + @Deprecated + public void setRelatedStreams(List relatedItems) { + setRelatedItems(relatedItems); + } + public long getStartPosition() { return startPosition; } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/utils/ExtractorHelper.java b/extractor/src/main/java/org/schabi/newpipe/extractor/utils/ExtractorHelper.java index 076827626..3a74c2d3d 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/utils/ExtractorHelper.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/utils/ExtractorHelper.java @@ -41,4 +41,12 @@ public class ExtractorHelper { } } + /** + * @deprecated Use {@link #getRelatedItemsOrLogError(StreamInfo, StreamExtractor)} + */ + @Deprecated + public static List getRelatedVideosOrLogError(StreamInfo info, StreamExtractor extractor) { + return getRelatedItemsOrLogError(info, extractor); + } + }