Skip to content

Commit 822c20d

Browse files
authored
Merge branch 'TeamNewPipe:dev' into yt_premieres-lockups-support
2 parents a910f84 + 6f51a23 commit 822c20d

1,449 files changed

Lines changed: 173243 additions & 165982 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.

build.gradle

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

11-
version 'v0.24.6'
11+
version 'v0.24.8'
1212
group 'com.github.TeamNewPipe'
1313

1414
repositories {
@@ -29,7 +29,7 @@ allprojects {
2929
ext {
3030
nanojsonVersion = "e9d656ddb49a412a5a0a5d5ef20ca7ef09549996"
3131
jsr305Version = "3.0.2"
32-
junitVersion = "5.13.3"
32+
junitVersion = "5.13.4"
3333
checkstyleVersion = "10.4"
3434
}
3535
}
@@ -68,10 +68,10 @@ subprojects {
6868

6969
// https://discuss.gradle.org/t/best-approach-gradle-multi-module-project-generate-just-one-global-javadoc/18657/21
7070
tasks.register('aggregatedJavadocs', Javadoc) {
71-
destinationDir = file("${layout.buildDirectory}/docs/javadoc")
71+
destinationDir = layout.buildDirectory.file("docs/javadoc").get().asFile
7272
title = "$project.name $version"
7373
// options.memberLevel = JavadocMemberLevel.PRIVATE
74-
options.links 'https://docs.oracle.com/javase/8/docs/api/'
74+
options.links 'https://docs.oracle.com/javase/11/docs/api/'
7575
options.encoding 'UTF-8'
7676
// Fixes unknown tag @implNote; the other two were added precautionary
7777
options.tags = [

extractor/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ checkstyleTest {
2828

2929
ext {
3030
rhinoVersion = '1.8.0'
31-
protobufVersion = '4.30.2'
31+
protobufVersion = '4.31.1'
3232
}
3333

3434
dependencies {
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package org.schabi.newpipe.extractor.exceptions;
2+
3+
/**
4+
* Exception for contents not supported in a country.
5+
*
6+
* <p>
7+
* Unsupported content means content is not intentionally geographically restricted such as for
8+
* distribution rights, for which {@link GeographicRestrictionException} should be used instead.
9+
* </p>
10+
*/
11+
public class UnsupportedContentInCountryException extends ContentNotAvailableException {
12+
13+
public UnsupportedContentInCountryException(final String message) {
14+
super(message);
15+
}
16+
17+
public UnsupportedContentInCountryException(final String message, final Throwable cause) {
18+
super(message, cause);
19+
}
20+
}

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

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -402,10 +402,9 @@ public static String getInfoItemsFromApi(final MultiInfoItemsCollector collector
402402
// `Likes` feed, so they should be handled by the correct extractor.
403403
final JsonObject likedPlaylist =
404404
searchResult.getObject("playlist", null);
405-
collector.commit(
406-
null == likedPlaylist
407-
? new SoundcloudLikesInfoItemExtractor(searchResult)
408-
: new SoundcloudPlaylistInfoItemExtractor(likedPlaylist)
405+
collector.commit(likedPlaylist == null
406+
? new SoundcloudLikesInfoItemExtractor(searchResult)
407+
: new SoundcloudPlaylistInfoItemExtractor(likedPlaylist)
409408
);
410409
break;
411410
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ public KioskList getKioskList() throws ExtractionException {
126126

127127
// add kiosks here e.g.:
128128
try {
129-
list.addKioskEntry(chartsFactory, h, "Top 50");
130129
list.addKioskEntry(chartsFactory, h, "New & hot");
131130
list.setDefaultKiosk("New & hot");
132131
} catch (final Exception e) {
Lines changed: 42 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package org.schabi.newpipe.extractor.services.soundcloud.extractors;
22

3+
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
4+
import static org.schabi.newpipe.extractor.services.soundcloud.SoundcloudParsingHelper.SOUNDCLOUD_API_V2_URL;
5+
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
6+
37
import org.schabi.newpipe.extractor.Page;
48
import org.schabi.newpipe.extractor.StreamingService;
59
import org.schabi.newpipe.extractor.downloader.Downloader;
@@ -11,22 +15,54 @@
1115
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
1216
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
1317

14-
import javax.annotation.Nonnull;
1518
import java.io.IOException;
1619

17-
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
18-
import static org.schabi.newpipe.extractor.services.soundcloud.SoundcloudParsingHelper.SOUNDCLOUD_API_V2_URL;
19-
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
20+
import javax.annotation.Nonnull;
2021

2122
public class SoundcloudChartsExtractor extends KioskExtractor<StreamInfoItem> {
23+
24+
private String initialFetchNextPageUrl;
25+
private StreamInfoItemsCollector initialFetchCollector;
26+
2227
public SoundcloudChartsExtractor(final StreamingService service,
2328
final ListLinkHandler linkHandler,
2429
final String kioskId) {
2530
super(service, linkHandler, kioskId);
2631
}
2732

2833
@Override
29-
public void onFetchPage(@Nonnull final Downloader downloader) {
34+
public void onFetchPage(@Nonnull final Downloader downloader)
35+
throws ExtractionException, IOException {
36+
// Check if already run
37+
if (initialFetchNextPageUrl != null) {
38+
return;
39+
}
40+
41+
initialFetchCollector = new StreamInfoItemsCollector(getServiceId());
42+
43+
final String apiUrl = SOUNDCLOUD_API_V2_URL + "charts"
44+
+ "?genre=soundcloud:genres:all-music"
45+
+ "&client_id=" + SoundcloudParsingHelper.clientId()
46+
+ "&kind=trending";
47+
48+
final ContentCountry contentCountry = SoundCloud.getContentCountry();
49+
String apiUrlWithRegion = null;
50+
if (getService().getSupportedCountries().contains(contentCountry)) {
51+
apiUrlWithRegion = apiUrl + "&region=soundcloud:regions:"
52+
+ contentCountry.getCountryCode();
53+
}
54+
55+
try {
56+
initialFetchNextPageUrl = SoundcloudParsingHelper.getStreamsFromApi(
57+
initialFetchCollector,
58+
apiUrlWithRegion == null ? apiUrl : apiUrlWithRegion, true);
59+
} catch (final IOException e) {
60+
// Request to other region may be geo-restricted.
61+
// See https://github.com/TeamNewPipe/NewPipeExtractor/issues/537.
62+
// We retry without the specified region.
63+
initialFetchNextPageUrl = SoundcloudParsingHelper.getStreamsFromApi(
64+
initialFetchCollector, apiUrl, true);
65+
}
3066
}
3167

3268
@Nonnull
@@ -52,35 +88,6 @@ public InfoItemsPage<StreamInfoItem> getPage(final Page page) throws IOException
5288
@Nonnull
5389
@Override
5490
public InfoItemsPage<StreamInfoItem> getInitialPage() throws IOException, ExtractionException {
55-
final StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId());
56-
57-
String apiUrl = SOUNDCLOUD_API_V2_URL + "charts" + "?genre=soundcloud:genres:all-music"
58-
+ "&client_id=" + SoundcloudParsingHelper.clientId();
59-
60-
if (getId().equals("Top 50")) {
61-
apiUrl += "&kind=top";
62-
} else {
63-
apiUrl += "&kind=trending";
64-
}
65-
66-
final ContentCountry contentCountry = SoundCloud.getContentCountry();
67-
String apiUrlWithRegion = null;
68-
if (getService().getSupportedCountries().contains(contentCountry)) {
69-
apiUrlWithRegion = apiUrl + "&region=soundcloud:regions:"
70-
+ contentCountry.getCountryCode();
71-
}
72-
73-
String nextPageUrl;
74-
try {
75-
nextPageUrl = SoundcloudParsingHelper.getStreamsFromApi(collector,
76-
apiUrlWithRegion == null ? apiUrl : apiUrlWithRegion, true);
77-
} catch (final IOException e) {
78-
// Request to other region may be geo-restricted.
79-
// See https://github.com/TeamNewPipe/NewPipeExtractor/issues/537.
80-
// We retry without the specified region.
81-
nextPageUrl = SoundcloudParsingHelper.getStreamsFromApi(collector, apiUrl, true);
82-
}
83-
84-
return new InfoItemsPage<>(collector, new Page(nextPageUrl));
91+
return new InfoItemsPage<>(initialFetchCollector, new Page(initialFetchNextPageUrl));
8592
}
8693
}

extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/linkHandler/SoundcloudChartsLinkHandlerFactory.java

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ public final class SoundcloudChartsLinkHandlerFactory extends ListLinkHandlerFac
1111
private static final SoundcloudChartsLinkHandlerFactory INSTANCE =
1212
new SoundcloudChartsLinkHandlerFactory();
1313

14-
private static final String TOP_URL_PATTERN =
15-
"^https?://(www\\.|m\\.)?soundcloud.com/charts(/top)?/?([#?].*)?$";
1614
private static final String URL_PATTERN =
1715
"^https?://(www\\.|m\\.)?soundcloud.com/charts(/top|/new)?/?([#?].*)?$";
1816

@@ -25,23 +23,15 @@ public static SoundcloudChartsLinkHandlerFactory getInstance() {
2523

2624
@Override
2725
public String getId(final String url) throws ParsingException, UnsupportedOperationException {
28-
if (Parser.isMatch(TOP_URL_PATTERN, url.toLowerCase())) {
29-
return "Top 50";
30-
} else {
31-
return "New & hot";
32-
}
26+
return "New & hot";
3327
}
3428

3529
@Override
3630
public String getUrl(final String id,
3731
final List<String> contentFilter,
3832
final String sortFilter)
3933
throws ParsingException, UnsupportedOperationException {
40-
if (id.equals("Top 50")) {
41-
return "https://soundcloud.com/charts/top";
42-
} else {
43-
return "https://soundcloud.com/charts/new";
44-
}
34+
return "https://soundcloud.com/charts/new";
4535
}
4636

4737
@Override

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ private ClientsConstants() {
4545
static final String WEB_EMBEDDED_CLIENT_NAME = "WEB_EMBEDDED_PLAYER";
4646
static final String WEB_EMBEDDED_CLIENT_VERSION = "1.20250121.00.00";
4747

48+
// WEB_MUSIC_ANALYTICS (YouTube charts)
49+
50+
static final String WEB_MUSIC_ANALYTICS_CLIENT_ID = "31";
51+
static final String WEB_MUSIC_ANALYTICS_CLIENT_NAME = "WEB_MUSIC_ANALYTICS";
52+
static final String WEB_MUSIC_ANALYTICS_CLIENT_VERSION = "2.0";
53+
4854
// IOS (iOS YouTube app) client fields
4955

5056
static final String IOS_CLIENT_ID = "5";

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

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package org.schabi.newpipe.extractor.services.youtube;
22

3+
import javax.annotation.Nonnull;
4+
import javax.annotation.Nullable;
5+
36
import static org.schabi.newpipe.extractor.services.youtube.ClientsConstants.ANDROID_CLIENT_ID;
47
import static org.schabi.newpipe.extractor.services.youtube.ClientsConstants.ANDROID_CLIENT_NAME;
58
import static org.schabi.newpipe.extractor.services.youtube.ClientsConstants.ANDROID_CLIENT_VERSION;
@@ -16,11 +19,11 @@
1619
import static org.schabi.newpipe.extractor.services.youtube.ClientsConstants.WEB_CLIENT_NAME;
1720
import static org.schabi.newpipe.extractor.services.youtube.ClientsConstants.WEB_EMBEDDED_CLIENT_ID;
1821
import static org.schabi.newpipe.extractor.services.youtube.ClientsConstants.WEB_EMBEDDED_CLIENT_NAME;
22+
import static org.schabi.newpipe.extractor.services.youtube.ClientsConstants.WEB_EMBEDDED_CLIENT_VERSION;
1923
import static org.schabi.newpipe.extractor.services.youtube.ClientsConstants.WEB_HARDCODED_CLIENT_VERSION;
20-
import static org.schabi.newpipe.extractor.services.youtube.ClientsConstants.WEB_REMIX_HARDCODED_CLIENT_VERSION;
21-
22-
import javax.annotation.Nonnull;
23-
import javax.annotation.Nullable;
24+
import static org.schabi.newpipe.extractor.services.youtube.ClientsConstants.WEB_MUSIC_ANALYTICS_CLIENT_ID;
25+
import static org.schabi.newpipe.extractor.services.youtube.ClientsConstants.WEB_MUSIC_ANALYTICS_CLIENT_NAME;
26+
import static org.schabi.newpipe.extractor.services.youtube.ClientsConstants.WEB_MUSIC_ANALYTICS_CLIENT_VERSION;
2427

2528
// TODO: add docs
2629

@@ -38,28 +41,28 @@ public static final class ClientInfo {
3841
@Nonnull
3942
public String clientVersion;
4043
@Nonnull
41-
public String clientScreen;
42-
@Nullable
4344
public String clientId;
4445
@Nullable
46+
public String clientScreen;
47+
@Nullable
4548
public String visitorData;
4649

4750
private ClientInfo(@Nonnull final String clientName,
4851
@Nonnull final String clientVersion,
49-
@Nonnull final String clientScreen,
50-
@Nullable final String clientId,
52+
@Nonnull final String clientId,
53+
@Nullable final String clientScreen,
5154
@Nullable final String visitorData) {
5255
this.clientName = clientName;
5356
this.clientVersion = clientVersion;
54-
this.clientScreen = clientScreen;
5557
this.clientId = clientId;
58+
this.clientScreen = clientScreen;
5659
this.visitorData = visitorData;
5760
}
5861
}
5962

6063
public static final class DeviceInfo {
6164

62-
@Nonnull
65+
@Nullable
6366
public String platform;
6467
@Nullable
6568
public String deviceMake;
@@ -71,7 +74,7 @@ public static final class DeviceInfo {
7174
public String osVersion;
7275
public int androidSdkVersion;
7376

74-
private DeviceInfo(@Nonnull final String platform,
77+
private DeviceInfo(@Nullable final String platform,
7578
@Nullable final String deviceMake,
7679
@Nullable final String deviceModel,
7780
@Nullable final String osName,
@@ -96,8 +99,8 @@ private InnertubeClientRequestInfo(@Nonnull final ClientInfo clientInfo,
9699
public static InnertubeClientRequestInfo ofWebClient() {
97100
return new InnertubeClientRequestInfo(
98101
new InnertubeClientRequestInfo.ClientInfo(
99-
WEB_CLIENT_NAME, WEB_HARDCODED_CLIENT_VERSION, WATCH_CLIENT_SCREEN,
100-
WEB_CLIENT_ID, null),
102+
WEB_CLIENT_NAME, WEB_HARDCODED_CLIENT_VERSION, WEB_CLIENT_ID,
103+
WATCH_CLIENT_SCREEN, null),
101104
new InnertubeClientRequestInfo.DeviceInfo(DESKTOP_CLIENT_PLATFORM, null, null,
102105
null, null, -1));
103106
}
@@ -106,17 +109,27 @@ public static InnertubeClientRequestInfo ofWebClient() {
106109
public static InnertubeClientRequestInfo ofWebEmbeddedPlayerClient() {
107110
return new InnertubeClientRequestInfo(
108111
new InnertubeClientRequestInfo.ClientInfo(WEB_EMBEDDED_CLIENT_NAME,
109-
WEB_REMIX_HARDCODED_CLIENT_VERSION, EMBED_CLIENT_SCREEN,
110-
WEB_EMBEDDED_CLIENT_ID, null),
112+
WEB_EMBEDDED_CLIENT_VERSION, WEB_EMBEDDED_CLIENT_ID, EMBED_CLIENT_SCREEN,
113+
null),
111114
new InnertubeClientRequestInfo.DeviceInfo(DESKTOP_CLIENT_PLATFORM, null, null,
112115
null, null, -1));
113116
}
114117

118+
@Nonnull
119+
public static InnertubeClientRequestInfo ofWebMusicAnalyticsChartsClient() {
120+
return new InnertubeClientRequestInfo(
121+
new InnertubeClientRequestInfo.ClientInfo(WEB_MUSIC_ANALYTICS_CLIENT_NAME,
122+
WEB_MUSIC_ANALYTICS_CLIENT_VERSION, WEB_MUSIC_ANALYTICS_CLIENT_ID, null,
123+
null),
124+
new InnertubeClientRequestInfo.DeviceInfo(null, null, null,
125+
null, null, -1));
126+
}
127+
115128
@Nonnull
116129
public static InnertubeClientRequestInfo ofAndroidClient() {
117130
return new InnertubeClientRequestInfo(
118131
new InnertubeClientRequestInfo.ClientInfo(ANDROID_CLIENT_NAME,
119-
ANDROID_CLIENT_VERSION, WATCH_CLIENT_SCREEN, ANDROID_CLIENT_ID, null),
132+
ANDROID_CLIENT_VERSION, ANDROID_CLIENT_ID, WATCH_CLIENT_SCREEN, null),
120133
new InnertubeClientRequestInfo.DeviceInfo(MOBILE_CLIENT_PLATFORM, null, null,
121134
"Android", "15", 35));
122135
}
@@ -125,7 +138,7 @@ public static InnertubeClientRequestInfo ofAndroidClient() {
125138
public static InnertubeClientRequestInfo ofIosClient() {
126139
return new InnertubeClientRequestInfo(
127140
new InnertubeClientRequestInfo.ClientInfo(IOS_CLIENT_NAME, IOS_CLIENT_VERSION,
128-
WATCH_CLIENT_SCREEN, IOS_CLIENT_ID, null),
141+
IOS_CLIENT_ID, WATCH_CLIENT_SCREEN, null),
129142
new InnertubeClientRequestInfo.DeviceInfo(MOBILE_CLIENT_PLATFORM, "Apple",
130143
IOS_DEVICE_MODEL, "iOS", IOS_OS_VERSION, -1));
131144
}

0 commit comments

Comments
 (0)