Skip to content

Commit

Permalink
Merge branch 'master_tubular'
Browse files Browse the repository at this point in the history
  • Loading branch information
asandikci committed Jul 26, 2024
2 parents d39fc43 + 4faa566 commit 8e84c9a
Show file tree
Hide file tree
Showing 20 changed files with 512 additions and 180 deletions.
3 changes: 0 additions & 3 deletions .github/PULL_REQUEST_TEMPLATE.md

This file was deleted.

12 changes: 0 additions & 12 deletions .github/dependabot.yml

This file was deleted.

51 changes: 0 additions & 51 deletions .github/workflows/ci.yml

This file was deleted.

38 changes: 0 additions & 38 deletions .github/workflows/docs.yml

This file was deleted.

66 changes: 3 additions & 63 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,65 +1,5 @@
# NewPipe Extractor

[![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/)

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.

## Usage

NewPipe Extractor is available at JitPack's Maven repo.

If you're using Gradle, you could add NewPipe Extractor as a dependency with the following steps:

1. Add `maven { url 'https://jitpack.io' }` to the `repositories` in your `build.gradle`.
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).
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:
```
## Rules for NewPipeExtractor
-keep class org.schabi.newpipe.extractor.timeago.patterns.** { *; }
-keep class org.mozilla.javascript.** { *; }
-keep class org.mozilla.classfile.ClassFileWriter
-dontwarn org.mozilla.javascript.tools.**
```

**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.

### Testing changes

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`:

```groovy
includeBuild('../NewPipeExtractor') {
dependencySubstitution {
substitute module('com.github.TeamNewPipe:NewPipeExtractor') with project(':extractor')
}
}
```

Another approach would be to use the local Maven repository, here's a gist of how to use it:

1. Add `mavenLocal()` in your project `repositories` list (usually as the first entry to give priority above the others).
2. It's _recommended_ that you change the `version` of this library (e.g. `LOCAL_SNAPSHOT`).
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`)
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'`)

> 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.
## Supported sites

The following sites are currently supported:

- YouTube
- SoundCloud
- media.ccc.de
- PeerTube (no P2P)
- Bandcamp
<h1 align="center"><b>Tubular Extractor</b></h2>
<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.

## License

