Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge dev to refactor #11809

Open
wants to merge 104 commits into
base: refactor
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
104 commits
Select commit Hold shift + click to select a range
8267d32
Fix compilation error when parsing unsupported file format
AbdeltwabMF Apr 30, 2024
b74cab6
Adjust the playlist bookmark item layout for RTL languages
AbdeltwabMF Apr 30, 2024
cf21b9f
Revert "Fix compilation error when parsing unsupported file format"
AbdeltwabMF May 1, 2024
c02ceda
Use layout constraints instead of static height
AbdeltwabMF May 18, 2024
e1bf67c
Update README.md
shrimprugbysnowowl Jun 7, 2024
71822a4
Update README.md
shrimprugbysnowowl Jun 7, 2024
26dd86e
Use Android's elapsed time formatting
Isira-Seneviratne Jul 7, 2024
07c63f7
Update documentation
Isira-Seneviratne Jul 7, 2024
063568b
Fixed playlist order between "Bookmarked Playlists" list and "add to …
nicholasala Sep 26, 2024
eb9f300
Fix seekbar preview crashes (#11584)
Thompson3142 Oct 10, 2024
781a69d
Chanegd related videos enqueue modal to attach to parent fragment ins…
rmtilde Oct 16, 2024
b14f658
Added comments to explain changes
rmtilde Oct 16, 2024
678f0a7
Merge pull request #1 from rmtilde/fix-related-items-enqueue-on-video…
rmtilde Oct 17, 2024
53edd05
Project now runs
u7656655 Oct 17, 2024
0cf4732
Fix UI crash when user navigates away before the download dialog appears
elvakang Oct 19, 2024
2eb2567
Revert "Project now runs"
elvakang Oct 19, 2024
ee15a72
Fix build failing locally due to outdated kotlin version
litetex Oct 22, 2024
8106ba6
CI: Use Java 21
litetex Oct 22, 2024
d80b6a7
Use working Extractor version
litetex Oct 22, 2024
ea0da5f
Delete symlink
litetex Oct 22, 2024
b1d4b66
Replace symlink with original
litetex Oct 22, 2024
9384365
Update Gradle to latest version
litetex Oct 22, 2024
2482615
Fix Android Gradle plugin warning
litetex Oct 22, 2024
2e96b65
Replaced ``Icepick`` with ``Bridge`` and ``Android-State``
litetex Oct 23, 2024
3a28651
Merge pull request #11636 from litetex/fix-build-2024-10
Stypox Oct 23, 2024
63bc982
Merge branch 'TeamNewPipe:dev' into fixing-ui-crash-11468
elvakang Oct 24, 2024
1ed4928
Add comment for fragment lifecycle checks before showing DownloadDialog
elvakang Oct 24, 2024
0190bce
Fix line length violation
elvakang Oct 24, 2024
1996c11
Merge branch 'TeamNewPipe:dev' into fix-related-items-enque-popup-crash
rmtilde Oct 26, 2024
fef4001
Added not null check for thumbnail URL before performing comparison
u7656655 Oct 27, 2024
05a87da
Merge pull request #11651 from u7656655/fix-addtoplaylist-crash
TobiGr Oct 27, 2024
f4baf46
Update app/src/main/java/org/schabi/newpipe/info_list/dialog/StreamDi…
TobiGr Oct 27, 2024
ba1e9c8
Update comment
Thompson3142 Oct 24, 2024
2396154
Formatting changes (back to original)
Thompson3142 Oct 27, 2024
cdac50b
Merge pull request #11596 from Thompson3142/fix_scrubbing_seekbar_pre…
TobiGr Oct 27, 2024
c855069
Make it possible control the version code and name
litetex Oct 27, 2024
94f992a
Merge pull request #11656 from litetex/better-control-over-version
TobiGr Oct 27, 2024
734b6e2
Add null-safe SharedPreferences.getStringSafe
Two-Ai Aug 30, 2024
64ad05d
Merge pull request #11629 from Two-Ai/kotlin-getStringSafe
TobiGr Oct 27, 2024
90404a2
Merge pull request #11621 from u7656655/fixing-ui-crash-11468
TobiGr Nov 2, 2024
66ec596
Update app/src/main/java/org/schabi/newpipe/fragments/list/videos/Rel…
rmtilde Nov 3, 2024
c0b36b8
Merge pull request #11614 from rmtilde/fix-related-items-enque-popup-…
TobiGr Nov 3, 2024
1193b02
Update user agent to Firefox ESR128
TobiGr Jul 11, 2024
f08e078
Merge pull request #11566 from nicholasala/fix/#10993-strange-playlis…
Stypox Nov 10, 2024
fe1c538
Update README.md
TobiGr Nov 11, 2024
7c18d4d
Update README.md
TobiGr Nov 11, 2024
0009613
Merge pull request #11140 from shrimprugbysnowowl/dev
TobiGr Nov 11, 2024
0ac5a26
Update README.md
VishramKidPG123 Nov 12, 2024
cb30072
Remove history dialog override so clicking "Start playing in the back…
codyit Nov 12, 2024
544b302
Merge pull request #11694 from VishramKidPG123/fix-typo-in-readme
Stypox Nov 12, 2024
a229ab6
Merge pull request #11696 from codyit/history-remove-dialog-override
Stypox Nov 12, 2024
6fe417a
Merge pull request #11024 from AbdeltwabMF/fix/rtl_lang_adjustment_bo…
Stypox Nov 14, 2024
bcd4579
Translated using Weblate (Hebrew)
weblate Nov 12, 2024
986cd52
Fix crash because of no height set on playlist bookmark
Stypox Nov 16, 2024
b43031f
Ellipsize uploader text in playlist bookmark
Stypox Nov 16, 2024
1f39523
Update NewPipeExtractor
Stypox Nov 16, 2024
e6c03bf
Merge pull request #11711 from Stypox/prepare-for-0.27.3
Stypox Nov 17, 2024
4ba961f
Translated using Weblate (Hungarian)
mdvhimself Nov 15, 2024
970ef93
Merge branch 'origin/dev' into Weblate.
weblate Nov 17, 2024
a962e6d
Add changelog for v0.27.3 (1000)
Stypox Nov 17, 2024
cf870ad
Release v0.27.3 (1000)
Stypox Nov 17, 2024
3c8d81a
add README.fr.md
KaGaster Mar 19, 2024
06d25b0
Merge pull request #11244 from Isira-Seneviratne/Android-elapsed-time
Stypox Nov 18, 2024
841471b
Merge pull request #10892 from KaGaster/el-koko
Stypox Nov 18, 2024
9f2f219
Merge branch 'dev' into release-0.27.3
Stypox Nov 18, 2024
10e7a5c
Merge pull request #11268 from TeamNewPipe/user-agent
Stypox Nov 18, 2024
8bf24e6
Merge branch 'dev' into release-0.27.3
Stypox Nov 18, 2024
2cc38f5
Readme translation to arabic
yosrinajar Apr 12, 2024
6d686b9
fixed all readme files
yosrinajar Apr 12, 2024
c7848e5
Apply URL encode/decode changes
Isira-Seneviratne Jul 21, 2024
ffcba17
Merge pull request #11330 from Isira-Seneviratne/Java-10-URL-NP
Profpatsch Nov 19, 2024
ebd4880
Merge pull request #10969 from yosrinajar/Read-Me-Translation
TobiGr Nov 19, 2024
1408150
Update backup and restore explanation & improve hindi, punjabi and as…
ShareASmile Nov 20, 2024
16c79c8
Fixed player resuming from start when clicking on a timestamp
Thompson3142 Nov 21, 2024
213f49f
Allow changing player notification preferences regardless of system s…
cillyvms Nov 22, 2024
33b96d2
Throttle loading subscriptions feed to avoid YouTube rate limits
Stypox Nov 24, 2024
726c12e
Only throttle YouTube feed loading
Stypox Nov 24, 2024
acf2e88
Merge pull request #11743 from TeamNewPipe/slower-feed
Stypox Nov 24, 2024
dc3f556
Add support for secondary audio track type
AudricV Nov 5, 2024
1255817
Merge pull request #11714 from AudricV/yt_more-audio-track-types-support
Stypox Nov 24, 2024
661e615
Update NewPipeExtractor to v0.24.3
Stypox Nov 24, 2024
a79bc3d
Translated using Weblate (Italian)
weblate Nov 23, 2024
d298a12
Merge pull request #11712 from TeamNewPipe/release-0.27.3
Stypox Nov 24, 2024
57e66b1
Merge branch 'master' into dev
Stypox Nov 24, 2024
df94167
Fix downloading/exporting when overwriting file would not truncate
Stypox Nov 24, 2024
f9711a3
Removed call to setRecovery() entirely
Thompson3142 Nov 24, 2024
b21981a
Add comments to explain why openAndTruncateStream()
Stypox Nov 27, 2024
e31a8ad
Mock openAndTruncateStream instead of getStream in test
Stypox Nov 27, 2024
c6b8bcf
Merge pull request #11745 from Stypox/truncate-before-export
TobiGr Nov 27, 2024
e4b0245
Merge pull request #11734 from Thompson3142/fix_timestamp_popup_time
Stypox Nov 27, 2024
52942ff
Merge pull request #11738 from cillyvms/a13-player-notifs
Stypox Nov 27, 2024
246fc03
Add build-release-apk workflow
Stypox Nov 30, 2024
c569f08
Add build-release-apk workflow
Stypox Nov 30, 2024
88d8d90
Merge pull request #11765 from Stypox/release-workflow
Stypox Nov 30, 2024
b19cd00
Translated using Weblate (Malay)
weblate Nov 30, 2024
0dca92d
Merge branch 'master' into dev
Stypox Nov 30, 2024
9054575
Add changelog for v0.27.4 (1001)
Stypox Nov 30, 2024
3847b32
Release v0.27.4 (1001)
Stypox Nov 30, 2024
70748fa
Use JDK 21 in build-release-apk.yml
Stypox Dec 2, 2024
de46e3a
Update CONTRIBUTING.md
Rishi2003Das Dec 7, 2024
240a2fe
Update CONTRIBUTING.md
Rishi2003Das Dec 7, 2024
c6b05c6
Update CONTRIBUTING.md
Rishi2003Das Dec 7, 2024
3fc0147
Merge pull request #11784 from Rishi2003Das/typo_change
Stypox Dec 17, 2024
d4ed18b
Merge branch 'dev' into Merge-dev
Isira-Seneviratne Dec 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ NewPipe contribution guidelines
## Crash reporting

Report crashes through the **automated crash report system** of NewPipe.
This way all the data needed for debugging is included in your bugreport for GitHub.
This way all the data needed for debugging is included in your bug report for GitHub.
You'll see *exactly* what is sent, be able to add **your comments**, and then send it.

## Issue reporting/feature requests
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/build-release-apk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: "Build unsigned release APK on master"

on:
workflow_dispatch:

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: 'master'

- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
cache: 'gradle'

- name: "Build release APK"
run: ./gradlew assembleRelease --stacktrace

- name: "Rename APK"
run: |
VERSION_NAME="$(jq -r ".elements[0].versionName" "app/build/outputs/apk/release/output-metadata.json")"
echo "Version name: $VERSION_NAME" >> "$GITHUB_STEP_SUMMARY"
echo '```json' >> "$GITHUB_STEP_SUMMARY"
cat "app/build/outputs/apk/release/output-metadata.json" >> "$GITHUB_STEP_SUMMARY"
echo >> "$GITHUB_STEP_SUMMARY"
echo '```' >> "$GITHUB_STEP_SUMMARY"
# assume there is only one APK in that folder
mv app/build/outputs/apk/release/*.apk "app/build/outputs/apk/release/NewPipe_v$VERSION_NAME.apk"

- name: "Upload APK"
uses: actions/upload-artifact@v4
with:
name: app
path: app/build/outputs/apk/release/*.apk
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<p align="center"><a href="https://newpipe.net">Website</a> &bull; <a href="https://newpipe.net/blog/">Blog</a> &bull; <a href="https://newpipe.net/FAQ/">FAQ</a> &bull; <a href="https://newpipe.net/press/">Press</a></p>
<hr>

*Read this document in other languages: [Deutsch](doc/README.de.md), [English](README.md), [Español](doc/README.es.md), [Français](doc/README.fr.md), [हिन्दी](doc/README.hi.md), [Italiano](doc/README.it.md), [한국어](doc/README.ko.md), [Português Brasil](doc/README.pt_BR.md), [Polski](doc/README.pl.md), [ਪੰਜਾਬੀ ](doc/README.pa.md), [日本語](doc/README.ja.md), [Română](doc/README.ro.md), [Soomaali](doc/README.so.md), [Türkçe](doc/README.tr.md), [正體中文](doc/README.zh_TW.md), [অসমীয়া](doc/README.asm.md), [Српски](doc/README.sr.md)*
*Read this document in other languages: [Deutsch](doc/README.de.md), [English](README.md), [Español](doc/README.es.md), [Français](doc/README.fr.md), [हिन्दी](doc/README.hi.md), [Italiano](doc/README.it.md), [한국어](doc/README.ko.md), [Português Brasil](doc/README.pt_BR.md), [Polski](doc/README.pl.md), [ਪੰਜਾਬੀ ](doc/README.pa.md), [日本語](doc/README.ja.md), [Română](doc/README.ro.md), [Soomaali](doc/README.so.md), [Türkçe](doc/README.tr.md), [正體中文](doc/README.zh_TW.md), [অসমীয়া](doc/README.asm.md), [Српски](doc/README.sr.md), [العربية](README.ar.md)*

> [!warning]
> <b>THIS APP IS IN BETA, SO YOU MAY ENCOUNTER BUGS. IF YOU DO, OPEN AN ISSUE IN OUR GITHUB REPOSITORY BY FILLING OUT THE ISSUE TEMPLATE.</b>
Expand Down Expand Up @@ -96,7 +96,7 @@ Also, since they are free and open source software, neither the app nor the Extr
## Installation and updates
You can install NewPipe using one of the following methods:
1. Add our custom repo to F-Droid and install it from there. The instructions are here: https://newpipe.net/FAQ/tutorials/install-add-fdroid-repo/
2. Download the APK from [GitHub Releases](https://github.com/TeamNewPipe/NewPipe/releases) and install it.
2. Download the APK from [GitHub Releases](https://github.com/TeamNewPipe/NewPipe/releases), [compare the signing key](#apk-info) and install it.
3. Update via F-Droid. This is the slowest method of getting updates, as F-Droid must recognize changes, build the APK itself, sign it, and then push the update to users.
4. Build a debug APK yourself. This is the fastest way to get new features on your device, but is much more complicated, so we recommend using one of the other methods.
5. If you're interested in a specific feature or bugfix provided in a Pull Request in this repo, you can also download its APK from within the PR. Read the PR description for instructions. The great thing about PR-specific APKs is that they're installed side-by-side the official app, so you don't have to worry about losing your data or messing anything up.
Expand All @@ -109,7 +109,15 @@ In the meanwhile, if you want to switch sources for some reason (e.g. NewPipe's
3. Download the APK from the new source and install it
4. Import the data from step 1 via Settings > Backup and Restore > Import Database

<b>Note: when you're importing a database into the official app, always make sure that it is the one you exported _from_ the official app. If you import a database exported from an APK other than the official app, it may break things. Such an action is unsupported, and you should only do so when you're absolutely certain you know what you're doing.</b>
> [!Note]
> When you're importing a database into the official app, always make sure that it is the one you exported _from_ the official app. If you import a database exported from an APK other than the official app, it may break things. Such an action is unsupported, and you should only do so when you're absolutely certain you know what you're doing.

### APK Info

This is the SHA fingerprint of NewPipe's signing key to verify downloaded APKs which are signed by us. The fingerprint is also available on [NewPipe's website](https://newpipe.net#download). This is relevant for method 2.
```
CB:84:06:9B:D6:81:16:BA:FA:E5:EE:4E:E5:B0:8A:56:7A:A6:D8:98:40:4E:7C:B1:2F:9E:75:6D:F5:CF:5C:AB
```

## Contribution
Whether you have ideas, translations, design changes, code cleaning, or even major code changes, help is always welcome. The app gets better and better with each contribution, no matter how big or small! If you'd like to get involved, check our [contribution notes](.github/CONTRIBUTING.md).
Expand Down
11 changes: 9 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,15 @@ android {
resValue "string", "app_name", "NewPipe"
minSdk 21
targetSdk 33
versionCode 999
versionName "0.27.2"
if (System.properties.containsKey('versionCodeOverride')) {
versionCode System.getProperty('versionCodeOverride') as Integer
} else {
versionCode 1001
}
versionName "0.27.4"
if (System.properties.containsKey('versionNameSuffix')) {
versionNameSuffix System.getProperty('versionNameSuffix')
}

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/org/schabi/newpipe/DownloaderImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

public final class DownloaderImpl extends Downloader {
public static final String USER_AGENT =
"Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0";
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 Firefox/128.0";
public static final String YOUTUBE_RESTRICTED_MODE_COOKIE_KEY =
"youtube_restricted_mode_key";
public static final String YOUTUBE_RESTRICTED_MODE_COOKIE = "PREF=f2=8000000";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,6 @@ default Flowable<List<PlaylistStreamEntity>> listByService(final int serviceId)
+ " AND :streamUrl = :streamUrl"

+ " GROUP BY " + JOIN_PLAYLIST_ID
+ " ORDER BY " + PLAYLIST_DISPLAY_INDEX)
+ " ORDER BY " + PLAYLIST_DISPLAY_INDEX + ", " + PLAYLIST_NAME)
Flowable<List<PlaylistDuplicatesEntry>> getPlaylistDuplicatesMetadata(String streamUrl);
}
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,10 @@ public enum StreamDialogDefaultEntry {
DOWNLOAD(R.string.download, (fragment, item) ->
fetchStreamInfoAndSaveToDatabase(fragment.requireContext(), item.getServiceId(),
item.getUrl(), info -> {
if (fragment.getContext() != null) {
// Ensure the fragment is attached and its state hasn't been saved to avoid
// showing dialog during lifecycle changes or when the activity is paused,
// e.g. by selecting the download option and opening a different fragment.
if (fragment.isAdded() && !fragment.isStateSaved()) {
final DownloadDialog downloadDialog =
new DownloadDialog(fragment.requireContext(), info);
downloadDialog.show(fragment.getChildFragmentManager(),
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/java/org/schabi/newpipe/ktx/SharedPreferences.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.schabi.newpipe.ktx

import android.content.SharedPreferences

fun SharedPreferences.getStringSafe(key: String, defValue: String): String {
return getString(key, null) ?: defValue
}
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ private void onPlaylistSelected(@NonNull final LocalPlaylistManager manager,
.subscribe(ignored -> {
successToast.show();

if (playlist.thumbnailUrl.equals(PlaylistEntity.DEFAULT_THUMBNAIL)) {
if (playlist.thumbnailUrl != null
&& playlist.thumbnailUrl.equals(PlaylistEntity.DEFAULT_THUMBNAIL)) {
playlistDisposables.add(manager
.changePlaylistThumbnail(playlist.getUid(), streams.get(0).getUid(),
false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ import org.schabi.newpipe.database.subscription.NotificationMode
import org.schabi.newpipe.database.subscription.SubscriptionEntity
import org.schabi.newpipe.extractor.Info
import org.schabi.newpipe.extractor.NewPipe
import org.schabi.newpipe.extractor.ServiceList
import org.schabi.newpipe.extractor.feed.FeedInfo
import org.schabi.newpipe.extractor.stream.StreamInfoItem
import org.schabi.newpipe.ktx.getStringSafe
import org.schabi.newpipe.local.feed.FeedDatabaseManager
import org.schabi.newpipe.local.subscription.SubscriptionManager
import org.schabi.newpipe.util.ChannelTabHelper
Expand Down Expand Up @@ -69,12 +71,10 @@ class FeedLoadManager(private val context: Context) {
val outdatedThreshold = if (ignoreOutdatedThreshold) {
OffsetDateTime.now(ZoneOffset.UTC)
} else {
val thresholdOutdatedSeconds = (
defaultSharedPreferences.getString(
context.getString(R.string.feed_update_threshold_key),
context.getString(R.string.feed_update_threshold_default_value)
) ?: context.getString(R.string.feed_update_threshold_default_value)
).toInt()
val thresholdOutdatedSeconds = defaultSharedPreferences.getStringSafe(
context.getString(R.string.feed_update_threshold_key),
context.getString(R.string.feed_update_threshold_default_value)
).toInt()
OffsetDateTime.now(ZoneOffset.UTC).minusSeconds(thresholdOutdatedSeconds.toLong())
}

Expand All @@ -91,6 +91,10 @@ class FeedLoadManager(private val context: Context) {
else -> feedDatabaseManager.outdatedSubscriptionsForGroup(groupId, outdatedThreshold)
}

// like `currentProgress`, but counts the number of YouTube extractions that have begun, so
// they can be properly throttled every once in a while (see doOnNext below)
val youtubeExtractionCount = AtomicInteger()

return outdatedSubscriptions
.take(1)
.doOnNext {
Expand All @@ -106,6 +110,15 @@ class FeedLoadManager(private val context: Context) {
.observeOn(Schedulers.io())
.flatMap { Flowable.fromIterable(it) }
.takeWhile { !cancelSignal.get() }
.doOnNext { subscriptionEntity ->
// throttle YouTube extractions once every BATCH_SIZE to avoid being rate limited
if (subscriptionEntity.serviceId == ServiceList.YouTube.serviceId) {
val previousCount = youtubeExtractionCount.getAndIncrement()
if (previousCount != 0 && previousCount % BATCH_SIZE == 0) {
Thread.sleep(DELAY_BETWEEN_BATCHES_MILLIS.random())
}
}
}
.parallel(PARALLEL_EXTRACTIONS, PARALLEL_EXTRACTIONS * 2)
.runOn(Schedulers.io(), PARALLEL_EXTRACTIONS * 2)
.filter { !cancelSignal.get() }
Expand Down Expand Up @@ -329,7 +342,19 @@ class FeedLoadManager(private val context: Context) {
/**
* How many extractions will be running in parallel.
*/
private const val PARALLEL_EXTRACTIONS = 6
private const val PARALLEL_EXTRACTIONS = 3

/**
* How many YouTube extractions to perform before waiting [DELAY_BETWEEN_BATCHES_MILLIS]
* to avoid being rate limited
*/
private const val BATCH_SIZE = 50

/**
* Wait a random delay in this range once every [BATCH_SIZE] YouTube extractions to avoid
* being rate limited
*/
private val DELAY_BETWEEN_BATCHES_MILLIS = (6000L..12000L)

/**
* Number of items to buffer to mass-insert in the database.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,10 +332,6 @@ private void showInfoItemDialog(final StreamStatisticsEntry item) {
StreamDialogDefaultEntry.DELETE,
(f, i) -> deleteEntry(
Math.max(itemListAdapter.getItemsList().indexOf(item), 0)))
.setAction(
StreamDialogDefaultEntry.START_HERE_ON_BACKGROUND,
(f, i) -> NavigationHelper.playOnBackgroundPlayer(
context, getPlayQueueStartingAt(item), true))
.create()
.show();
} catch (final IllegalArgumentException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ public int onStartCommand(final Intent intent, final int flags, final int startI

try {
outFile = new StoredFileHelper(this, path, "application/json");
outputStream = new SharpOutputStream(outFile.getStream());
// truncate the file before writing to it, otherwise if the new content is smaller than
// the previous file size, the file will retain part of the previous content and be
// corrupted
outputStream = new SharpOutputStream(outFile.openAndTruncateStream());
} catch (final IOException e) {
handleError(e);
return START_NOT_STICKY;
Expand Down
1 change: 0 additions & 1 deletion app/src/main/java/org/schabi/newpipe/player/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,6 @@ public void handleIntent(@NonNull final Intent intent) {
if (oldPlayerType != playerType && playQueue != null) {
// If playerType changes from one to another we should reload the player
// (to disable/enable video stream or to set quality)
setRecovery();
reloadPlayQueueManager();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,8 @@ private void generateDataFrom(final Frameset frameset, final UUID updateRequestI

// Get the bounds where the frame is found
final int[] bounds = frameset.getFrameBoundsAt(currentPosMs);
generatedDataForUrl.put(currentPosMs, () -> {
// It can happen, that the original bitmap could not be downloaded
// In such a case - we don't want a NullPointer - simply return null
if (srcBitMap == null) {
return null;
}

// Cut out the corresponding bitmap form the "srcBitMap"
return Bitmap.createBitmap(srcBitMap, bounds[1], bounds[2],
frameset.getFrameWidth(), frameset.getFrameHeight());
});
generatedDataForUrl.put(currentPosMs,
createBitmapSupplier(srcBitMap, bounds, frameset));

currentPosMs += frameset.getDurationPerFrame();
pos++;
Expand All @@ -166,6 +157,45 @@ private void generateDataFrom(final Frameset frameset, final UUID updateRequestI
}
}

private Supplier<Bitmap> createBitmapSupplier(final Bitmap srcBitMap,
final int[] bounds,
final Frameset frameset) {
return () -> {
// It can happen, that the original bitmap could not be downloaded
// (or it was recycled though that should not happen)
// In such a case - we don't want a NullPointer/
// "cannot use a recycled source in createBitmap" Exception -> simply return null
if (srcBitMap == null || srcBitMap.isRecycled()) {
return null;
}

// Under some rare circumstances the YouTube API returns slightly too small storyboards,
// (or not the matching frame width/height)
// This would lead to createBitmap cutting out a bitmap that is out of bounds,
// so we need to adjust the bounds accordingly
if (srcBitMap.getWidth() < bounds[1] + frameset.getFrameWidth()) {
bounds[1] = srcBitMap.getWidth() - frameset.getFrameWidth();
}

if (srcBitMap.getHeight() < bounds[2] + frameset.getFrameHeight()) {
bounds[2] = srcBitMap.getHeight() - frameset.getFrameHeight();
}

// Cut out the corresponding bitmap form the "srcBitMap"
final Bitmap cutOutBitmap = Bitmap.createBitmap(srcBitMap, bounds[1], bounds[2],
frameset.getFrameWidth(), frameset.getFrameHeight());

// If the cut out bitmap is identical to its source,
// we need to copy the bitmap to create a new instance.
// createBitmap allows itself to return the original object that is was created with
// this leads to recycled bitmaps being returned (if they are identical)
// Reference: https://stackoverflow.com/a/23683075 + first comment
// Fixes: https://github.com/TeamNewPipe/NewPipe/issues/11461
return cutOutBitmap == srcBitMap
? cutOutBitmap.copy(cutOutBitmap.getConfig(), true) : cutOutBitmap;
};
}

@Nullable
private Bitmap getBitMapFrom(final String url) {
if (url == null) {
Expand Down
Loading
Loading