1
0
mirror of https://github.com/TeamNewPipe/NewPipe.git synced 2024-11-25 12:32:31 +01:00

Merge branch 'dev' of github.com:TeamNewPipe/NewPipe into alang-selector

This commit is contained in:
ThetaDev 2023-04-21 23:32:33 +02:00
commit c377ffbce8
11 changed files with 86 additions and 45 deletions

View File

@ -44,10 +44,10 @@ jobs:
if: github.event_name == 'pull_request' if: github.event_name == 'pull_request'
run: git checkout -B ${{ github.head_ref }} run: git checkout -B ${{ github.head_ref }}
- name: set up JDK 11 - name: set up JDK 17
uses: actions/setup-java@v3 uses: actions/setup-java@v3
with: with:
java-version: 11 java-version: 17
distribution: "temurin" distribution: "temurin"
cache: 'gradle' cache: 'gradle'
@ -66,8 +66,13 @@ jobs:
timeout-minutes: 20 timeout-minutes: 20
strategy: strategy:
matrix: matrix:
# api-level 19 is min sdk, but throws errors related to desugaring include:
api-level: [ 21, 29 ] - api-level: 21
target: default
arch: x86
- api-level: 33
target: google_apis # emulator API 33 only exists with Google APIs
arch: x86_64
permissions: permissions:
contents: read contents: read
@ -75,10 +80,10 @@ jobs:
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: set up JDK 11 - name: set up JDK 17
uses: actions/setup-java@v3 uses: actions/setup-java@v3
with: with:
java-version: 11 java-version: 17
distribution: "temurin" distribution: "temurin"
cache: 'gradle' cache: 'gradle'
@ -86,8 +91,8 @@ jobs:
uses: reactivecircus/android-emulator-runner@v2 uses: reactivecircus/android-emulator-runner@v2
with: with:
api-level: ${{ matrix.api-level }} api-level: ${{ matrix.api-level }}
# workaround to emulator bug: https://github.com/ReactiveCircus/android-emulator-runner/issues/160 target: ${{ matrix.target }}
emulator-build: 7425822 arch: ${{ matrix.arch }}
script: ./gradlew connectedCheck --stacktrace script: ./gradlew connectedCheck --stacktrace
- name: Upload test report when tests fail # because the printed out stacktrace (console) is too short, see also #7553 - name: Upload test report when tests fail # because the printed out stacktrace (console) is too short, see also #7553
@ -108,10 +113,10 @@ jobs:
with: with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 11 - name: Set up JDK 17
uses: actions/setup-java@v3 uses: actions/setup-java@v3
with: with:
java-version: 11 # Sonar requires JDK 11 java-version: 17
distribution: "temurin" distribution: "temurin"
cache: 'gradle' cache: 'gradle'

View File

@ -80,13 +80,13 @@ android {
// Flag to enable support for the new language APIs // Flag to enable support for the new language APIs
coreLibraryDesugaringEnabled true coreLibraryDesugaringEnabled true
sourceCompatibility JavaVersion.VERSION_11 sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_11 targetCompatibility JavaVersion.VERSION_17
encoding 'utf-8' encoding 'utf-8'
} }
kotlinOptions { kotlinOptions {
jvmTarget = JavaVersion.VERSION_11 jvmTarget = JavaVersion.VERSION_17
} }
sourceSets { sourceSets {
@ -98,10 +98,11 @@ android {
} }
packagingOptions { packagingOptions {
// remove two files which belong to jsoup resources {
// no idea how they ended up in the META-INF dir... // remove two files which belong to jsoup
exclude 'META-INF/README.md' // no idea how they ended up in the META-INF dir...
exclude 'META-INF/CHANGES' excludes += ['META-INF/README.md', 'META-INF/CHANGES']
}
} }
} }

View File

