Skip to content

Commit e82b20c

Browse files
Merge branch 'dev_newpipe_extractor' into dev
# Conflicts: # .github/workflows/ci.yml # README.md
2 parents 30671d7 + 1ddc27c commit e82b20c

212 files changed

Lines changed: 6194 additions & 2252 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/workflows/snapshot.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Publish snapshot
2+
3+
on:
4+
push:
5+
branches:
6+
- dev
7+
workflow_dispatch:
8+
9+
jobs:
10+
build-and-deploy-docs:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v6
14+
15+
- name: set up JDK
16+
uses: actions/setup-java@v5
17+
with:
18+
java-version: 21
19+
distribution: 'temurin'
20+
21+
- name: Cache Gradle dependencies
22+
uses: actions/cache@v5
23+
with:
24+
path: ~/.gradle/caches
25+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
26+
restore-keys: ${{ runner.os }}-gradle
27+
28+
- name: Publish snapshot
29+
env:
30+
PGP_PRIVATE_SIGNING_KEY: ${{ secrets.PGP_PRIVATE_SIGNING_KEY }}
31+
PGP_PRIVATE_SIGNING_KEY_PASSWORD: ${{ secrets.PGP_PRIVATE_SIGNING_KEY_PASSWORD }}
32+
SONATYPE_MAVEN_CENTRAL_USERNAME: ${{ secrets.SONATYPE_MAVEN_CENTRAL_USERNAME }}
33+
SONATYPE_MAVEN_CENTRAL_PASSWORD: ${{ secrets.SONATYPE_MAVEN_CENTRAL_PASSWORD }}
34+
run: ./gradlew publishSnapshotPublicationToSonatypeRepository
35+
36+
- name: Upload metadata
37+
uses: actions/upload-artifact@v7
38+
with:
39+
name: NewPipeExtractor-Snapshot
40+
path: extractor/build/publications/snapshot/**

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ plugins {
1010
allprojects {
1111
apply(plugin = "java-library")
1212

13-
version = "v0.25.1"
13+
version = "v0.26.0"
1414

1515
tasks.withType<JavaCompile> {
1616
options.encoding = Charsets.UTF_8.toString()

extractor/build.gradle.kts

Lines changed: 68 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,20 @@
66
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
77
import org.gradle.api.tasks.testing.logging.TestLogEvent
88

9+
val ciSigningKey: String? = System.getenv("PGP_PRIVATE_SIGNING_KEY")
10+
val ciSigningPassword: String? = System.getenv("PGP_PRIVATE_SIGNING_KEY_PASSWORD")
11+
val shouldSignCIRelease: Boolean
12+
get() = !ciSigningKey.isNullOrEmpty() && !ciSigningPassword.isNullOrEmpty()
13+
14+
val lastCommitHash: String = providers.exec {
15+
commandLine("git", "rev-parse", "--short", "HEAD")
16+
}.standardOutput.asText.map { it.trim() }.get()
17+
918
plugins {
1019
alias(libs.plugins.google.protobuf)
1120
checkstyle
1221
`maven-publish`
22+
signing
1323
}
1424

1525
java {
@@ -112,47 +122,79 @@ protobuf {
112122
// Run "./gradlew publishReleasePublicationToLocalRepository" to generate release JARs locally
113123
publishing {
114124
publications {
125+
val mavenGroupId = "net.newpipe"
126+
val mavenArtifactId = "extractor"
127+
fun MavenPublication.setupPOM() = pom {
128+
name = "NewPipe Extractor"
129+
description = "A library for extracting data from streaming websites, used in NewPipe"
130+
url = "https://github.com/TeamNewPipe/NewPipeExtractor"
131+
132+
licenses {
133+
license {
134+
name = "GNU GENERAL PUBLIC LICENSE, Version 3"
135+
url = "https://www.gnu.org/licenses/gpl-3.0.txt"
136+
}
137+
}
138+
139+
scm {
140+
url = "https://github.com/TeamNewPipe/NewPipeExtractor"
141+
connection = "scm:git:git@github.com:TeamNewPipe/NewPipeExtractor.git"
142+
developerConnection = "scm:git:git@github.com:TeamNewPipe/NewPipeExtractor.git"
143+
}
144+
145+
developers {
146+
developer {
147+
id = "newpipe"
148+
name = "Team NewPipe"
149+
email = "team@newpipe.net"
150+
}
151+
}
152+
}
153+
115154
create<MavenPublication>("release") {
116-
groupId = "net.newpipe"
117-
artifactId = "extractor"
155+
groupId = mavenGroupId
156+
artifactId = mavenArtifactId
118157
version = rootProject.version.toString()
119158

120159
afterEvaluate {
121160
from(components["java"])
122161
}
123162

124-
pom {
125-
name = "NewPipe Extractor"
126-
description = "A library for extracting data from streaming websites, used in NewPipe"
127-
url = "https://github.com/TeamNewPipe/NewPipeExtractor"
128-
129-
licenses {
130-
license {
131-
name = "GNU GENERAL PUBLIC LICENSE, Version 3"
132-
url = "https://www.gnu.org/licenses/gpl-3.0.txt"
133-
}
134-
}
135-
136-
scm {
137-
url = "https://github.com/TeamNewPipe/NewPipeExtractor"
138-
connection = "scm:git:git@github.com:TeamNewPipe/NewPipeExtractor.git"
139-
developerConnection = "scm:git:git@github.com:TeamNewPipe/NewPipeExtractor.git"
140-
}
163+
setupPOM()
164+
}
165+
create<MavenPublication>("snapshot") {
166+
groupId = mavenGroupId
167+
artifactId = mavenArtifactId
168+
version = "$lastCommitHash-SNAPSHOT"
141169

142-
developers {
143-
developer {
144-
id = "newpipe"
145-
name = "Team NewPipe"
146-
email = "team@newpipe.net"
147-
}
148-
}
170+
afterEvaluate {
171+
from(components["java"])
149172
}
173+
174+
setupPOM()
150175
}
151176
repositories {
177+
maven {
178+
name = "sonatype"
179+
url = uri("https://central.sonatype.com/repository/maven-snapshots/")
180+
credentials {
181+
username = System.getenv("SONATYPE_MAVEN_CENTRAL_USERNAME")
182+
password = System.getenv("SONATYPE_MAVEN_CENTRAL_PASSWORD")
183+
}
184+
}
152185
maven {
153186
name = "local"
154187
url = uri(layout.buildDirectory.dir("maven"))
155188
}
156189
}
157190
}
158191
}
192+
193+
signing {
194+
useInMemoryPgpKeys(ciSigningKey, ciSigningPassword)
195+
sign(publishing.publications["snapshot"])
196+
}
197+
198+
tasks.withType<Sign> {
199+
onlyIf("Signing credentials are present (only used for maven central)") { shouldSignCIRelease }
200+
}

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import javax.annotation.Nullable;
2828
import java.util.Collections;
2929
import java.util.List;
30+
import java.util.Set;
3031

3132
/*
3233
* Copyright (C) 2018 Christian Schabesberger <chris.schabesberger@mailbox.org>
@@ -54,23 +55,23 @@ public abstract class StreamingService {
5455
public static class ServiceInfo {
5556
private final String name;
5657

57-
private final List<MediaCapability> mediaCapabilities;
58+
private final Set<MediaCapability> mediaCapabilities;
5859

5960
/**
6061
* Creates a new instance of a ServiceInfo
6162
* @param name the name of the service
6263
* @param mediaCapabilities the type of media this service can handle
6364
*/
64-
public ServiceInfo(final String name, final List<MediaCapability> mediaCapabilities) {
65+
public ServiceInfo(final String name, final Set<MediaCapability> mediaCapabilities) {
6566
this.name = name;
66-
this.mediaCapabilities = Collections.unmodifiableList(mediaCapabilities);
67+
this.mediaCapabilities = mediaCapabilities;
6768
}
6869

6970
public String getName() {
7071
return name;
7172
}
7273

73-
public List<MediaCapability> getMediaCapabilities() {
74+
public Set<MediaCapability> getMediaCapabilities() {
7475
return mediaCapabilities;
7576
}
7677

@@ -104,7 +105,7 @@ public enum LinkType {
104105
*/
105106
public StreamingService(final int id,
106107
final String name,
107-
final List<ServiceInfo.MediaCapability> capabilities) {
108+
final Set<ServiceInfo.MediaCapability> capabilities) {
108109
this.serviceId = id;
109110
this.serviceInfo = new ServiceInfo(name, capabilities);
110111
}

extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@
4747
import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor;
4848
import org.schabi.newpipe.extractor.suggestion.SuggestionExtractor;
4949

50-
import java.util.Arrays;
50+
import java.util.EnumSet;
5151

5252
public class BandcampService extends StreamingService {
5353

5454
public BandcampService(final int id) {
55-
super(id, "Bandcamp", Arrays.asList(AUDIO, COMMENTS));
55+
super(id, "Bandcamp", EnumSet.of(AUDIO, COMMENTS));
5656
}
5757

5858
@Override

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import static org.schabi.newpipe.extractor.StreamingService.ServiceInfo.MediaCapability.AUDIO;
44
import static org.schabi.newpipe.extractor.StreamingService.ServiceInfo.MediaCapability.VIDEO;
5-
import static java.util.Arrays.asList;
65

76
import org.schabi.newpipe.extractor.StreamingService;
87
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
@@ -38,9 +37,11 @@
3837
import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor;
3938
import org.schabi.newpipe.extractor.suggestion.SuggestionExtractor;
4039

40+
import java.util.EnumSet;
41+
4142
public class MediaCCCService extends StreamingService {
4243
public MediaCCCService(final int id) {
43-
super(id, "media.ccc.de", asList(AUDIO, VIDEO));
44+
super(id, "media.ccc.de", EnumSet.of(AUDIO, VIDEO));
4445
}
4546

4647
@Override

extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/PeertubeService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import static org.schabi.newpipe.extractor.StreamingService.ServiceInfo.MediaCapability.COMMENTS;
44
import static org.schabi.newpipe.extractor.StreamingService.ServiceInfo.MediaCapability.VIDEO;
5-
import static java.util.Arrays.asList;
65

76
import org.schabi.newpipe.extractor.StreamingService;
87
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
@@ -38,6 +37,7 @@
3837
import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor;
3938
import org.schabi.newpipe.extractor.suggestion.SuggestionExtractor;
4039

40+
import java.util.EnumSet;
4141
import java.util.List;
4242

4343
public class PeertubeService extends StreamingService {
@@ -49,7 +49,7 @@ public PeertubeService(final int id) {
4949
}
5050

5151
public PeertubeService(final int id, final PeertubeInstance instance) {
52-
super(id, "PeerTube", asList(VIDEO, COMMENTS));
52+
super(id, "PeerTube", EnumSet.of(VIDEO, COMMENTS));
5353
this.instance = instance;
5454
}
5555

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import static org.schabi.newpipe.extractor.StreamingService.ServiceInfo.MediaCapability.AUDIO;
44
import static org.schabi.newpipe.extractor.StreamingService.ServiceInfo.MediaCapability.COMMENTS;
5-
import static java.util.Arrays.asList;
65

76
import org.schabi.newpipe.extractor.StreamingService;
87
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
@@ -38,12 +37,13 @@
3837
import org.schabi.newpipe.extractor.stream.StreamExtractor;
3938
import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor;
4039

40+
import java.util.EnumSet;
4141
import java.util.List;
4242

4343
public class SoundcloudService extends StreamingService {
4444

4545
public SoundcloudService(final int id) {
46-
super(id, "SoundCloud", asList(AUDIO, COMMENTS));
46+
super(id, "SoundCloud", EnumSet.of(AUDIO, COMMENTS));
4747
}
4848

4949
@Override

extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/extractors/SoundcloudPlaylistExtractor.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,7 @@ public InfoItemsPage<StreamInfoItem> getInitialPage() {
149149
streamInfoItemsCollector.commit(
150150
new SoundcloudStreamInfoItemExtractor(track));
151151
} else {
152-
// %09d would be enough, but a 0 before the number does not create
153-
// problems, so let's be sure
154-
ids.add(String.format("%010d", track.getInt("id")));
152+
ids.add(String.valueOf(track.getLong("id")));
155153
}
156154
});
157155

@@ -187,15 +185,15 @@ public InfoItemsPage<StreamInfoItem> getPage(final Page page) throws IOException
187185
final JsonArray tracks = JsonParser.array().from(response);
188186
// Response may not contain tracks in the same order as currentIds.
189187
// The streams are displayed in the order which is used in currentIds on SoundCloud.
190-
final HashMap<Integer, JsonObject> idToTrack = new HashMap<>();
188+
final HashMap<Long, JsonObject> idToTrack = new HashMap<>();
191189
for (final Object track : tracks) {
192190
if (track instanceof JsonObject) {
193191
final JsonObject o = (JsonObject) track;
194-
idToTrack.put(o.getInt("id"), o);
192+
idToTrack.put(o.getLong("id"), o);
195193
}
196194
}
197195
for (final String strId : currentIds) {
198-
final int id = Integer.parseInt(strId);
196+
final long id = Long.parseLong(strId);
199197
try {
200198
collector.commit(new SoundcloudStreamInfoItemExtractor(
201199
Objects.requireNonNull(

extractor/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/extractors/SoundcloudStreamExtractor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public void onFetchPage(@Nonnull final Downloader downloader) throws IOException
7979
@Nonnull
8080
@Override
8181
public String getId() {
82-
return String.valueOf(track.getInt("id"));
82+
return String.valueOf(track.getLong("id"));
8383
}
8484

8585
@Nonnull

0 commit comments

Comments
 (0)