Skip to content

Use specific fork from iv‐org YouTube.js

Émilien (perso) edited this page Mar 25, 2025 · 5 revisions

Description

This tutorial is for using a specific fork from iv-org/YouTube.js, like using new commits that are still not in YouTube.js itself.

  1. Create a new branch in https://github.com/iv-org/YouTube.js
  2. Update the master branch against the new commits from LuanRT/YouTube.js (can use the Sync fork button in GitHub)
  3. Do your things, like apply commits from an existing PR at https://github.com/LuanRT/YouTube.js
  4. Once your tests are correct, run these new commands:
    npm ci
    npm run build:deno
    This will create a folder called "deno".
  5. Delete existing deno branch if it exists: git branch -D deno.
  6. Create a new branch: git switch --orphan deno
  7. Now create a file called deno.ts with this content: https://github.com/LuanRT/YouTube.js/blob/deno/deno.ts
    wget https://github.com/iv-org/YouTube.js/raw/refs/heads/deno/deno.ts
  8. Add deno.ts and deno folder to git tracking, commit and push:
    git add deno.ts deno/
    git commit -m "changes from branch XXX"
    git push -f origin deno
  9. Go to deno.json in invidious-companion code and change the URLs from LuanRT/YouTube.js/refs/tags/vXX.X.X-deno to iv-org/YouTube.js/LATEST_COMMITID_FROM_DENO_BRANCH
    diff --git a/deno.json b/deno.json
    index 02ea3a2..bb78869 100644
    --- a/deno.json
    +++ b/deno.json
    @@ -6,10 +6,10 @@
       "imports": {
         "hono": "jsr:@hono/[email protected]",
         "@std/toml": "jsr:@std/[email protected]",
    -    "youtubei.js": "https://raw.githubusercontent.com/LuanRT/YouTube.js/refs/tags/v13.1.0-deno/deno.ts",
    -    "youtubei.js/Utils": "https://raw.githubusercontent.com/LuanRT/YouTube.js/refs/tags/v13.1.0-deno/deno/src/utils/Utils.ts",
    -    "youtubei.js/NavigationEndpoint": "https://raw.githubusercontent.com/LuanRT/YouTube.js/refs/tags/v13.1.0-deno/deno/src/parser/classes/NavigationEndpoint.ts",
    -    "youtubei.js/PlayerCaptionsTracklist": "https://raw.githubusercontent.com/LuanRT/YouTube.js/refs/tags/v13.1.0-deno/deno/src/parser/classes/PlayerCaptionsTracklist.ts",
    +    "youtubei.js": "https://raw.githubusercontent.com/iv-org/YouTube.js/LATEST_COMMITID_FROM_DENO_BRANCH/deno.ts",
    +    "youtubei.js/Utils": "https://raw.githubusercontent.com/iv-org/YouTube.js/LATEST_COMMITID_FROM_DENO_BRANCH/deno/src/utils/Utils.ts",
    +    "youtubei.js/NavigationEndpoint": "https://raw.githubusercontent.com/iv-org/YouTube.js/LATEST_COMMITID_FROM_DENO_BRANCH/deno/src/parser/classes/NavigationEndpoint.ts",
    +    "youtubei.js/PlayerCaptionsTracklist": "https://raw.githubusercontent.com/iv-org/YouTube.js/LATEST_COMMITID_FROM_DENO_BRANCH/deno/src/parser/classes/PlayerCaptionsTracklist.ts",
         "jsdom": "npm:[email protected]",
         "bgutils": "https://esm.sh/[email protected]",
         "estree": "https://esm.sh/@types/[email protected]",
  10. Update deno.lock using:
    SERVER_SECRET_KEY=yoh3deiSh3Aih1iw deno task dev
    deno check src/**
    
  11. Create a PR for these changes and merge it if it's working great.

Once the changes are upstreamed to YouTube.js, please revert to YouTube.js repo.

Clone this wiki locally