Skip to content

Commit 4086715

Browse files
committed
Merge branch 'dev'
2 parents 04af575 + 8a79b14 commit 4086715

63 files changed

Lines changed: 1937 additions & 690 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
- [ ] I carefully read the [contribution guidelines](https://github.com/TeamNewPipe/NewPipe/blob/HEAD/.github/CONTRIBUTING.md) and agree to them.
2-
- [ ] I did test the API against [NewPipe](https://github.com/TeamNewPipe/NewPipe).
3-
- [ ] I agree to ASAP create a PULL request for [NewPipe](https://github.com/TeamNewPipe/NewPipe) for making in compatible when I changed the api.
2+
- [ ] I have tested the API against [NewPipe](https://github.com/TeamNewPipe/NewPipe).
3+
- [ ] I agree to create a pull request for [NewPipe](https://github.com/TeamNewPipe/NewPipe) as soon as possible to make it compatible with the changed API.

README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# NewPipe Extractor
22

3-
[![Build Status](https://travis-ci.org/TeamNewPipe/NewPipeExtractor.svg?branch=master)](https://travis-ci.org/TeamNewPipe/NewPipeExtractor) [![JIT Pack Badge](https://jitpack.io/v/TeamNewPipe/NewPipeExtractor.svg)](https://jitpack.io/#TeamNewPipe/NewPipeExtractor) [Documentation](https://teamnewpipe.github.io/documentation/)
3+
[![Build Status](https://travis-ci.org/TeamNewPipe/NewPipeExtractor.svg?branch=master)](https://travis-ci.org/TeamNewPipe/NewPipeExtractor) [![JIT Pack Badge](https://jitpack.io/v/TeamNewPipe/NewPipeExtractor.svg)](https://jitpack.io/#TeamNewPipe/NewPipeExtractor) [JDoc](https://teamnewpipe.github.io/NewPipeExtractor/javadoc/)[Documentation](https://teamnewpipe.github.io/documentation/)
44

55
NewPipe Extractor is a library for extracting things from streaming sites. It is a core component of [NewPipe](https://github.com/TeamNewPipe/NewPipe), but could be used independently.
66

@@ -11,11 +11,21 @@ NewPipe Extractor is available at JitPack's Maven repo.
1111
If you're using Gradle, you could add NewPipe Extractor as a dependency with the following steps:
1212

1313
1. Add `maven { url 'https://jitpack.io' }` to the `repositories` in your `build.gradle`.
14-
2. Add `compile 'com.github.TeamNewPipe:NewPipeExtractor:v0.11.0'`the `dependencies` in your `build.gradle`. Replace `v0.11.0` with the latest release.
14+
2. Add `implementation 'com.github.TeamNewPipe:NewPipeExtractor:v0.19.0'`the `dependencies` in your `build.gradle`. Replace `v0.19.0` with the latest release.
1515

1616
### Testing changes
1717

18-
To test changes quickly you can build the library locally. Using the local Maven repository is a good approach, here's a gist of how to use it:
18+
To test changes quickly you can build the library locally. A good approach would be to add something like the following to your `settings.gradle`:
19+
20+
```groovy
21+
includeBuild('../NewPipeExtractor') {
22+
dependencySubstitution {
23+
substitute module('com.github.TeamNewPipe:NewPipeExtractor') with project(':extractor')
24+
}
25+
}
26+
```
27+
28+
Another approach would be to use the local Maven repository, here's a gist of how to use it:
1929

2030
1. Add `mavenLocal()` in your project `repositories` list (usually as the first entry to give priority above the others).
2131
2. It's _recommended_ that you change the `version` of this library (e.g. `LOCAL_SNAPSHOT`).

build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ allprojects {
55
sourceCompatibility = 1.7
66
targetCompatibility = 1.7
77

8-
version 'v0.19.0'
8+
version 'v0.19.4'
99
group 'com.github.TeamNewPipe'
1010

1111
repositories {
1212
jcenter()
13+
maven { url "https://jitpack.io" }
1314
}
1415
}
1516

extractor/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
dependencies {
22
implementation project(':timeago-parser')
33

4-
implementation 'com.grack:nanojson:1.1'
4+
implementation 'com.github.TeamNewPipe:nanojson:1d9e1aea9049fc9f85e68b43ba39fe7be1c1f751'
55
implementation 'org.jsoup:jsoup:1.9.2'
66
implementation 'org.mozilla:rhino:1.7.7.1'
77
implementation 'com.github.spotbugs:spotbugs-annotations:3.1.0'
88
implementation 'org.nibor.autolink:autolink:0.8.0'
99

1010
testImplementation 'junit:junit:4.12'
11-
}
11+
}

extractor/src/main/java/org/schabi/newpipe/extractor/ListExtractor.java

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,33 @@
33
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
44
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
55

6-
import javax.annotation.Nonnull;
76
import java.io.IOException;
87
import java.util.Collections;
98
import java.util.List;
109

10+
import javax.annotation.Nonnull;
11+
1112
/**
1213
* Base class to extractors that have a list (e.g. playlists, users).
1314
*/
1415
public abstract class ListExtractor<R extends InfoItem> extends Extractor {
1516

17+
/**
18+
* Constant that should be returned whenever
19+
* a list has an unknown number of items.
20+
*/
21+
public static final long ITEM_COUNT_UNKNOWN = -1;
22+
/**
23+
* Constant that should be returned whenever a list has an
24+
* infinite number of items. For example a YouTube mix.
25+
*/
26+
public static final long ITEM_COUNT_INFINITE = -2;
27+
/**
28+
* Constant that should be returned whenever a list
29+
* has an unknown number of items bigger than 100.
30+
*/
31+
public static final long ITEM_COUNT_MORE_THAN_100 = -3;
32+
1633
public ListExtractor(StreamingService service, ListLinkHandler linkHandler) {
1734
super(service, linkHandler);
1835
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package org.schabi.newpipe.extractor.exceptions;
2+
3+
public class ContentNotSupportedException extends ParsingException {
4+
public ContentNotSupportedException(String message) {
5+
super(message);
6+
}
7+
8+
public ContentNotSupportedException(String message, Throwable cause) {
9+
super(message, cause);
10+
}
11+
}

extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCService.java

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@
66
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
77
import org.schabi.newpipe.extractor.kiosk.KioskExtractor;
88
import org.schabi.newpipe.extractor.kiosk.KioskList;
9-
import org.schabi.newpipe.extractor.linkhandler.*;
9+
import org.schabi.newpipe.extractor.linkhandler.LinkHandler;
10+
import org.schabi.newpipe.extractor.linkhandler.LinkHandlerFactory;
11+
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
12+
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandlerFactory;
13+
import org.schabi.newpipe.extractor.linkhandler.SearchQueryHandler;
14+
import org.schabi.newpipe.extractor.linkhandler.SearchQueryHandlerFactory;
1015
import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;
1116
import org.schabi.newpipe.extractor.search.SearchExtractor;
1217
import org.schabi.newpipe.extractor.services.media_ccc.extractors.MediaCCCConferenceExtractor;
@@ -21,19 +26,17 @@
2126
import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor;
2227
import org.schabi.newpipe.extractor.suggestion.SuggestionExtractor;
2328

24-
import java.io.IOException;
25-
2629
import static java.util.Arrays.asList;
2730
import static org.schabi.newpipe.extractor.StreamingService.ServiceInfo.MediaCapability.AUDIO;
2831
import static org.schabi.newpipe.extractor.StreamingService.ServiceInfo.MediaCapability.VIDEO;
2932

3033
public class MediaCCCService extends StreamingService {
31-
public MediaCCCService(int id) {
34+
public MediaCCCService(final int id) {
3235
super(id, "MediaCCC", asList(AUDIO, VIDEO));
3336
}
3437

3538
@Override
36-
public SearchExtractor getSearchExtractor(SearchQueryHandler query) {
39+
public SearchExtractor getSearchExtractor(final SearchQueryHandler query) {
3740
return new MediaCCCSearchExtractor(this, query);
3841
}
3942

@@ -58,17 +61,17 @@ public SearchQueryHandlerFactory getSearchQHFactory() {
5861
}
5962

6063
@Override
61-
public StreamExtractor getStreamExtractor(LinkHandler linkHandler) {
64+
public StreamExtractor getStreamExtractor(final LinkHandler linkHandler) {
6265
return new MediaCCCStreamExtractor(this, linkHandler);
6366
}
6467

6568
@Override
66-
public ChannelExtractor getChannelExtractor(ListLinkHandler linkHandler) {
69+
public ChannelExtractor getChannelExtractor(final ListLinkHandler linkHandler) {
6770
return new MediaCCCConferenceExtractor(this, linkHandler);
6871
}
6972

7073
@Override
71-
public PlaylistExtractor getPlaylistExtractor(ListLinkHandler linkHandler) {
74+
public PlaylistExtractor getPlaylistExtractor(final ListLinkHandler linkHandler) {
7275
return null;
7376
}
7477

@@ -85,9 +88,9 @@ public KioskList getKioskList() throws ExtractionException {
8588
try {
8689
list.addKioskEntry(new KioskList.KioskExtractorFactory() {
8790
@Override
88-
public KioskExtractor createNewKiosk(StreamingService streamingService,
89-
String url,
90-
String kioskId) throws ExtractionException, IOException {
91+
public KioskExtractor createNewKiosk(final StreamingService streamingService,
92+
final String url, final String kioskId)
93+
throws ExtractionException {
9194
return new MediaCCCConferenceKiosk(MediaCCCService.this,
9295
new MediaCCCConferencesListLinkHandlerFactory().fromUrl(url), kioskId);
9396
}
@@ -111,8 +114,7 @@ public ListLinkHandlerFactory getCommentsLHFactory() {
111114
}
112115

113116
@Override
114-
public CommentsExtractor getCommentsExtractor(ListLinkHandler linkHandler)
115-
throws ExtractionException {
117+
public CommentsExtractor getCommentsExtractor(final ListLinkHandler linkHandler) {
116118
return null;
117119
}
118120

extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCConferenceExtractor.java

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.grack.nanojson.JsonObject;
55
import com.grack.nanojson.JsonParser;
66
import com.grack.nanojson.JsonParserException;
7+
78
import org.schabi.newpipe.extractor.StreamingService;
89
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
910
import org.schabi.newpipe.extractor.downloader.Downloader;
@@ -14,45 +15,46 @@
1415
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
1516
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
1617

17-
import javax.annotation.Nonnull;
1818
import java.io.IOException;
1919

20-
public class MediaCCCConferenceExtractor extends ChannelExtractor {
20+
import javax.annotation.Nonnull;
2121

22+
public class MediaCCCConferenceExtractor extends ChannelExtractor {
2223
private JsonObject conferenceData;
2324

24-
public MediaCCCConferenceExtractor(StreamingService service, ListLinkHandler linkHandler) {
25+
public MediaCCCConferenceExtractor(final StreamingService service,
26+
final ListLinkHandler linkHandler) {
2527
super(service, linkHandler);
2628
}
2729

2830
@Override
29-
public String getAvatarUrl() throws ParsingException {
31+
public String getAvatarUrl() {
3032
return conferenceData.getString("logo_url");
3133
}
3234

3335
@Override
34-
public String getBannerUrl() throws ParsingException {
36+
public String getBannerUrl() {
3537
return conferenceData.getString("logo_url");
3638
}
3739

3840
@Override
39-
public String getFeedUrl() throws ParsingException {
41+
public String getFeedUrl() {
4042
return null;
4143
}
4244

4345
@Override
44-
public long getSubscriberCount() throws ParsingException {
46+
public long getSubscriberCount() {
4547
return -1;
4648
}
4749

4850
@Override
49-
public String getDescription() throws ParsingException {
51+
public String getDescription() {
5052
return null;
5153
}
5254

5355
@Nonnull
5456
@Override
55-
public InfoItemsPage<StreamInfoItem> getInitialPage() throws IOException, ExtractionException {
57+
public InfoItemsPage<StreamInfoItem> getInitialPage() {
5658
StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId());
5759
JsonArray events = conferenceData.getArray("events");
5860
for (int i = 0; i < events.size(); i++) {
@@ -62,17 +64,18 @@ public InfoItemsPage<StreamInfoItem> getInitialPage() throws IOException, Extrac
6264
}
6365

6466
@Override
65-
public String getNextPageUrl() throws IOException, ExtractionException {
67+
public String getNextPageUrl() {
6668
return null;
6769
}
6870

6971
@Override
70-
public InfoItemsPage<StreamInfoItem> getPage(String pageUrl) throws IOException, ExtractionException {
72+
public InfoItemsPage<StreamInfoItem> getPage(final String pageUrl) {
7173
return null;
7274
}
7375

7476
@Override
75-
public void onFetchPage(@Nonnull Downloader downloader) throws IOException, ExtractionException {
77+
public void onFetchPage(@Nonnull final Downloader downloader)
78+
throws IOException, ExtractionException {
7679
try {
7780
conferenceData = JsonParser.object().from(downloader.get(getUrl()).responseBody());
7881
} catch (JsonParserException jpe) {
@@ -88,7 +91,7 @@ public String getName() throws ParsingException {
8891

8992
@Nonnull
9093
@Override
91-
public String getOriginalUrl() throws ParsingException {
94+
public String getOriginalUrl() {
9295
return "https://media.ccc.de/c/" + conferenceData.getString("acronym");
9396
}
9497
}

extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCConferenceKiosk.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.grack.nanojson.JsonObject;
55
import com.grack.nanojson.JsonParser;
66
import com.grack.nanojson.JsonParserException;
7+
78
import org.schabi.newpipe.extractor.StreamingService;
89
import org.schabi.newpipe.extractor.channel.ChannelInfoItem;
910
import org.schabi.newpipe.extractor.channel.ChannelInfoItemsCollector;
@@ -14,22 +15,22 @@
1415
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
1516
import org.schabi.newpipe.extractor.services.media_ccc.extractors.infoItems.MediaCCCConferenceInfoItemExtractor;
1617

17-
import javax.annotation.Nonnull;
1818
import java.io.IOException;
1919

20-
public class MediaCCCConferenceKiosk extends KioskExtractor<ChannelInfoItem> {
20+
import javax.annotation.Nonnull;
2121

22+
public class MediaCCCConferenceKiosk extends KioskExtractor<ChannelInfoItem> {
2223
private JsonObject doc;
2324

24-
public MediaCCCConferenceKiosk(StreamingService streamingService,
25-
ListLinkHandler linkHandler,
26-
String kioskId) {
25+
public MediaCCCConferenceKiosk(final StreamingService streamingService,
26+
final ListLinkHandler linkHandler,
27+
final String kioskId) {
2728
super(streamingService, linkHandler, kioskId);
2829
}
2930

3031
@Nonnull
3132
@Override
32-
public InfoItemsPage<ChannelInfoItem> getInitialPage() throws IOException, ExtractionException {
33+
public InfoItemsPage<ChannelInfoItem> getInitialPage() {
3334
JsonArray conferences = doc.getArray("conferences");
3435
ChannelInfoItemsCollector collector = new ChannelInfoItemsCollector(getServiceId());
3536
for (int i = 0; i < conferences.size(); i++) {
@@ -40,18 +41,20 @@ public InfoItemsPage<ChannelInfoItem> getInitialPage() throws IOException, Extra
4041
}
4142

4243
@Override
43-
public String getNextPageUrl() throws IOException, ExtractionException {
44+
public String getNextPageUrl() {
4445
return "";
4546
}
4647

4748
@Override
48-
public InfoItemsPage<ChannelInfoItem> getPage(String pageUrl) throws IOException, ExtractionException {
49+
public InfoItemsPage<ChannelInfoItem> getPage(final String pageUrl) {
4950
return InfoItemsPage.emptyPage();
5051
}
5152

5253
@Override
53-
public void onFetchPage(@Nonnull Downloader downloader) throws IOException, ExtractionException {
54-
String site = downloader.get(getLinkHandler().getUrl(), getExtractorLocalization()).responseBody();
54+
public void onFetchPage(@Nonnull final Downloader downloader)
55+
throws IOException, ExtractionException {
56+
final String site = downloader.get(getLinkHandler().getUrl(), getExtractorLocalization())
57+
.responseBody();
5558
try {
5659
doc = JsonParser.object().from(site);
5760
} catch (JsonParserException jpe) {

extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCParsingHelper.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,10 @@
77
import java.util.Calendar;
88
import java.util.Date;
99

10-
public class MediaCCCParsingHelper {
11-
private MediaCCCParsingHelper() {
12-
}
10+
public final class MediaCCCParsingHelper {
11+
private MediaCCCParsingHelper() { }
1312

14-
public static Calendar parseDateFrom(String textualUploadDate) throws ParsingException {
13+
public static Calendar parseDateFrom(final String textualUploadDate) throws ParsingException {
1514
Date date;
1615
try {
1716
date = new SimpleDateFormat("yyyy-MM-dd").parse(textualUploadDate);

0 commit comments

Comments
 (0)