@ -1,7 +1,7 @@
package org.schabi.newpipe.player.resolver; package org.schabi.newpipe.player.resolver;
import static org.schabi.newpipe.util.ListHelper.getFilteredAudioStreams; import static org.schabi.newpipe.util.ListHelper.getFilteredAudioStreams;
import static org.schabi.newpipe.util.ListHelper.getNonTorrentStreams; import static org.schabi.newpipe.util.ListHelper.getPlayableStreams;
import android.content.Context; import android.content.Context;
import android.util.Log; import android.util.Log;
@ -64,7 +64,8 @@ public class AudioPlaybackResolver implements PlaybackResolver {
stream = getStreamForIndex(audioIndex, audioStreams); stream = getStreamForIndex(audioIndex, audioStreams);
tag = StreamInfoTag.of(info, audioStreams, audioIndex); tag = StreamInfoTag.of(info, audioStreams, audioIndex);
} else { } else {
final List<VideoStream> videoStreams = getNonTorrentStreams(info.getVideoStreams()); final List<VideoStream> videoStreams =
getPlayableStreams(info.getVideoStreams(), info.getServiceId());
if (!videoStreams.isEmpty()) { if (!videoStreams.isEmpty()) {
final int index = ListHelper.getDefaultResolutionIndex(context, videoStreams); final int index = ListHelper.getDefaultResolutionIndex(context, videoStreams);
stream = getStreamForIndex(index, videoStreams); stream = getStreamForIndex(index, videoStreams);

View File

@ -30,7 +30,7 @@ import java.util.Optional;
import static com.google.android.exoplayer2.C.TIME_UNSET; import static com.google.android.exoplayer2.C.TIME_UNSET;
import static org.schabi.newpipe.util.ListHelper.getFilteredAudioStreams; import static org.schabi.newpipe.util.ListHelper.getFilteredAudioStreams;
import static org.schabi.newpipe.util.ListHelper.getUrlAndNonTorrentStreams; import static org.schabi.newpipe.util.ListHelper.getUrlAndNonTorrentStreams;
import static org.schabi.newpipe.util.ListHelper.getNonTorrentStreams; import static org.schabi.newpipe.util.ListHelper.getPlayableStreams;
public class VideoPlaybackResolver implements PlaybackResolver { public class VideoPlaybackResolver implements PlaybackResolver {
private static final String TAG = VideoPlaybackResolver.class.getSimpleName(); private static final String TAG = VideoPlaybackResolver.class.getSimpleName();
@ -75,8 +75,8 @@ public class VideoPlaybackResolver implements PlaybackResolver {
// Create video stream source // Create video stream source
final List<VideoStream> videoStreamsList = ListHelper.getSortedStreamVideosList(context, final List<VideoStream> videoStreamsList = ListHelper.getSortedStreamVideosList(context,
getNonTorrentStreams(info.getVideoStreams()), getPlayableStreams(info.getVideoStreams(), info.getServiceId()),
getNonTorrentStreams(info.getVideoOnlyStreams()), false, true); getPlayableStreams(info.getVideoOnlyStreams(), info.getServiceId()), false, true);
final List<AudioStream> audioStreamsList = final List<AudioStream> audioStreamsList =
getFilteredAudioStreams(context, info.getAudioStreams()); getFilteredAudioStreams(context, info.getAudioStreams());

View File

@ -1,5 +1,7 @@
package org.schabi.newpipe.util; package org.schabi.newpipe.util;
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.net.ConnectivityManager; import android.net.ConnectivityManager;
@ -50,8 +52,22 @@ public final class ListHelper {
private static final List<AudioTrackType> AUDIO_TRACK_TYPE_RANKING_DESCRIPTIVE = private static final List<AudioTrackType> AUDIO_TRACK_TYPE_RANKING_DESCRIPTIVE =
List.of(AudioTrackType.ORIGINAL, AudioTrackType.DUBBED, AudioTrackType.DESCRIPTIVE); List.of(AudioTrackType.ORIGINAL, AudioTrackType.DUBBED, AudioTrackType.DESCRIPTIVE);
private ListHelper() { /**
} * List of supported YouTube Itag ids.
* The original order is kept.
* @see {@link org.schabi.newpipe.extractor.services.youtube.ItagItem#ITAG_LIST}
*/
private static final List<Integer> SUPPORTED_ITAG_IDS =
List.of(
17, 36, // video v3GPP
18, 34, 35, 59, 78, 22, 37, 38, // video MPEG4
43, 44, 45, 46, // video webm
171, 172, 139, 140, 141, 249, 250, 251, // audio
160, 133, 134, 135, 212, 136, 298, 137, 299, 266, // video only
278, 242, 243, 244, 245, 246, 247, 248, 271, 272, 302, 303, 308, 313, 315
);
private ListHelper() { }
/** /**
* @param context Android app context * @param context Android app context
@ -150,7 +166,7 @@ public final class ListHelper {
*/ */
@NonNull @NonNull
public static <S extends Stream> List<S> getStreamsOfSpecifiedDelivery( public static <S extends Stream> List<S> getStreamsOfSpecifiedDelivery(
final List<S> streamList, @Nullable final List<S> streamList,
final DeliveryMethod deliveryMethod) { final DeliveryMethod deliveryMethod) {
return getFilteredStreamList(streamList, return getFilteredStreamList(streamList,
stream -> stream.getDeliveryMethod() == deliveryMethod); stream -> stream.getDeliveryMethod() == deliveryMethod);
@ -165,23 +181,31 @@ public final class ListHelper {
*/ */
@NonNull @NonNull
public static <S extends Stream> List<S> getUrlAndNonTorrentStreams( public static <S extends Stream> List<S> getUrlAndNonTorrentStreams(
final List<S> streamList) { @Nullable final List<S> streamList) {
return getFilteredStreamList(streamList, return getFilteredStreamList(streamList,
stream -> stream.isUrl() && stream.getDeliveryMethod() != DeliveryMethod.TORRENT); stream -> stream.isUrl() && stream.getDeliveryMethod() != DeliveryMethod.TORRENT);
} }
/** /**
* Return a {@link Stream} list which only contains non-torrent streams. * Return a {@link Stream} list which only contains streams which can be played by the player.
* <br>
* Some formats are not supported. For more info, see {@link #SUPPORTED_ITAG_IDS}.
* Torrent streams are also removed, because they cannot be retrieved.
* *
* @param streamList the original stream list
* @param <S> the item type's class that extends {@link Stream} * @param <S> the item type's class that extends {@link Stream}
* @return a stream list which only contains non-torrent streams * @param streamList the original stream list
* @param serviceId
* @return a stream list which only contains streams that can be played the player
*/ */
@NonNull @NonNull
public static <S extends Stream> List<S> getNonTorrentStreams( public static <S extends Stream> List<S> getPlayableStreams(
final List<S> streamList) { @Nullable final List<S> streamList, final int serviceId) {
final int youtubeServiceId = YouTube.getServiceId();
return getFilteredStreamList(streamList, return getFilteredStreamList(streamList,
stream -> stream.getDeliveryMethod() != DeliveryMethod.TORRENT); stream -> stream.getDeliveryMethod() != DeliveryMethod.TORRENT
&& (serviceId != youtubeServiceId
|| stream.getItagItem() == null
|| SUPPORTED_ITAG_IDS.contains(stream.getItagItem().id)));
} }
/** /**
@ -312,7 +336,7 @@ public final class ListHelper {
* @return a new stream list filtered using the given predicate * @return a new stream list filtered using the given predicate
*/ */
private static <S extends Stream> List<S> getFilteredStreamList( private static <S extends Stream> List<S> getFilteredStreamList(
final List<S> streamList, @Nullable final List<S> streamList,
final Predicate<S> streamListPredicate) { final Predicate<S> streamListPredicate) {
if (streamList == null) { if (streamList == null) {
return Collections.emptyList(); return Collections.emptyList();
@ -323,7 +347,7 @@ public final class ListHelper {
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
private static String computeDefaultResolution(final Context context, final int key, private static String computeDefaultResolution(@NonNull final Context context, final int key,
final int value) { final int value) {
final SharedPreferences preferences = final SharedPreferences preferences =
PreferenceManager.getDefaultSharedPreferences(context); PreferenceManager.getDefaultSharedPreferences(context);

View File

@ -7,7 +7,7 @@ buildscript {
mavenCentral() mavenCentral()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:7.4.0' classpath 'com.android.tools.build:gradle:8.0.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong

View File

@ -1,4 +1,7 @@
android.defaults.buildfeatures.buildconfig=true
android.enableJetifier=false android.enableJetifier=false
android.nonFinalResIds=false
android.nonTransitiveRClass=false
android.useAndroidX=true android.useAndroidX=true
org.gradle.jvmargs=-Xmx2048M org.gradle.jvmargs=-Xmx2048M --add-opens jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED
systemProp.file.encoding=utf-8 systemProp.file.encoding=utf-8

Binary file not shown.

View File

@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip distributionSha256Sum=a62c5f99585dd9e1f95dab7b9415a0e698fa9dd1e6c38537faa81ac078f4d23e
distributionSha256Sum=f6b8596b10cce501591e92f229816aa4046424f3b24d771751b06779d58c8ec4 distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

19
gradlew vendored
View File

@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop. # Darwin, MinGW, and NonStop.
# #
# (3) This script is generated from the Groovy template # (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt # https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project. # within the Gradle project.
# #
# You can find Gradle at https://github.com/gradle/gradle/. # You can find Gradle at https://github.com/gradle/gradle/.
@ -80,13 +80,10 @@ do
esac esac
done done
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit # This is normally unused
# shellcheck disable=SC2034
APP_NAME="Gradle"
APP_BASE_NAME=${0##*/} APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value. # Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum MAX_FD=maximum
@ -143,12 +140,16 @@ fi
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #( case $MAX_FD in #(
max*) max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) || MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit" warn "Could not query maximum file descriptor limit"
esac esac
case $MAX_FD in #( case $MAX_FD in #(
'' | soft) :;; #( '' | soft) :;; #(
*) *)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" || ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD" warn "Could not set maximum file descriptor limit to $MAX_FD"
esac esac
@ -193,6 +194,10 @@ if "$cygwin" || "$msys" ; then
done done
fi fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Collect all arguments for the java command; # Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in # shell script including quotes and variable substitutions, so put them in

1
gradlew.bat vendored
View File

@ -26,6 +26,7 @@ if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0 set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=. if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0 set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME% set APP_HOME=%DIRNAME%