Skip to content

Commit 7484b6a

Browse files
authored
Merge pull request #758 from litetex/release/v0.21.12
Release 0.21.12
2 parents 0b0c39a + 795e6df commit 7484b6a

File tree

51 files changed

+1950
-442
lines changed

Some content is hidden

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

51 files changed

+1950
-442
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ 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 `implementation 'com.github.TeamNewPipe:NewPipeExtractor:v0.21.11'`the `dependencies` in your `build.gradle`. Replace `v0.21.11` with the latest release.
14+
2. Add `implementation 'com.github.TeamNewPipe:NewPipeExtractor:INSERT_VERSION_HERE'` to the `dependencies` in your `build.gradle`. Replace `INSERT_VERSION_HERE` with the [latest release](https://github.com/TeamNewPipe/NewPipeExtractor/releases/latest).
1515

1616
**Note:** To use NewPipe Extractor in projects with a `minSdkVersion` below 26, [API desugaring](https://developer.android.com/studio/write/java8-support#library-desugaring) is required.
1717

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ allprojects {
88
sourceCompatibility = 1.8
99
targetCompatibility = 1.8
1010

11-
version 'v0.21.11'
11+
version 'v0.21.12'
1212
group 'com.github.TeamNewPipe'
1313

1414
repositories {
@@ -28,7 +28,7 @@ allprojects {
2828

2929
ext {
3030
nanojsonVersion = "1d9e1aea9049fc9f85e68b43ba39fe7be1c1f751"
31-
spotbugsVersion = "4.4.1"
31+
spotbugsVersion = "4.5.0"
3232
junitVersion = "4.13.2"
3333
}
3434
}

extractor/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ dependencies {
1616

1717
testImplementation "junit:junit:$junitVersion"
1818
testImplementation "com.squareup.okhttp3:okhttp:3.12.13"
19-
testImplementation 'com.google.code.gson:gson:2.8.8'
19+
testImplementation 'com.google.code.gson:gson:2.8.9'
2020
}

extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfo.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ public static CommentsInfo getInfo(final String url) throws IOException, Extract
2424
return getInfo(NewPipe.getServiceByUrl(url), url);
2525
}
2626

27-
public static CommentsInfo getInfo(final StreamingService serviceByUrl, final String url)
27+
public static CommentsInfo getInfo(final StreamingService service, final String url)
2828
throws ExtractionException, IOException {
29-
return getInfo(serviceByUrl.getCommentsExtractor(url));
29+
return getInfo(service.getCommentsExtractor(url));
3030
}
3131

3232
public static CommentsInfo getInfo(final CommentsExtractor commentsExtractor)
@@ -63,7 +63,7 @@ public static InfoItemsPage<CommentsInfoItem> getMoreItems(
6363
final StreamingService service,
6464
final CommentsInfo commentsInfo,
6565
final Page page) throws IOException, ExtractionException {
66-
if (null == commentsInfo.getCommentsExtractor()) {
66+
if (commentsInfo.getCommentsExtractor() == null) {
6767
commentsInfo.setCommentsExtractor(service.getCommentsExtractor(commentsInfo.getUrl()));
6868
commentsInfo.getCommentsExtractor().fetchPage();
6969
}

extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/linkHandler/PeertubeChannelLinkHandlerFactory.java

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
public class PeertubeChannelLinkHandlerFactory extends ListLinkHandlerFactory {
1111

1212
private static final PeertubeChannelLinkHandlerFactory instance = new PeertubeChannelLinkHandlerFactory();
13-
private static final String ID_PATTERN = "(accounts|video-channels)/([^/?&#]*)";
13+
private static final String ID_PATTERN = "((accounts|a)|(video-channels|c))/([^/?&#]*)";
1414
public static final String API_ENDPOINT = "/api/v1/";
1515

1616
public static PeertubeChannelLinkHandlerFactory getInstance() {
@@ -19,7 +19,7 @@ public static PeertubeChannelLinkHandlerFactory getInstance() {
1919

2020
@Override
2121
public String getId(String url) throws ParsingException {
22-
return Parser.matchGroup(ID_PATTERN, url, 0);
22+
return fixId(Parser.matchGroup(ID_PATTERN, url, 0));
2323
}
2424

2525
@Override
@@ -31,7 +31,7 @@ public String getUrl(String id, List<String> contentFilters, String searchFilter
3131
public String getUrl(String id, List<String> contentFilter, String sortFilter, String baseUrl)
3232
throws ParsingException {
3333
if (id.matches(ID_PATTERN)) {
34-
return baseUrl + "/" + id;
34+
return baseUrl + "/" + fixId(id);
3535
} else {
3636
// This is needed for compatibility with older versions were we didn't support video channels yet
3737
return baseUrl + "/accounts/" + id;
@@ -40,6 +40,28 @@ public String getUrl(String id, List<String> contentFilter, String sortFilter, S
4040

4141
@Override
4242
public boolean onAcceptUrl(String url) {
43-
return url.contains("/accounts/") || url.contains("/video-channels/");
43+
return url.contains("/accounts/") || url.contains("/a/")
44+
|| url.contains("/video-channels/") || url.contains("/c/");
45+
}
46+
47+
/**
48+
* Fix id
49+
*
50+
* <p>
51+
* a/:accountName and c/:channelName ids are supported
52+
* by the PeerTube web client (>= v3.3.0)
53+
* but not by the API.
54+
* </p>
55+
*
56+
* @param id the id to fix
57+
* @return the fixed id
58+
*/
59+
private String fixId(String id) {
60+
if (id.startsWith("a/")) {
61+
id = "accounts" + id.substring(1);
62+
} else if (id.startsWith("c/")) {
63+
id = "video-channels" + id.substring(1);
64+
}
65+
return id;
4466
}
4567
}

extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/linkHandler/PeertubeCommentsLinkHandlerFactory.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
public class PeertubeCommentsLinkHandlerFactory extends ListLinkHandlerFactory {
1212

1313
private static final PeertubeCommentsLinkHandlerFactory instance = new PeertubeCommentsLinkHandlerFactory();
14-
private static final String ID_PATTERN = "/videos/(watch/)?([^/?&#]*)";
1514
private static final String COMMENTS_ENDPOINT = "/api/v1/videos/%s/comment-threads";
1615

1716
public static PeertubeCommentsLinkHandlerFactory getInstance() {
@@ -20,12 +19,12 @@ public static PeertubeCommentsLinkHandlerFactory getInstance() {
2019

2120
@Override
2221
public String getId(String url) throws ParsingException, IllegalArgumentException {
23-
return Parser.matchGroup(ID_PATTERN, url, 2);
22+
return PeertubeStreamLinkHandlerFactory.getInstance().getId(url); // the same id is needed
2423
}
2524

2625
@Override
2726
public boolean onAcceptUrl(final String url) throws FoundAdException {
28-
return url.contains("/videos/");
27+
return url.contains("/videos/") || url.contains("/w/");
2928
}
3029

3130
@Override

extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/linkHandler/PeertubePlaylistLinkHandlerFactory.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
public class PeertubePlaylistLinkHandlerFactory extends ListLinkHandlerFactory {
1212

1313
private static final PeertubePlaylistLinkHandlerFactory instance = new PeertubePlaylistLinkHandlerFactory();
14-
private static final String ID_PATTERN = "/videos/watch/playlist/([^/?&#]*)";
14+
private static final String ID_PATTERN = "(/videos/watch/playlist/|/w/p/)([^/?&#]*)";
1515

1616
public static PeertubePlaylistLinkHandlerFactory getInstance() {
1717
return instance;
@@ -30,7 +30,7 @@ public String getUrl(String id, List<String> contentFilters, String sortFilter,
3030

3131
@Override
3232
public String getId(String url) throws ParsingException {
33-
return Parser.matchGroup1(ID_PATTERN, url);
33+
return Parser.matchGroup(ID_PATTERN, url, 2);
3434
}
3535

3636
@Override

extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/linkHandler/PeertubeStreamLinkHandlerFactory.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,13 @@
99
public class PeertubeStreamLinkHandlerFactory extends LinkHandlerFactory {
1010

1111
private static final PeertubeStreamLinkHandlerFactory instance = new PeertubeStreamLinkHandlerFactory();
12-
private static final String ID_PATTERN = "/videos/(watch/|embed/)?([^/?&#]*)";
12+
private static final String ID_PATTERN = "(/w/|(/videos/(watch/|embed/)?))(?!p/)([^/?&#]*)";
13+
// we exclude p/ because /w/p/ is playlist, not video
1314
public static final String VIDEO_API_ENDPOINT = "/api/v1/videos/";
15+
16+
// From PeerTube 3.3.0, the default path is /w/.
17+
// We still use /videos/watch/ for compatibility reasons:
18+
// /videos/watch/ is still accepted by >=3.3.0 but /w/ isn't by <3.3.0
1419
private static final String VIDEO_PATH = "/videos/watch/";
1520

1621
private PeertubeStreamLinkHandlerFactory() {
@@ -32,7 +37,7 @@ public String getUrl(String id, String baseUrl) {
3237

3338
@Override
3439
public String getId(String url) throws ParsingException, IllegalArgumentException {
35-
return Parser.matchGroup(ID_PATTERN, url, 2);
40+
return Parser.matchGroup(ID_PATTERN, url, 4);
3641
}
3742

3843
@Override

extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudParsingHelper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040
import static org.schabi.newpipe.extractor.utils.Utils.*;
4141

4242
public class SoundcloudParsingHelper {
43-
private static final String HARDCODED_CLIENT_ID =
44-
"yoxLvaFlJ3V5LbNCt53Cwvw5KXKKxWfn"; // Updated on 01/10/21
43+
static final String HARDCODED_CLIENT_ID =
44+
"1NKODbzHzEpoowFHxTAmS7oB08DObPuK"; // Updated on 08/12/21
4545
private static String clientId;
4646
public static final String SOUNDCLOUD_API_V2_URL = "https://api-v2.soundcloud.com/";
4747

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelper.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,10 @@ public static boolean isInvidioURL(@Nonnull final URL url) {
162162
|| host.equalsIgnoreCase("y.com.cm");
163163
}
164164

165+
public static boolean isY2ubeURL(@Nonnull final URL url) {
166+
return url.getHost().equalsIgnoreCase("y2u.be");
167+
}
168+
165169
/**
166170
* Parses the duration string of the video expecting ":" or "." as separators
167171
*

0 commit comments

Comments
 (0)