Implement naming and releases

This commit is contained in:
Simon Sawicki
2025-09-22 18:30:05 +02:00
parent d7bb4cc0cb
commit b904e70181
11 changed files with 167 additions and 50 deletions

29
.github/workflows/release.yml vendored Normal file
View File

@@ -0,0 +1,29 @@
on:
push:
tags:
- "*"
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: denoland/setup-deno@v2
with:
deno-version: v2.x
- uses: astral-sh/setup-uv@v6
with:
python-version: "3.13"
- name: Bundle
run:
# XXX: uv build fails for some reason
uv tool run hatch build --target wheel
- env:
TAG: ${{ github.ref_name }}
run: |
gh release create v${TAG} \
--title "yt-dlp-ejs v${TAG}" \
--notes-from-tag \
--verify-tag \
dist/yt.solver.* \
dist/yt_dlp_ejs*.whl

3
.gitignore vendored
View File

@@ -1,6 +1,7 @@
/dist
*.py[cd]
/yt_dlp_jsc_deno/*.js
/yt_dlp_ejs/**.js
/yt_dlp_ejs/_version.py
/node_modules
/bun.lock
/deno.lock

View File

@@ -1,13 +1,11 @@
# yt-dlp-jsc-deno
# yt-dlp-ejs
Deno backend of builtin JavaScript Challenge Provider for yt-dlp
External JavaScript for yt-dlp supporting many runtimes
## Installation
In the yt-dlp repository, install the """python""" package, either by doing
In the yt-dlp repository, install the python package, either directly or from url:
```console
pip install ../yt-dlp-jsp-deno
pip install git+https://github.com/yt-dlp/ejs@main
```
or from the url.

View File

@@ -1,11 +1,11 @@
[build-system]
requires = ["hatchling", "hatch-build-scripts"]
requires = ["hatchling", "hatch-build-scripts", "hatch-vcs"]
build-backend = "hatchling.build"
[project]
name = "yt-dlp-jsc"
version = "0.0.1"
description = "JavaScript Challenge Provider for yt-dlp supporting many runtimes"
name = "yt-dlp-ejs"
description = "External JavaScript for yt-dlp supporting many runtimes"
dynamic = ["version"]
readme = "README.md"
requires-python = ">=3.9"
license = "Unlicense"
@@ -14,7 +14,7 @@ authors = [
{ name = "Simon Sawicki", email = "contact@grub4k.dev" },
]
classifiers = [
"Development Status :: 4 - Beta",
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
@@ -28,18 +28,24 @@ classifiers = [
dependencies = []
[project.urls]
Documentation = "https://github.com/yt-dlp/yt-dlp-jsc#readme"
Issues = "https://github.com/yt-dlp/yt-dlp-jsc/issues"
Source = "https://github.com/yt-dlp/yt-dlp-jsc"
Documentation = "https://github.com/yt-dlp/ejs#readme"
Issues = "https://github.com/yt-dlp/ejs/issues"
Source = "https://github.com/yt-dlp/ejs"
[tool.hatch.version]
source = "vcs"
[tool.hatch.build.hooks.vcs]
version-file = "yt_dlp_ejs/_version.py"
[[tool.hatch.build.hooks.build-scripts.scripts]]
work_dir = "dist"
out_dir = "yt_dlp_jsc"
out_dir = "yt_dlp_ejs/"
commands = [
"deno install",
"deno task bundle",
]
artifacts = [
"jsc.min.js",
"lib.min.js",
"yt.solver.core.min.js",
"yt.solver.lib.min.js",
]

View File

@@ -13,7 +13,7 @@ export default defineConfig([
input: "input",
meriyah: "meriyah",
},
file: "dist/jsc.js",
file: "dist/yt.solver.core.js",
format: "iife",
},
external: ["astring", "meriyah"],
@@ -34,7 +34,7 @@ export default defineConfig([
input: "input",
meriyah: "meriyah",
},
file: "dist/jsc.min.js",
file: "dist/yt.solver.core.min.js",
compact: true,
format: "iife",
minifyInternalExports: true,
@@ -53,7 +53,7 @@ export default defineConfig([
input: "src/lib.ts",
output: {
name: "lib",
file: "dist/lib.js",
file: "dist/yt.solver.lib.js",
format: "iife",
exports: "named",
},
@@ -69,7 +69,7 @@ export default defineConfig([
input: "src/lib.ts",
output: {
name: "lib",
file: "dist/lib.min.js",
file: "dist/yt.solver.lib.min.js",
compact: true,
format: "iife",
minifyInternalExports: true,

38
run.ts Normal file
View File

@@ -0,0 +1,38 @@
import { exit } from "node:process";
import { readFileSync } from "node:fs";
import { isOneOf } from "./src/utils.ts";
import main from "./src/main.ts";
const args = process.argv.slice(2);
if (args.length < 2) {
console.error(
`ERROR: Missing argument\nusage: ${
process.argv[1]
} <player> [<type>:<request> ...]`,
);
exit(1);
}
const player = readFileSync(args[0], "utf-8");
const requests = {
nsig: [] as string[],
sig: [] as string[],
};
for (const request of args.slice(1)) {
const [type, challenge] = request.split(":", 2);
if (!isOneOf(type, "sig", "nsig")) {
console.error(`ERROR: Unsupported request type: ${type}`);
exit(1);
}
requests[type].push(challenge);
}
console.log(JSON.stringify(main({
type: "player",
player,
output_preprocessed: false,
requests: [
{ type: "nsig", challenges: requests.nsig },
{ type: "sig", challenges: requests.sig },
],
})));

View File

@@ -203,6 +203,54 @@ export const tests: {
},
],
},
{
player: "4f8fa943",
nsig: [
// Synthetic test
{ input: "0eRGgQWJGfT5rFHFj", expected: "JWWr7hDSRpMq5" },
],
sig: [
// Synthetic test
{
input:
"MMGZJMUucirzS_SnrSPYsc85CJNnTUi6GgR5NKn-znQEICACojE8MHS6S7uYq4TGjQX_D4aPk99hNU6wbTvorvVVMgIARwsSdQfJAA",
expected:
"AAJfQdSswRAIgMVVvrovTbw6UNh99kPa4D_XQjGT4qYu7S6SHr8EjoCACIEQnz-nKN5RgG6iUTnNZC58csYPSMnS_SzricuUM",
},
],
},
{
player: "0004de42",
nsig: [
// Synthetic test
{ input: "0eRGgQWJGfT5rFHFj", expected: "OPd7UEsCDmCw4qD0" },
],
sig: [
// Synthetic test
{
input:
"MMGZJMUucirzS_SnrSPYsc85CJNnTUi6GgR5NKn-znQEICACojE8MHS6S7uYq4TGjQX_D4aPk99hNU6wbTvorvVVMgIARwsSdQfJAA",
expected:
"ZJMUucirzS_SnrSPYsc85MJNnTUi6GgR5NCn-znQEICACojE8MHS6S7uYq4TGjQX_D4aPk99hNU6wbTvorvVVMgIARwsSdQ",
},
],
},
{
player: "2b83d2e0",
nsig: [
// Synthetic test
{ input: "0eRGgQWJGfT5rFHFj", expected: "euHbygrCMLksxd" },
],
sig: [
// Synthetic test
{
input:
"MMGZJMUucirzS_SnrSPYsc85CJNnTUi6GgR5NKn-znQEICACojE8MHS6S7uYq4TGjQX_D4aPk99hNU6wbTvorvVVMgIARwsSdQfJA",
expected:
"-MGZJMUucirzS_SnrSPYsc85CJNnTUi6GgR5NKnMznQEICACojE8MHS6S7uYq4TGjQX_D4aPk99hNU6wbTvorvVVMgIARwsSdQfJA",
},
],
},
];
export const players = new Map(

25
yt_dlp_ejs/__init__.py Normal file
View File

@@ -0,0 +1,25 @@
import importlib.resources
import yt_dlp_ejs
# XXX: this reflects package version
from yt_dlp_ejs._version import version
def yt_solver_core() -> str:
"""
Read the contents of the JavaScript core solver bundle as string.
"""
return importlib.resources.read_text(yt_dlp_ejs, 'yt.solver.core.min.js')
def yt_solver_lib() -> str:
"""
Read the contents of the JavaScript library solver bundle as string.
"""
return importlib.resources.read_text(yt_dlp_ejs, 'yt.solver.lib.min.js')
__all__ = [
"core",
"lib",
"version",
]

View File

@@ -1,26 +0,0 @@
import importlib.resources
import importlib.metadata
import yt_dlp_jsc
version = importlib.metadata.version(yt_dlp_jsc.__name__)
def jsc() -> str:
"""
Read the contents of the JavaScript jsc bundle as string.
"""
return importlib.resources.read_text(yt_dlp_jsc, 'jsc.min.js')
def lib() -> str:
"""
Read the contents of the JavaScript library bundle as string.
"""
return importlib.resources.read_text(yt_dlp_jsc, 'lib.min.js')
__all__ = [
"jsc",
"lib",
"version",
]

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long