Skip to content

Commit 34d8220

Browse files
Merge pull request #5 from NonoElRobot/dev
[YT] Fix 403 again merge latest extractor fixes to zen
2 parents 7e7cf7e + 60d5e94 commit 34d8220

File tree

1,154 files changed

+35326
-9874
lines changed

Some content is hidden

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

1,154 files changed

+35326
-9874
lines changed

.github/CONTRIBUTING.md

+2-4
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

@@ -40,10 +42,6 @@ You'll see *exactly* what is sent, be able to add **your comments**, and then se
4042
* Create PRs that cover only **one specific issue/solution/bug**. Do not create PRs that are huge monoliths and could have been split into multiple independent contributions.
4143
* NewPipe uses [NewPipeExtractor](https://github.com/TeamNewPipe/NewPipeExtractor) to fetch data from services. If you need to change something there, you must test your changes in NewPipe. Telling NewPipe to use your extractor version can be accomplished by editing the `app/build.gradle` file: the comments under the "NewPipe libraries" section of `dependencies` will help you out.
4244

43-
### Kotlin in NewPipe
44-
* NewPipe will remain mostly Java for time being
45-
* Contributions containing a simple conversion from Java to Kotlin should be avoided. Conversions to Kotlin should only be done if Kotlin actually brings improvements like bug fixes or better performance which are not, or only with much more effort, implementable in Java. The core team sees Java as an easier to learn and generally well adopted programming language.
46-
4745
### Creating a Pull Request (PR)
4846

4947
* Make changes on a **separate branch** with a meaningful name, not on the _master_ branch or the _dev_ branch. This is commonly known as *feature branch workflow*. You may then send your changes as a pull request (PR) on GitHub.

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

+2-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
name: Question
2-
description: Ask about anything NewPipe-related
3-
labels: [question, needs triage]
41
body:
52
- type: markdown
63
attributes:
74
value: |
8-
Thanks for taking the time to fill out this issue! :hugs:
5+
Thanks for taking the time to fill out this form! :hugs:
96
107
Note that you can also ask questions on our [IRC channel](https://web.libera.chat/#newpipe).
118
@@ -14,7 +11,7 @@ body:
1411
attributes:
1512
label: "Checklist"
1613
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."
14+
- 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."
1815
required: true
1916
- label: "I have read the [FAQ](https://newpipe.net/FAQ/) and my question isn't listed."
2017
required: true

.github/ISSUE_TEMPLATE/bug_report.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ body:
1414
attributes:
1515
label: "Checklist"
1616
options:
17-
- label: "I am able to reproduce the bug with the [latest version](https://github.com/TeamNewPipe/NewPipe/releases/latest)."
17+
- label: "I am able to reproduce the bug with the latest version given here: [CLICK THIS LINK](https://github.com/TeamNewPipe/NewPipe/releases/latest)."
1818
required: true
1919
- 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."
2020
required: true

.github/ISSUE_TEMPLATE/config.yml

+3
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

+1-1
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).
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Add 'size/small' label to any changes with less than 50 lines
2+
size/small:
3+
max: 49
4+
5+
# Add 'size/medium' label to any changes between 50 and 249 lines
6+
size/medium:
7+
min: 50
8+
max: 249
9+
10+
# Add 'size/large' label to any changes between 250 and 749 lines
11+
size/large:
12+
min: 250
13+
max: 749
14+
15+
# Add 'size/giant' label to any changes for more than 749 lines
16+
size/giant:
17+
min: 750

.github/workflows/ci.yml

+36-23
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
branches:
77
- dev
88
- master
9+
- refactor
910
- release**
1011
- zen
1112
paths-ignore:
@@ -39,62 +40,74 @@ jobs:
3940
contents: read
4041

4142
steps:
42-
- uses: actions/checkout@v3
43-
- uses: gradle/wrapper-validation-action@v1
43+
- uses: actions/checkout@v4
44+
- uses: gradle/wrapper-validation-action@v2
4445

4546
- name: create and checkout branch
4647
# push events already checked out the branch
4748
if: github.event_name == 'pull_request'
48-
run: git checkout -B ${{ github.head_ref }}
49+
env:
50+
BRANCH: ${{ github.head_ref }}
51+
run: git checkout -B "$BRANCH"
4952

50-
- name: set up JDK 11
51-
uses: actions/setup-java@v3
53+
- name: set up JDK 17
54+
uses: actions/setup-java@v4
5255
with:
53-
java-version: 11
56+
java-version: 17
5457
distribution: "temurin"
5558
cache: 'gradle'
5659

5760
- name: Build debug APK and run jvm tests
5861
run: ./gradlew assembleDebug lintDebug testDebugUnitTest --stacktrace -DskipFormatKtlint
5962

6063
- name: Upload APK
61-
uses: actions/upload-artifact@v3
64+
uses: actions/upload-artifact@v4
6265
with:
6366
name: app
6467
path: app/build/outputs/apk/debug/*.apk
6568

6669
test-android:
67-
# macos has hardware acceleration. See android-emulator-runner action
68-
runs-on: macos-latest
70+
runs-on: ubuntu-latest
6971
timeout-minutes: 20
7072
strategy:
7173
matrix:
72-
# api-level 19 is min sdk, but throws errors related to desugaring
73-
api-level: [ 21, 29 ]
74+
include:
75+
- api-level: 21
76+
target: default
77+
arch: x86
78+
- api-level: 33
79+
target: google_apis # emulator API 33 only exists with Google APIs
80+
arch: x86_64
7481

7582
permissions:
7683
contents: read
7784

7885
steps:
79-
- uses: actions/checkout@v3
86+
- uses: actions/checkout@v4
87+
88+
- name: Enable KVM
89+
run: |
90+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
91+
sudo udevadm control --reload-rules
92+
sudo udevadm trigger --name-match=kvm
8093
81-
- name: set up JDK 11
82-
uses: actions/setup-java@v3
94+
- name: set up JDK 17
95+
uses: actions/setup-java@v4
8396
with:
84-
java-version: 11
97+
java-version: 17
8598
distribution: "temurin"
8699
cache: 'gradle'
87100

88101
- name: Run android tests
89102
uses: reactivecircus/android-emulator-runner@v2
90103
with:
91104
api-level: ${{ matrix.api-level }}
92-
# workaround to emulator bug: https://github.com/ReactiveCircus/android-emulator-runner/issues/160
93-
emulator-build: 7425822
105+
target: ${{ matrix.target }}
106+
arch: ${{ matrix.arch }}
94107
script: ./gradlew connectedCheck --stacktrace
95108

96109
- name: Upload test report when tests fail # because the printed out stacktrace (console) is too short, see also #7553
97-
uses: actions/upload-artifact@v3
110+
uses: actions/upload-artifact@v4
98111
if: failure()
99112
with:
100113
name: android-test-report-api${{ matrix.api-level }}
@@ -107,19 +120,19 @@ jobs:
107120
contents: read
108121

109122
steps:
110-
- uses: actions/checkout@v3
123+
- uses: actions/checkout@v4
111124
with:
112125
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
113126

114-
- name: Set up JDK 11
115-
uses: actions/setup-java@v3
127+
- name: Set up JDK 17
128+
uses: actions/setup-java@v4
116129
with:
117-
java-version: 11 # Sonar requires JDK 11
130+
java-version: 17
118131
distribution: "temurin"
119132
cache: 'gradle'
120133

121134
- name: Cache SonarCloud packages
122-
uses: actions/cache@v3
135+
uses: actions/cache@v4
123136
with:
124137
path: ~/.sonar/cache
125138
key: ${{ runner.os }}-sonar

.github/workflows/image-minimizer.js

+65-50
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,9 +76,17 @@ 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

122-
// Asnyc replace function from https://stackoverflow.com/a/48032528
89+
// Async replace function from https://stackoverflow.com/a/48032528
12390
async function replaceAsync(str, regex, asyncFn) {
12491
const promises = [];
12592
str.replace(regex, (match, ...args) => {
@@ -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, Math.floor(IMG_MAX_HEIGHT_PX * probeAspectRatio))} />`;
142+
}
143+
144+
console.log(`Match '${match}' is ok/will not be modified`);
145+
return match;
146+
}
132147
}

.github/workflows/image-minimizer.yml

+5-3
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
@@ -15,17 +17,17 @@ jobs:
1517
runs-on: ubuntu-latest
1618

1719
steps:
18-
- uses: actions/checkout@v3
20+
- uses: actions/checkout@v4
1921

20-
- uses: actions/setup-node@v3
22+
- uses: actions/setup-node@v4
2123
with:
2224
node-version: 16
2325

2426
- name: Install probe-image-size
2527
run: npm i [email protected] --ignore-scripts
2628

2729
- name: Minimize simple images
28-
uses: actions/github-script@v6
30+
uses: actions/github-script@v7
2931
timeout-minutes: 3
3032
with:
3133
script: |

0 commit comments

Comments
 (0)