[![GNU GPLv3 Image](https://www.gnu.org/graphics/gplv3-127x51.png)](https://www.gnu.org/licenses/gpl-3.0.en.html)

NewPipe Extractor is Free Software: You can use, study share and improve it at your
will. Specifically you can redistribute and/or modify it under the terms of the
[GNU General Public License](https://www.gnu.org/licenses/gpl.html) as
published by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
[![GNU GPLv3](https://www.gnu.org/graphics/gplv3-127x51.png)](https://www.gnu.org/licenses/gpl-3.0.en.html)
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ allprojects {

ext {
nanojsonVersion = "1d9e1aea9049fc9f85e68b43ba39fe7be1c1f751"
spotbugsVersion = "4.8.3"
junitVersion = "5.10.2"
spotbugsVersion = "4.8.6"
junitVersion = "5.10.3"
checkstyleVersion = "10.4"
}
}
Expand Down
4 changes: 2 additions & 2 deletions extractor/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ dependencies {

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

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

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

testImplementation "com.squareup.okhttp3:okhttp:3.12.13"
testImplementation 'com.google.code.gson:gson:2.10.1'
testImplementation 'com.google.code.gson:gson:2.11.0'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.schabi.newpipe.extractor.returnyoutubedislike;

public class ReturnYouTubeDislikeApiSettings {
public String apiUrl;

// TODO: add more if needed
//
//
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package org.schabi.newpipe.extractor.returnyoutubedislike;

import com.grack.nanojson.JsonObject;
import com.grack.nanojson.JsonParser;
import com.grack.nanojson.JsonParserException;

import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.exceptions.ReCaptchaException;
import org.schabi.newpipe.extractor.stream.StreamInfo;

import java.io.IOException;

public final class ReturnYouTubeDislikeExtractorHelper {

private ReturnYouTubeDislikeExtractorHelper() {
}

@SuppressWarnings("CheckStyle")
public static ReturnYouTubeDislikeInfo getInfo(
final StreamInfo streamInfo,
final ReturnYouTubeDislikeApiSettings apiSettings) {
if (!streamInfo.getUrl().startsWith("https://www.youtube.com")
|| apiSettings.apiUrl == null
|| apiSettings.apiUrl.isEmpty()) {
return null;
}

final String url = apiSettings.apiUrl + "votes?videoId=" + streamInfo.getId();

JsonObject response = null;

try {
final String responseBody =
NewPipe.getDownloader().get(url).responseBody();

response = JsonParser.object().from(responseBody);
} catch (ReCaptchaException | IOException | JsonParserException e) {
// ignored
}

if (response == null) {
return null;
}

final int likes = response.getInt("likes", 0);
final int dislikes = response.getInt("dislikes", 0);
final double rating = response.getDouble("rating", 0);
final int viewCount = response.getInt("viewCount", 0);
final boolean deleted = response.getBoolean("deleted", false);

return new ReturnYouTubeDislikeInfo(likes, dislikes, rating, viewCount, deleted);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.schabi.newpipe.extractor.returnyoutubedislike;

import java.io.Serializable;

public class ReturnYouTubeDislikeInfo implements Serializable {
public long likes;
public long dislikes;
public double rating;
public long viewCount;
public boolean deleted;

public ReturnYouTubeDislikeInfo(final long likes, final long dislikes, final double rating,
final long viewCount, final boolean deleted) {
this.likes = likes;
this.dislikes = dislikes;
this.rating = rating;
this.viewCount = viewCount;
this.deleted = deleted;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package org.schabi.newpipe.extractor.sponsorblock;

public enum SponsorBlockAction {
SKIP("skip"),
POI("poi");

private final String apiName;

SponsorBlockAction(final String apiName) {
this.apiName = apiName;
}

public static SponsorBlockAction fromApiName(final String apiName) {
switch (apiName) {
case "skip":
return SponsorBlockAction.SKIP;
case "poi":
return SponsorBlockAction.POI;
default:
throw new IllegalArgumentException("Invalid API name");
}
}

public String getApiName() {
return apiName;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.schabi.newpipe.extractor.sponsorblock;

public class SponsorBlockApiSettings {
public String apiUrl;
public boolean includeSponsorCategory;
public boolean includeIntroCategory;
public boolean includeOutroCategory;
public boolean includeInteractionCategory;
public boolean includeHighlightCategory;
public boolean includeSelfPromoCategory;
public boolean includeMusicCategory;
public boolean includePreviewCategory;
public boolean includeFillerCategory;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package org.schabi.newpipe.extractor.sponsorblock;

public enum SponsorBlockCategory {
SPONSOR("sponsor"),
INTRO("intro"),
OUTRO("outro"),
INTERACTION("interaction"),
HIGHLIGHT("poi_highlight"),
SELF_PROMO("selfpromo"),
NON_MUSIC("music_offtopic"),
PREVIEW("preview"),
FILLER("filler"),
PENDING("pending");

private final String apiName;

SponsorBlockCategory(final String apiName) {
this.apiName = apiName;
}

public static SponsorBlockCategory fromApiName(final String apiName) {
switch (apiName) {
case "sponsor":
return SponsorBlockCategory.SPONSOR;
case "intro":
return SponsorBlockCategory.INTRO;
case "outro":
return SponsorBlockCategory.OUTRO;
case "interaction":
return SponsorBlockCategory.INTERACTION;
case "poi_highlight":
return SponsorBlockCategory.HIGHLIGHT;
case "selfpromo":
return SponsorBlockCategory.SELF_PROMO;
case "music_offtopic":
return SponsorBlockCategory.NON_MUSIC;
case "preview":
return SponsorBlockCategory.PREVIEW;
case "filler":
return SponsorBlockCategory.FILLER;
default:
throw new IllegalArgumentException("Invalid API name");
}
}

public String getApiName() {
return apiName;
}
}
Loading

0 comments on commit 8e84c9a

Please sign in to comment.