Skip to content

Commit c377ffb

Browse files
committed
Merge branch 'dev' of github.com:TeamNewPipe/NewPipe into alang-selector
2 parents b567d42 + da30e53 commit c377ffb

11 files changed

Lines changed: 86 additions & 45 deletions

File tree

.github/workflows/ci.yml

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ jobs:
4444
if: github.event_name == 'pull_request'
4545
run: git checkout -B ${{ github.head_ref }}
4646

47-
- name: set up JDK 11
47+
- name: set up JDK 17
4848
uses: actions/setup-java@v3
4949
with:
50-
java-version: 11
50+
java-version: 17
5151
distribution: "temurin"
5252
cache: 'gradle'
5353

@@ -66,28 +66,33 @@ jobs:
6666
timeout-minutes: 20
6767
strategy:
6868
matrix:
69-
# api-level 19 is min sdk, but throws errors related to desugaring
70-
api-level: [ 21, 29 ]
69+
include:
70+
- api-level: 21
71+
target: default
72+
arch: x86
73+
- api-level: 33
74+
target: google_apis # emulator API 33 only exists with Google APIs
75+
arch: x86_64
7176

7277
permissions:
7378
contents: read
7479

7580
steps:
7681
- uses: actions/checkout@v3
7782

78-
- name: set up JDK 11
83+
- name: set up JDK 17
7984
uses: actions/setup-java@v3
8085
with:
81-
java-version: 11
86+
java-version: 17
8287
distribution: "temurin"
8388
cache: 'gradle'
8489

8590
- name: Run android tests
8691
uses: reactivecircus/android-emulator-runner@v2
8792
with:
8893
api-level: ${{ matrix.api-level }}
89-
# workaround to emulator bug: https://github.com/ReactiveCircus/android-emulator-runner/issues/160
90-
emulator-build: 7425822
94+
target: ${{ matrix.target }}
95+
arch: ${{ matrix.arch }}
9196
script: ./gradlew connectedCheck --stacktrace
9297

9398
- name: Upload test report when tests fail # because the printed out stacktrace (console) is too short, see also #7553
@@ -108,10 +113,10 @@ jobs:
108113
with:
109114
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
110115

111-
- name: Set up JDK 11
116+
- name: Set up JDK 17
112117
uses: actions/setup-java@v3
113118
with:
114-
java-version: 11 # Sonar requires JDK 11
119+
java-version: 17
115120
distribution: "temurin"
116121
cache: 'gradle'
117122

app/build.gradle

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,13 @@ android {
8080
// Flag to enable support for the new language APIs
8181
coreLibraryDesugaringEnabled true
8282

83-
sourceCompatibility JavaVersion.VERSION_11
84-
targetCompatibility JavaVersion.VERSION_11
83+
sourceCompatibility JavaVersion.VERSION_17
84+
targetCompatibility JavaVersion.VERSION_17
8585
encoding 'utf-8'
8686
}
8787

8888
kotlinOptions {
89-
jvmTarget = JavaVersion.VERSION_11
89+
jvmTarget = JavaVersion.VERSION_17
9090
}
9191

9292
sourceSets {
@@ -98,10 +98,11 @@ android {
9898
}
9999

100100
packagingOptions {
101-
// remove two files which belong to jsoup
102-
// no idea how they ended up in the META-INF dir...
103-
exclude 'META-INF/README.md'
104-
exclude 'META-INF/CHANGES'
101+
resources {
102+
// remove two files which belong to jsoup
103+
// no idea how they ended up in the META-INF dir...
104+
excludes += ['META-INF/README.md', 'META-INF/CHANGES']
105+
}
105106
}
106107
}
107108

app/src/main/java/org/schabi/newpipe/player/resolver/AudioPlaybackResolver.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package org.schabi.newpipe.player.resolver;
22

33
import static org.schabi.newpipe.util.ListHelper.getFilteredAudioStreams;
4-
import static org.schabi.newpipe.util.ListHelper.getNonTorrentStreams;
4+
import static org.schabi.newpipe.util.ListHelper.getPlayableStreams;
55

