-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
512 additions
and
180 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
...va/org/schabi/newpipe/extractor/returnyoutubedislike/ReturnYouTubeDislikeApiSettings.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
// | ||
// | ||
} |
53 changes: 53 additions & 0 deletions
53
...rg/schabi/newpipe/extractor/returnyoutubedislike/ReturnYouTubeDislikeExtractorHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
...main/java/org/schabi/newpipe/extractor/returnyoutubedislike/ReturnYouTubeDislikeInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
extractor/src/main/java/org/schabi/newpipe/extractor/sponsorblock/SponsorBlockAction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...ctor/src/main/java/org/schabi/newpipe/extractor/sponsorblock/SponsorBlockApiSettings.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
49 changes: 49 additions & 0 deletions
49
extractor/src/main/java/org/schabi/newpipe/extractor/sponsorblock/SponsorBlockCategory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
Oops, something went wrong.