Skip to content

Commit ff8eb68

Browse files
committed
Modified type hierarchy for downloads
1 parent 889b5f2 commit ff8eb68

File tree

10 files changed

+62
-21
lines changed

10 files changed

+62
-21
lines changed

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/dashmanifestcreator/AbstractYoutubeDashManifestCreator.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,12 @@ protected AbstractYoutubeDashManifestCreator(
102102
this.durationSecondsFallback = durationSecondsFallback;
103103
}
104104

105+
@Nonnull
106+
@Override
107+
public String downloadUrl() {
108+
return itagInfo.getStreamUrl();
109+
}
110+
105111
@Override
106112
public long getExpectedContentLength(final Downloader downloader) {
107113
return downloader.getContentLength(itagInfo.getStreamUrl());

extractor/src/main/java/org/schabi/newpipe/extractor/streamdata/delivery/DASHManifestDeliveryData.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,18 @@
55

66
import javax.annotation.Nonnull;
77

8-
public interface DASHManifestDeliveryData extends DASHDeliveryData {
8+
public interface DASHManifestDeliveryData extends DASHDeliveryData, DownloadableDeliveryData {
99
@Nonnull
1010
DashManifestCreator dashManifestCreator();
1111

1212
String getCachedDashManifestAsString();
1313

14+
@Nonnull
15+
@Override
16+
default String downloadUrl() {
17+
return dashManifestCreator().downloadUrl();
18+
}
19+
1420
@Override
1521
default long getExpectedContentLength(final Downloader downloader) {
1622
return dashManifestCreator().getExpectedContentLength(downloader);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package org.schabi.newpipe.extractor.streamdata.delivery;
22

3-
public interface DASHUrlDeliveryData extends UrlBasedDeliveryData, DASHDeliveryData {
3+
public interface DASHUrlDeliveryData extends DownloadableUrlBasedDeliveryData, DASHDeliveryData {
44
// Nothing to implement additionally
55
}
Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
package org.schabi.newpipe.extractor.streamdata.delivery;
22

3-
import org.schabi.newpipe.extractor.downloader.Downloader;
4-
53
public interface DeliveryData {
6-
/**
7-
* Returns the expected content length/size of the data.
8-
*
9-
* @param downloader The downloader that may be used for fetching (HTTP HEAD).
10-
* @return the expected size/content length or <code>-1</code> if unknown
11-
*/
12-
long getExpectedContentLength(Downloader downloader);
4+
// Just a marker
135
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package org.schabi.newpipe.extractor.streamdata.delivery;
2+
3+
import org.schabi.newpipe.extractor.downloader.Downloader;
4+
5+
import javax.annotation.Nonnull;
6+
7+
/**
8+
* Provides information for downloading a stream.
9+
*/
10+
public interface DownloadableDeliveryData extends DeliveryData {
11+
12+
@Nonnull
13+
String downloadUrl();
14+
15+
/**
16+
* Returns the expected content length/size of the data.
17+
*
18+
* @param downloader The downloader that may be used for fetching (HTTP HEAD).
19+
* @return the expected size/content length or <code>-1</code> if unknown
20+
*/
21+
long getExpectedContentLength(Downloader downloader);
22+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package org.schabi.newpipe.extractor.streamdata.delivery;
2+
3+
import org.schabi.newpipe.extractor.downloader.Downloader;
4+
5+
import javax.annotation.Nonnull;
6+
7+
public interface DownloadableUrlBasedDeliveryData
8+
extends UrlBasedDeliveryData, DownloadableDeliveryData {
9+
@Nonnull
10+
@Override
11+
default String downloadUrl() {
12+
return url();
13+
}
14+
15+
@Override
16+
default long getExpectedContentLength(final Downloader downloader) {
17+
return downloader.getContentLength(url());
18+
}
19+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package org.schabi.newpipe.extractor.streamdata.delivery;
22

3-
public interface HLSDeliveryData extends UrlBasedDeliveryData {
3+
public interface HLSDeliveryData extends DownloadableUrlBasedDeliveryData {
44
// Nothing to implement additionally
55
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package org.schabi.newpipe.extractor.streamdata.delivery;
22

3-
public interface ProgressiveHTTPDeliveryData extends UrlBasedDeliveryData {
3+
public interface ProgressiveHTTPDeliveryData extends DownloadableUrlBasedDeliveryData {
44
// Nothing to implement additionally
55
}
Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
11
package org.schabi.newpipe.extractor.streamdata.delivery;
22

3-
import org.schabi.newpipe.extractor.downloader.Downloader;
4-
53
import javax.annotation.Nonnull;
64

75
public interface UrlBasedDeliveryData extends DeliveryData {
86
@Nonnull
97
String url();
10-
11-
@Override
12-
default long getExpectedContentLength(final Downloader downloader) {
13-
return downloader.getContentLength(url());
14-
}
158
}

extractor/src/main/java/org/schabi/newpipe/extractor/streamdata/delivery/dashmanifestcreator/DashManifestCreator.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@ public interface DashManifestCreator {
1515
@Nonnull
1616
String generateManifest();
1717

18+
@Nonnull
19+
String downloadUrl();
20+
1821
/**
1922
* See
20-
* {@link org.schabi.newpipe.extractor.streamdata.delivery.DeliveryData#getExpectedContentLength(Downloader)}
23+
* {@link org.schabi.newpipe.extractor.streamdata.delivery.DownloadableDeliveryData#getExpectedContentLength(Downloader)}
2124
*/
2225
long getExpectedContentLength(Downloader downloader);
2326
}

0 commit comments

Comments
 (0)