66
import android.content.Context;
77
import android.util.Log;
@@ -64,7 +64,8 @@ public MediaSource resolve(@NonNull final StreamInfo info) {
6464
stream = getStreamForIndex(audioIndex, audioStreams);
6565
tag = StreamInfoTag.of(info, audioStreams, audioIndex);
6666
} else {
67-
final List<VideoStream> videoStreams = getNonTorrentStreams(info.getVideoStreams());
67+
final List<VideoStream> videoStreams =
68+
getPlayableStreams(info.getVideoStreams(), info.getServiceId());
6869
if (!videoStreams.isEmpty()) {
6970
final int index = ListHelper.getDefaultResolutionIndex(context, videoStreams);
7071
stream = getStreamForIndex(index, videoStreams);

app/src/main/java/org/schabi/newpipe/player/resolver/VideoPlaybackResolver.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
import static com.google.android.exoplayer2.C.TIME_UNSET;
3131
import static org.schabi.newpipe.util.ListHelper.getFilteredAudioStreams;
3232
import static org.schabi.newpipe.util.ListHelper.getUrlAndNonTorrentStreams;
33-
import static org.schabi.newpipe.util.ListHelper.getNonTorrentStreams;
33+
import static org.schabi.newpipe.util.ListHelper.getPlayableStreams;
3434

3535
public class VideoPlaybackResolver implements PlaybackResolver {
3636
private static final String TAG = VideoPlaybackResolver.class.getSimpleName();
@@ -75,8 +75,8 @@ public MediaSource resolve(@NonNull final StreamInfo info) {
7575

7676
// Create video stream source
7777
final List<VideoStream> videoStreamsList = ListHelper.getSortedStreamVideosList(context,
78-
getNonTorrentStreams(info.getVideoStreams()),
79-
getNonTorrentStreams(info.getVideoOnlyStreams()), false, true);
78+
getPlayableStreams(info.getVideoStreams(), info.getServiceId()),
79+
getPlayableStreams(info.getVideoOnlyStreams(), info.getServiceId()), false, true);
8080
final List<AudioStream> audioStreamsList =
8181
getFilteredAudioStreams(context, info.getAudioStreams());
8282

app/src/main/java/org/schabi/newpipe/util/ListHelper.java

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package org.schabi.newpipe.util;
22

3+
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
4+
35
import android.content.Context;
46
import android.content.SharedPreferences;
57
import android.net.ConnectivityManager;
@@ -50,8 +52,22 @@ public final class ListHelper {
5052
private static final List<AudioTrackType> AUDIO_TRACK_TYPE_RANKING_DESCRIPTIVE =
5153
List.of(AudioTrackType.ORIGINAL, AudioTrackType.DUBBED, AudioTrackType.DESCRIPTIVE);
5254

53-
private ListHelper() {
54-
}
55+
/**
56+
* List of supported YouTube Itag ids.
57+
* The original order is kept.
58+
* @see {@link org.schabi.newpipe.extractor.services.youtube.ItagItem#ITAG_LIST}
59+
*/
60+
private static final List<Integer> SUPPORTED_ITAG_IDS =
61+
List.of(
62+
17, 36, // video v3GPP
63+
18, 34, 35, 59, 78, 22, 37, 38, // video MPEG4
64+
43, 44, 45, 46, // video webm
65+
171, 172, 139, 140, 141, 249, 250, 251, // audio
66+
160, 133, 134, 135, 212, 136, 298, 137, 299, 266, // video only
67+
278, 242, 243, 244, 245, 246, 247, 248, 271, 272, 302, 303, 308, 313, 315
68+
);
69+
70+
private ListHelper() { }
5571

5672
/**
5773
* @param context Android app context
@@ -150,7 +166,7 @@ public static int getAudioFormatIndex(final Context context,
150166
*/
151167
@NonNull
152168
public static <S extends Stream> List<S> getStreamsOfSpecifiedDelivery(
153-
final List<S> streamList,
169+
@Nullable final List<S> streamList,
154170
final DeliveryMethod deliveryMethod) {
155171
return getFilteredStreamList(streamList,
156172
stream -> stream.getDeliveryMethod() == deliveryMethod);
@@ -165,23 +181,31 @@ public static <S extends Stream> List<S> getStreamsOfSpecifiedDelivery(
165181
*/
166182
@NonNull
167183
public static <S extends Stream> List<S> getUrlAndNonTorrentStreams(
168-
final List<S> streamList) {
184+
@Nullable final List<S> streamList) {
169185
return getFilteredStreamList(streamList,
170186
stream -> stream.isUrl() && stream.getDeliveryMethod() != DeliveryMethod.TORRENT);
171187
}
172188

173189
/**
174-
* Return a {@link Stream} list which only contains non-torrent streams.
190+
* Return a {@link Stream} list which only contains streams which can be played by the player.
191+
* <br>
192+
* Some formats are not supported. For more info, see {@link #SUPPORTED_ITAG_IDS}.
193+
* Torrent streams are also removed, because they cannot be retrieved.
175194
*
176-
* @param streamList the original stream list
177195
* @param <S> the item type's class that extends {@link Stream}
178-
* @return a stream list which only contains non-torrent streams
196+
* @param streamList the original stream list
197+
* @param serviceId
198+
* @return a stream list which only contains streams that can be played the player
179199
*/
180200
@NonNull
181-
public static <S extends Stream> List<S> getNonTorrentStreams(
182-
final List<S> streamList) {
201+
public static <S extends Stream> List<S> getPlayableStreams(
202+
@Nullable final List<S> streamList, final int serviceId) {
203+
final int youtubeServiceId = YouTube.getServiceId();
183204
return getFilteredStreamList(streamList,
184-
stream -> stream.getDeliveryMethod() != DeliveryMethod.TORRENT);
205+
stream -> stream.getDeliveryMethod() != DeliveryMethod.TORRENT
206+
&& (serviceId != youtubeServiceId
207+
|| stream.getItagItem() == null
208+
|| SUPPORTED_ITAG_IDS.contains(stream.getItagItem().id)));
185209
}
186210

187211
/**
@@ -312,7 +336,7 @@ public static List<List<AudioStream>> getGroupedAudioStreams(
312336
* @return a new stream list filtered using the given predicate
313337
*/
314338
private static <S extends Stream> List<S> getFilteredStreamList(
315-
final List<S> streamList,
339+
@Nullable final List<S> streamList,
316340
final Predicate<S> streamListPredicate) {
317341
if (streamList == null) {
318342
return Collections.emptyList();
@@ -323,7 +347,7 @@ private static <S extends Stream> List<S> getFilteredStreamList(
323347
.collect(Collectors.toList());
324348
}
325349

326-
private static String computeDefaultResolution(final Context context, final int key,
350+
private static String computeDefaultResolution(@NonNull final Context context, final int key,
327351
final int value) {
328352
final SharedPreferences preferences =
329353
PreferenceManager.getDefaultSharedPreferences(context);

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ buildscript {
77
mavenCentral()
88
}
99
dependencies {
10-
classpath 'com.android.tools.build:gradle:7.4.0'
10+
classpath 'com.android.tools.build:gradle:8.0.0'
1111
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1212

1313
// NOTE: Do not place your application dependencies here; they belong

gradle.properties

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
android.defaults.buildfeatures.buildconfig=true
12
android.enableJetifier=false
3+
android.nonFinalResIds=false
4+
android.nonTransitiveRClass=false
25
android.useAndroidX=true
3-
org.gradle.jvmargs=-Xmx2048M
6+
org.gradle.jvmargs=-Xmx2048M --add-opens jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED
47
systemProp.file.encoding=utf-8

gradle/wrapper/gradle-wrapper.jar

1.29 KB
Binary file not shown.
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
4-
distributionSha256Sum=f6b8596b10cce501591e92f229816aa4046424f3b24d771751b06779d58c8ec4
3+
distributionSha256Sum=a62c5f99585dd9e1f95dab7b9415a0e698fa9dd1e6c38537faa81ac078f4d23e
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip
5+
networkTimeout=10000
56
zipStoreBase=GRADLE_USER_HOME
67
zipStorePath=wrapper/dists

gradlew

Lines changed: 12 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)