Skip to content

Commit 8e84c9a

Browse files
committed
Merge branch 'master_tubular'
2 parents d39fc43 + 4faa566 commit 8e84c9a

20 files changed

+512
-180
lines changed

.github/PULL_REQUEST_TEMPLATE.md

-3
This file was deleted.

.github/dependabot.yml

-12
This file was deleted.

.github/workflows/ci.yml

-51
This file was deleted.

.github/workflows/docs.yml

-38
This file was deleted.

README.md

+3-63
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,5 @@
1-
# NewPipe Extractor
2-
3-
[![CI](https://github.com/TeamNewPipe/NewPipeExtractor/actions/workflows/ci.yml/badge.svg?branch=dev&event=schedule)](https://github.com/TeamNewPipe/NewPipeExtractor/actions/workflows/ci.yml) [![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/)
4-
5-
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.
6-
7-
## Usage
8-
9-
NewPipe Extractor is available at JitPack's Maven repo.
10-
11-
If you're using Gradle, you could add NewPipe Extractor as a dependency with the following steps:
12-
13-
1. Add `maven { url 'https://jitpack.io' }` to the `repositories` in your `build.gradle`.
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).
15-
3. If you are using tools to minimize your project, make sure to keep the files below, by e.g. adding the following lines to your proguard file:
16-
```
17-
## Rules for NewPipeExtractor
18-
-keep class org.schabi.newpipe.extractor.timeago.patterns.** { *; }
19-
-keep class org.mozilla.javascript.** { *; }
20-
-keep class org.mozilla.classfile.ClassFileWriter
21-
-dontwarn org.mozilla.javascript.tools.**
22-
```
23-
24-
**Note:** To use NewPipe Extractor in Android projects with a `minSdk` below 26, [API desugaring](https://developer.android.com/studio/write/java8-support#library-desugaring) is required. If the `minSdk` is below 19, the `desugar_jdk_libs_nio` artifact is required, which requires Android Gradle Plugin (AGP) version 7.4.0.
25-
26-
### Testing changes
27-
28-
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`:
29-
30-
```groovy
31-
includeBuild('../NewPipeExtractor') {
32-
dependencySubstitution {
33-
substitute module('com.github.TeamNewPipe:NewPipeExtractor') with project(':extractor')
34-
}
35-
}
36-
```
37-
38-
Another approach would be to use the local Maven repository, here's a gist of how to use it:
39-
40-
1. Add `mavenLocal()` in your project `repositories` list (usually as the first entry to give priority above the others).
41-
2. It's _recommended_ that you change the `version` of this library (e.g. `LOCAL_SNAPSHOT`).
42-
3. Run gradle's `ìnstall` task to deploy this library to your local repository (using the wrapper, present in the root of this project: `./gradlew install`)
43-
4. Change the dependency version used in your project to match the one you chose in step 2 (`implementation 'com.github.TeamNewPipe:NewPipeExtractor:LOCAL_SNAPSHOT'`)
44-
45-
> Tip for Android Studio users: After you make changes and run the `install` task, use the menu option `File → "Sync with File System"` to refresh the library in your project.
46-
47-
## Supported sites
48-
49-
The following sites are currently supported:
50-
51-
- YouTube
52-
- SoundCloud
53-
- media.ccc.de
54-
- PeerTube (no P2P)
55-
- Bandcamp
1+
<h1 align="center"><b>Tubular Extractor</b></h2>
2+
<h4 align="center">A fork of <a href="https://github.com/TeamNewPipe/NewPipeExtractor/">NewPipeExtractor</a>, a library for extracting things from streaming sites. It is a core component of <a href="https://github.com/polymorphicshade/Tubular">Tubular</a>, but could be used independently.
563

574
## License
58-
59-
[![GNU GPLv3 Image](https://www.gnu.org/graphics/gplv3-127x51.png)](https://www.gnu.org/licenses/gpl-3.0.en.html)
60-
61-
NewPipe Extractor is Free Software: You can use, study share and improve it at your
62-
will. Specifically you can redistribute and/or modify it under the terms of the
63-
[GNU General Public License](https://www.gnu.org/licenses/gpl.html) as
64-
published by the Free Software Foundation, either version 3 of the License, or
65-
(at your option) any later version.
5+
[![GNU GPLv3](https://www.gnu.org/graphics/gplv3-127x51.png)](https://www.gnu.org/licenses/gpl-3.0.en.html)

build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ allprojects {
2828

2929
ext {
3030
nanojsonVersion = "1d9e1aea9049fc9f85e68b43ba39fe7be1c1f751"
31-
spotbugsVersion = "4.8.3"
32-
junitVersion = "5.10.2"
31+
spotbugsVersion = "4.8.6"
32+
junitVersion = "5.10.3"
3333
checkstyleVersion = "10.4"
3434
}
3535
}

extractor/build.gradle

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ dependencies {
3131

3232
// do not upgrade to 1.7.14, since in 1.7.14 Rhino uses the `SourceVersion` class, which is not
3333
// available on Android (even when using desugaring), and `NoClassDefFoundError` is thrown
34-
implementation 'org.mozilla:rhino:1.7.13'
34+
implementation 'org.mozilla:rhino:1.7.15'
3535

3636
checkstyle "com.puppycrawl.tools:checkstyle:$checkstyleVersion"
3737

@@ -41,5 +41,5 @@ dependencies {
4141
testImplementation 'org.junit.jupiter:junit-jupiter-params'
4242

4343
testImplementation "com.squareup.okhttp3:okhttp:3.12.13"
44-
testImplementation 'com.google.code.gson:gson:2.10.1'
44+
testImplementation 'com.google.code.gson:gson:2.11.0'
4545
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package org.schabi.newpipe.extractor.returnyoutubedislike;
2+
3+
public class ReturnYouTubeDislikeApiSettings {
4+
public String apiUrl;
5+
6+
// TODO: add more if needed
7+
//
8+
//
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package org.schabi.newpipe.extractor.returnyoutubedislike;
2+
3+
import com.grack.nanojson.JsonObject;
4+
import com.grack.nanojson.JsonParser;
5+
import com.grack.nanojson.JsonParserException;
6+
7+
import org.schabi.newpipe.extractor.NewPipe;
8+
import org.schabi.newpipe.extractor.exceptions.ReCaptchaException;
9+
import org.schabi.newpipe.extractor.stream.StreamInfo;
10+
11+
import java.io.IOException;
12+
13+
public final class ReturnYouTubeDislikeExtractorHelper {
14+
15+
private ReturnYouTubeDislikeExtractorHelper() {
16+
}
17+
18+
@SuppressWarnings("CheckStyle")
19+
public static ReturnYouTubeDislikeInfo getInfo(
20+
final StreamInfo streamInfo,
21+
final ReturnYouTubeDislikeApiSettings apiSettings) {
22+
if (!streamInfo.getUrl().startsWith("https://www.youtube.com")
23+
|| apiSettings.apiUrl == null
24+
|| apiSettings.apiUrl.isEmpty()) {
25+
return null;
26+
}
27+
28+
final String url = apiSettings.apiUrl + "votes?videoId=" + streamInfo.getId();
29+
30+
JsonObject response = null;
31+
32+
try {
33+
final String responseBody =
34+
NewPipe.getDownloader().get(url).responseBody();
35+
36+
response = JsonParser.object().from(responseBody);
37+
} catch (ReCaptchaException | IOException | JsonParserException e) {
38+
// ignored
39+
}
40+
41+
if (response == null) {
42+
return null;
43+
}
44+
45+
final int likes = response.getInt("likes", 0);
46+
final int dislikes = response.getInt("dislikes", 0);
47+
final double rating = response.getDouble("rating", 0);
48+
final int viewCount = response.getInt("viewCount", 0);
49+
final boolean deleted = response.getBoolean("deleted", false);
50+
51+
return new ReturnYouTubeDislikeInfo(likes, dislikes, rating, viewCount, deleted);
52+
}
53+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package org.schabi.newpipe.extractor.returnyoutubedislike;
2+
3+
import java.io.Serializable;
4+
5+
public class ReturnYouTubeDislikeInfo implements Serializable {
6+
public long likes;
7+
public long dislikes;
8+
public double rating;
9+
public long viewCount;
10+
public boolean deleted;
11+
12+
public ReturnYouTubeDislikeInfo(final long likes, final long dislikes, final double rating,
13+
final long viewCount, final boolean deleted) {
14+
this.likes = likes;
15+
this.dislikes = dislikes;
16+
this.rating = rating;
17+
this.viewCount = viewCount;
18+
this.deleted = deleted;
19+
}
20+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package org.schabi.newpipe.extractor.sponsorblock;
2+
3+
public enum SponsorBlockAction {
4+
SKIP("skip"),
5+
POI("poi");
6+
7+
private final String apiName;
8+
9+
SponsorBlockAction(final String apiName) {
10+
this.apiName = apiName;
11+
}
12+
13+
public static SponsorBlockAction fromApiName(final String apiName) {
14+
switch (apiName) {
15+
case "skip":
16+
return SponsorBlockAction.SKIP;
17+
case "poi":
18+
return SponsorBlockAction.POI;
19+
default:
20+
throw new IllegalArgumentException("Invalid API name");
21+
}
22+
}
23+
24+
public String getApiName() {
25+
return apiName;
26+
}
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package org.schabi.newpipe.extractor.sponsorblock;
2+
3+
public class SponsorBlockApiSettings {
4+
public String apiUrl;
5+
public boolean includeSponsorCategory;
6+
public boolean includeIntroCategory;
7+
public boolean includeOutroCategory;
8+
public boolean includeInteractionCategory;
9+
public boolean includeHighlightCategory;
10+
public boolean includeSelfPromoCategory;
11+
public boolean includeMusicCategory;
12+
public boolean includePreviewCategory;
13+
public boolean includeFillerCategory;
14+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package org.schabi.newpipe.extractor.sponsorblock;
2+
3+
public enum SponsorBlockCategory {
4+
SPONSOR("sponsor"),
5+
INTRO("intro"),
6+
OUTRO("outro"),
7+
INTERACTION("interaction"),
8+
HIGHLIGHT("poi_highlight"),
9+
SELF_PROMO("selfpromo"),
10+
NON_MUSIC("music_offtopic"),
11+
PREVIEW("preview"),
12+
FILLER("filler"),
13+
PENDING("pending");
14+
15+
private final String apiName;
16+
17+
SponsorBlockCategory(final String apiName) {
18+
this.apiName = apiName;
19+
}
20+
21+
public static SponsorBlockCategory fromApiName(final String apiName) {
22+
switch (apiName) {
23+
case "sponsor":
24+
return SponsorBlockCategory.SPONSOR;
25+
case "intro":
26+
return SponsorBlockCategory.INTRO;
27+
case "outro":
28+
return SponsorBlockCategory.OUTRO;
29+
case "interaction":
30+
return SponsorBlockCategory.INTERACTION;
31+
case "poi_highlight":
32+
return SponsorBlockCategory.HIGHLIGHT;
33+
case "selfpromo":
34+
return SponsorBlockCategory.SELF_PROMO;
35+
case "music_offtopic":
36+
return SponsorBlockCategory.NON_MUSIC;
37+
case "preview":
38+
return SponsorBlockCategory.PREVIEW;
39+
case "filler":
40+
return SponsorBlockCategory.FILLER;
41+
default:
42+
throw new IllegalArgumentException("Invalid API name");
43+
}
44+
}
45+
46+
public String getApiName() {
47+
return apiName;
48+
}
49+
}

0 commit comments

Comments
 (0)