Skip to content
This repository was archived by the owner on Jan 21, 2024. It is now read-only.

Commit ed6a94b

Browse files
Merge branch 'master' into sponsorblock
# Conflicts: # README.md # app/src/main/java/org/schabi/newpipe/player/PlayQueueActivity.java # app/src/main/java/org/schabi/newpipe/player/Player.java # app/src/main/java/org/schabi/newpipe/settings/SettingsResourceRegistry.java # app/src/main/java/us/shandian/giga/service/DownloadManagerService.java # app/src/main/res/values-es/strings.xml # app/src/main/res/values-it/strings.xml # app/src/main/res/values-zh-rTW/strings.xml # app/src/main/res/values/strings.xml # doc/README.es.md # doc/README.ja.md # doc/README.ko.md # doc/README.pt_BR.md # doc/README.ro.md # doc/README.so.md # doc/README.tr.md
2 parents f112058 + 1e8efa7 commit ed6a94b

File tree

338 files changed

+8066
-2083
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

338 files changed

+8066
-2083
lines changed

.github/CONTRIBUTING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
### Please do **not** open pull requests for *new features* now, as we are planning to rewrite large chunks of the code. Only bugfix PRs will be accepted. More details will be announced soon!
2+
13
NewPipe contribution guidelines
24
===============================
35

