Merge branch 'current' into feat/threads

This commit is contained in:
Snazzah 2024-08-08 19:58:30 -05:00 committed by GitHub
commit cce24b9f34
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 92 additions and 22 deletions

55
.github/workflows/docker-develop.yml vendored Normal file
View file

@ -0,0 +1,55 @@
name: Build Docker development image
on:
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get release metadata
id: release-meta
run: |
version=$(cat package.json | jq -r .version)
echo "commit_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "version=$version" >> $GITHUB_OUTPUT
echo "major_version=$(echo "$version" | cut -d. -f1)" >> $GITHUB_OUTPUT
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
tags: type=raw,value=develop
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max

View file

@ -48,7 +48,7 @@ jobs:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64,linux/arm/v7

18
package-lock.json generated
View file

@ -24,7 +24,7 @@
"set-cookie-parser": "2.6.0",
"undici": "^5.19.1",
"url-pattern": "1.0.3",
"youtubei.js": "^10.2.0"
"youtubei.js": "^10.3.0"
},
"engines": {
"node": ">=18"
@ -76,6 +76,7 @@
"version": "8.12.1",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.1.tgz",
"integrity": "sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg==",
"license": "MIT",
"bin": {
"acorn": "bin/acorn"
},
@ -683,12 +684,13 @@
}
},
"node_modules/jintr": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/jintr/-/jintr-2.0.0.tgz",
"integrity": "sha512-RiVlevxttZ4eHEYB2dXKXDXluzHfRuw0DJQGsYuKCc5IvZj5/GbOakeqVX+Bar/G9kTty9xDJREcxukurkmYLA==",
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/jintr/-/jintr-2.1.1.tgz",
"integrity": "sha512-89cwX4ouogeDGOBsEVsVYsnWWvWjchmwXBB4kiBhmjOKw19FiOKhNhMhpxhTlK2ctl7DS+d/ethfmuBpzoNNgA==",
"funding": [
"https://github.com/sponsors/LuanRT"
],
"license": "MIT",
"dependencies": {
"acorn": "^8.8.0"
}
@ -1123,15 +1125,15 @@
}
},
"node_modules/youtubei.js": {
"version": "10.2.0",
"resolved": "https://registry.npmjs.org/youtubei.js/-/youtubei.js-10.2.0.tgz",
"integrity": "sha512-JLKW9AHQ1qrTwBbre1aDkH8UJFmNcc4+kOSaVou5jSY7AzfFPFJK0yvX6afnLst0UVC9wfXHrLiNx93sutVErA==",
"version": "10.3.0",
"resolved": "https://registry.npmjs.org/youtubei.js/-/youtubei.js-10.3.0.tgz",
"integrity": "sha512-tLmeJCECK2xF2hZZtF2nEqirdKVNLFSDpa0LhTaXY3tngtL7doQXyy7M2CLueramDTlmCnFaW+rctHirTPFaRQ==",
"funding": [
"https://github.com/sponsors/LuanRT"
],
"license": "MIT",
"dependencies": {
"jintr": "^2.0.0",
"jintr": "^2.1.1",
"tslib": "^2.5.0",
"undici": "^5.19.1"
}

View file

@ -40,7 +40,7 @@
"set-cookie-parser": "2.6.0",
"undici": "^5.19.1",
"url-pattern": "1.0.3",
"youtubei.js": "^10.2.0"
"youtubei.js": "^10.3.0"
},
"optionalDependencies": {
"freebind": "^0.2.2"

View file

@ -160,6 +160,7 @@
"ErrorYTAgeRestrict": "this youtube video is age-restricted, so i can't see it. try another one!",
"ErrorYTLogin": "couldn't get this youtube video because it requires an account to view.\n\nthis limitation is done by google to seemingly stop scraping, affecting all 3rd party tools and even their own clients.\n\ntry again, but if issue persists, {ContactLink}.",
"ErrorYTRateLimit": "i got rate limited by youtube. try again in a few seconds, but if issue persists, {ContactLink}.",
"ErrorInvalidAcceptHeader": "invalid accept header"
"ErrorInvalidAcceptHeader": "invalid accept header",
"ErrorYoutubeDecipher": "youtube updated its decipher algorithm, so i can't get the video info. try again, but if it still doesn't work, please <a class=\"text-backdrop link\" href=\"{repo}\" target=\"_blank\">create an issue on github</a>."
}
}

View file

@ -6,7 +6,9 @@ import { env } from "../../config.js";
import { cleanString } from "../../sub/utils.js";
import { getCookie, updateCookieValues } from "../cookie/manager.js";
const ytBase = Innertube.create().catch(e => e);
const PLAYER_REFRESH_PERIOD = 1000 * 60 * 15; // ms
let innertube, lastRefreshedAt;
const codecMatch = {
h264: {
@ -48,9 +50,12 @@ const transformSessionData = (cookie) => {
}
const cloneInnertube = async (customFetch) => {
const innertube = await ytBase;
if (innertube instanceof Error) {
throw innertube;
const shouldRefreshPlayer = lastRefreshedAt + PLAYER_REFRESH_PERIOD < new Date();
if (!innertube || shouldRefreshPlayer) {
innertube = await Innertube.create({
fetch: customFetch
});
lastRefreshedAt = +new Date();
}
const session = new Session(
@ -95,12 +100,19 @@ const cloneInnertube = async (customFetch) => {
}
export default async function(o) {
const yt = await cloneInnertube(
(input, init) => fetch(input, {
...init,
dispatcher: o.dispatcher
})
);
let yt;
try {
yt = await cloneInnertube(
(input, init) => fetch(input, {
...init,
dispatcher: o.dispatcher
})
);
} catch(e) {
if (e.message?.endsWith("decipher algorithm")) {
return { error: "ErrorYoutubeDecipher" }
} else throw e;
}
const quality = o.quality === "max" ? "9000" : o.quality;