.github/ISSUE_TEMPLATE/question.yml renamed to .github/DISCUSSION_TEMPLATE/questions.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
name: Question
22
description: Ask about anything NewPipe-related
3-
labels: [question, needs triage]
3+
labels: [question]
44
body:
55
- type: markdown
66
attributes:
77
value: |
8-
Thanks for taking the time to fill out this issue! :hugs:
8+
Thanks for taking the time to fill out this form! :hugs:
99
1010
Note that you can also ask questions on our [IRC channel](https://web.libera.chat/#newpipe).
1111
@@ -14,7 +14,7 @@ body:
1414
attributes:
1515
label: "Checklist"
1616
options:
17-
- label: "I made sure that there are *no existing issues* - [open](https://github.com/TeamNewPipe/NewPipe/issues) or [closed](https://github.com/TeamNewPipe/NewPipe/issues?q=is%3Aissue+is%3Aclosed) - which I could contribute my information to."
17+
- label: "I made sure that there are *no existing issues or discussions* - [open](https://github.com/TeamNewPipe/NewPipe/issues) or [closed](https://github.com/TeamNewPipe/NewPipe/issues?q=is%3Aissue+is%3Aclosed) - which I could contribute my information to."
1818
required: true
1919
- label: "I have read the [FAQ](https://newpipe.net/FAQ/) and my question isn't listed."
2020
required: true

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
blank_issues_enabled: false
22
contact_links:
3+
- name: ❓ Question
4+
url: https://github.com/TeamNewPipe/NewPipe/discussions/new?category=questions
5+
about: Ask about anything NewPipe-related
36
- name: 💬 IRC
47
url: https://web.libera.chat/#newpipe
58
about: Chat with us via IRC for quick Q/A

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#### APK testing
2929
<!-- Use a new, meaningfully named branch. The name is used as a suffix for the app ID to allow installing and testing multiple versions of NewPipe, e.g. "commentfix", if your PR implements a bugfix for comments. (No names like "patch-0" and "feature-1".) -->
3030
<!-- Remove the following line if you directly link the APK created by the CI pipeline. Directly linking is preferred if you need to let users test.-->
31-
The APK can be found by going to the "Checks" tab below the title. On the left pane, click on "CI", scroll down to "artifacts" and click "app" to download the zip file which contains the debug APK of this PR.
31+
The APK can be found by going to the "Checks" tab below the title. On the left pane, click on "CI", scroll down to "artifacts" and click "app" to download the zip file which contains the debug APK of this PR. You can find more info and a video demonstration [on this wiki page](https://github.com/TeamNewPipe/NewPipe/wiki/Download-APK-for-PR).
3232

3333
#### Due diligence
3434
- [ ] I read the [contribution guidelines](https://github.com/TeamNewPipe/NewPipe/blob/HEAD/.github/CONTRIBUTING.md).

.github/workflows/ci.yml

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,14 @@ jobs:
4242
- name: create and checkout branch
4343
# push events already checked out the branch
4444
if: github.event_name == 'pull_request'
45-
run: git checkout -B ${{ github.head_ref }}
45+
env:
46+
BRANCH: ${{ github.head_ref }}
47+
run: git checkout -B "$BRANCH"
4648

47-
- name: set up JDK 11
49+
- name: set up JDK 17
4850
uses: actions/setup-java@v3
4951
with:
50-
java-version: 11
52+
java-version: 17
5153
distribution: "temurin"
5254
cache: 'gradle'
5355

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

7279
permissions:
7380
contents: read
7481

7582
steps:
7683
- uses: actions/checkout@v3
7784

78-
- name: set up JDK 11
85+
- name: set up JDK 17
7986
uses: actions/setup-java@v3
8087
with:
81-
java-version: 11
88+
java-version: 17
8289
distribution: "temurin"
8390
cache: 'gradle'
8491

8592
- name: Run android tests
8693
uses: reactivecircus/android-emulator-runner@v2
8794
with:
8895
api-level: ${{ matrix.api-level }}
89-
# workaround to emulator bug: https://github.com/ReactiveCircus/android-emulator-runner/issues/160
90-
emulator-build: 7425822
96+
target: ${{ matrix.target }}
97+
arch: ${{ matrix.arch }}
9198
script: ./gradlew connectedCheck --stacktrace
9299

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

111-
- name: Set up JDK 11
118+
- name: Set up JDK 17
112119
uses: actions/setup-java@v3
113120
with:
114-
java-version: 11 # Sonar requires JDK 11
121+
java-version: 17
115122
distribution: "temurin"
116123
cache: 'gradle'
117124

.github/workflows/image-minimizer.js

Lines changed: 64 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ module.exports = async ({github, context}) => {
1717
initialBody = context.payload.comment.body;
1818
} else if (context.eventName == 'issues') {
1919
initialBody = context.payload.issue.body;
20+
} else if (context.eventName == 'pull_request') {
21+
initialBody = context.payload.pull_request.body;
2022
} else {
2123
console.log('Aborting: No body found');
2224
return;
@@ -30,10 +32,12 @@ module.exports = async ({github, context}) => {
3032
}
3133

3234
// Regex for finding images (simple variant) ![ALT_TEXT](https://*.githubusercontent.com/<number>/<variousHexStringsAnd->.<fileExtension>)
33-
const REGEX_IMAGE_LOOKUP = /\!\[(.*)\]\((https:\/\/[-a-z0-9]+\.githubusercontent\.com\/\d+\/[-0-9a-f]{32,512}\.(jpg|gif|png))\)/gm;
35+
const REGEX_USER_CONTENT_IMAGE_LOOKUP = /\!\[(.*)\]\((https:\/\/[-a-z0-9]+\.githubusercontent\.com\/\d+\/[-0-9a-f]{32,512}\.(jpg|gif|png))\)/gm;
36+
const REGEX_ASSETS_IMAGE_LOCKUP = /\!\[(.*)\]\((https:\/\/github\.com\/[-\w\d]+\/[-\w\d]+\/assets\/\d+\/[\-0-9a-f]{32,512})\)/gm;
3437

3538
// Check if we found something
36-
let foundSimpleImages = REGEX_IMAGE_LOOKUP.test(initialBody);
39+
let foundSimpleImages = REGEX_USER_CONTENT_IMAGE_LOOKUP.test(initialBody)
40+
|| REGEX_ASSETS_IMAGE_LOCKUP.test(initialBody);
3741
if (!foundSimpleImages) {
3842
console.log('Found no simple images to process');
3943
return;
@@ -47,53 +51,8 @@ module.exports = async ({github, context}) => {
4751
var wasMatchModified = false;
4852

4953
// Try to find and replace the images with minimized ones
50-
let newBody = await replaceAsync(initialBody, REGEX_IMAGE_LOOKUP, async (match, g1, g2) => {
51-
console.log(`Found match '${match}'`);
52-
53-
if (g1.endsWith(IGNORE_ALT_NAME_END)) {
54-
console.log(`Ignoring match '${match}': IGNORE_ALT_NAME_END`);
55-
return match;
56-
}
57-
58-
let probeAspectRatio = 0;
59-
let shouldModify = false;
60-
try {
61-
console.log(`Probing ${g2}`);
62-
let probeResult = await probe(g2);
63-
if (probeResult == null) {
64-
throw 'No probeResult';
65-
}
66-
if (probeResult.hUnits != 'px') {
67-
throw `Unexpected probeResult.hUnits (expected px but got ${probeResult.hUnits})`;
68-
}
69-
if (probeResult.height <= 0) {
70-
throw `Unexpected probeResult.height (height is invalid: ${probeResult.height})`;
71-
}
72-
if (probeResult.wUnits != 'px') {
73-
throw `Unexpected probeResult.wUnits (expected px but got ${probeResult.wUnits})`;
74-
}
75-
if (probeResult.width <= 0) {
76-
throw `Unexpected probeResult.width (width is invalid: ${probeResult.width})`;
77-
}
78-
console.log(`Probing resulted in ${probeResult.width}x${probeResult.height}px`);
79-
80-
probeAspectRatio = probeResult.width / probeResult.height;
81-
shouldModify = probeResult.height > IMG_MAX_HEIGHT_PX && probeAspectRatio < MIN_ASPECT_RATIO;
82-
} catch(e) {
83-
console.log('Probing failed:', e);
84-
// Immediately abort
85-
return match;
86-
}
87-
88-
if (shouldModify) {
89-
wasMatchModified = true;
90-
console.log(`Modifying match '${match}'`);
91-
return `<img alt="${g1}" src="${g2}" width=${Math.min(600, (IMG_MAX_HEIGHT_PX * probeAspectRatio).toFixed(0))} />`;
92-
}
93-
94-
console.log(`Match '${match}' is ok/will not be modified`);
95-
return match;
96-
});
54+
let newBody = await replaceAsync(initialBody, REGEX_USER_CONTENT_IMAGE_LOOKUP, minimizeAsync);
55+
newBody = await replaceAsync(newBody, REGEX_ASSETS_IMAGE_LOCKUP, minimizeAsync);
9756

9857
if (!wasMatchModified) {
9958
console.log('Nothing was modified. Skipping update');
@@ -117,6 +76,14 @@ module.exports = async ({github, context}) => {
11776
repo: context.repo.repo,
11877
body: newBody
11978
});
79+
} else if (context.eventName == 'pull_request') {
80+
console.log('Updating pull request', context.payload.pull_request.number);
81+
await github.rest.pulls.update({
82+
pull_number: context.payload.pull_request.number,
83+
owner: context.repo.owner,
84+
repo: context.repo.repo,
85+
body: newBody
86+
});
12087
}
12188

12289
// Asnyc replace function from https://stackoverflow.com/a/48032528
@@ -129,4 +96,52 @@ module.exports = async ({github, context}) => {
12996
const data = await Promise.all(promises);
13097
return str.replace(regex, () => data.shift());
13198
}
99+
100+
async function minimizeAsync(match, g1, g2) {
101+
console.log(`Found match '${match}'`);
102+
103+
if (g1.endsWith(IGNORE_ALT_NAME_END)) {
104+
console.log(`Ignoring match '${match}': IGNORE_ALT_NAME_END`);
105+
return match;
106+
}
107+
108+
let probeAspectRatio = 0;
109+
let shouldModify = false;
110+
try {
111+
console.log(`Probing ${g2}`);
112+
let probeResult = await probe(g2);
113+
if (probeResult == null) {
114+
throw 'No probeResult';
115+
}
116+
if (probeResult.hUnits != 'px') {
117+
throw `Unexpected probeResult.hUnits (expected px but got ${probeResult.hUnits})`;
118+
}
119+
if (probeResult.height <= 0) {
120+
throw `Unexpected probeResult.height (height is invalid: ${probeResult.height})`;
121+
}
122+
if (probeResult.wUnits != 'px') {
123+
throw `Unexpected probeResult.wUnits (expected px but got ${probeResult.wUnits})`;
124+
}
125+
if (probeResult.width <= 0) {
126+
throw `Unexpected probeResult.width (width is invalid: ${probeResult.width})`;
127+
}
128+
console.log(`Probing resulted in ${probeResult.width}x${probeResult.height}px`);
129+
130+
probeAspectRatio = probeResult.width / probeResult.height;
131+
shouldModify = probeResult.height > IMG_MAX_HEIGHT_PX && probeAspectRatio < MIN_ASPECT_RATIO;
132+
} catch(e) {
133+
console.log('Probing failed:', e);
134+
// Immediately abort
135+
return match;
136+
}
137+
138+
if (shouldModify) {
139+
wasMatchModified = true;
140+
console.log(`Modifying match '${match}'`);
141+
return `<img alt="${g1}" src="${g2}" width=${Math.min(600, (IMG_MAX_HEIGHT_PX * probeAspectRatio).toFixed(0))} />`;
142+
}
143+
144+
console.log(`Match '${match}' is ok/will not be modified`);
145+
return match;
146+
}
132147
}

.github/workflows/image-minimizer.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ on:
55
types: [created, edited]
66
issues:
77
types: [opened, edited]
8+
pull_request:
9+
types: [opened, edited]
810

911
permissions:
1012
issues: write

0 commit comments

Comments
 (0)