From 05ba1f09b68898ef673c2cd629ef28b577e8cf4f Mon Sep 17 00:00:00 2001 From: dumbmoron Date: Fri, 2 Aug 2024 16:37:23 +0000 Subject: [PATCH 1/5] youtube: periodically refresh innertube player --- src/modules/processing/services/youtube.js | 35 ++++++++++++++-------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/src/modules/processing/services/youtube.js b/src/modules/processing/services/youtube.js index d3ee5602..9bfc3919 100644 --- a/src/modules/processing/services/youtube.js +++ b/src/modules/processing/services/youtube.js @@ -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,11 +50,12 @@ const transformSessionData = (cookie) => { } const cloneInnertube = async (customFetch) => { - const innertube = await ytBase; - if (innertube instanceof Error) { - if (innertube?.message?.endsWith("decipher algorithm")) { - return { error: "ErrorYoutubeDecipher" } - } else 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( @@ -97,13 +100,19 @@ const cloneInnertube = async (customFetch) => { } export default async function(o) { - const yt = await cloneInnertube( - (input, init) => fetch(input, { - ...init, - dispatcher: o.dispatcher - }) - ); - if (yt.error) return yt; + 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; From afa33c404355e1a00d884a2db837233bca54f7f6 Mon Sep 17 00:00:00 2001 From: dumbmoron Date: Sat, 3 Aug 2024 16:46:45 +0000 Subject: [PATCH 2/5] ci: add build action for `develop` tag --- .github/workflows/docker-develop.yml | 55 ++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 .github/workflows/docker-develop.yml diff --git a/.github/workflows/docker-develop.yml b/.github/workflows/docker-develop.yml new file mode 100644 index 00000000..e89eeae0 --- /dev/null +++ b/.github/workflows/docker-develop.yml @@ -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 From 4e66a3813e49b43d97e112abbbe0034a7499e6ab Mon Sep 17 00:00:00 2001 From: dumbmoron Date: Sun, 8 Sep 2024 14:55:15 +0000 Subject: [PATCH 3/5] github: replace markdown issue templates with issue forms --- .github/ISSUE_TEMPLATE/bug-main-instance.md | 36 --------------- .github/ISSUE_TEMPLATE/bug-main-instance.yml | 47 ++++++++++++++++++++ .github/ISSUE_TEMPLATE/bug-report.md | 36 --------------- .github/ISSUE_TEMPLATE/bug-report.yml | 47 ++++++++++++++++++++ .github/ISSUE_TEMPLATE/feature-request.md | 15 ------- .github/ISSUE_TEMPLATE/feature-request.yml | 23 ++++++++++ .github/ISSUE_TEMPLATE/hosting-help.md | 12 ----- .github/ISSUE_TEMPLATE/hosting-help.yml | 21 +++++++++ .github/ISSUE_TEMPLATE/service-request.md | 18 -------- .github/ISSUE_TEMPLATE/service-request.yml | 40 +++++++++++++++++ 10 files changed, 178 insertions(+), 117 deletions(-) delete mode 100644 .github/ISSUE_TEMPLATE/bug-main-instance.md create mode 100644 .github/ISSUE_TEMPLATE/bug-main-instance.yml delete mode 100644 .github/ISSUE_TEMPLATE/bug-report.md create mode 100644 .github/ISSUE_TEMPLATE/bug-report.yml delete mode 100644 .github/ISSUE_TEMPLATE/feature-request.md create mode 100644 .github/ISSUE_TEMPLATE/feature-request.yml delete mode 100644 .github/ISSUE_TEMPLATE/hosting-help.md create mode 100644 .github/ISSUE_TEMPLATE/hosting-help.yml delete mode 100644 .github/ISSUE_TEMPLATE/service-request.md create mode 100644 .github/ISSUE_TEMPLATE/service-request.yml diff --git a/.github/ISSUE_TEMPLATE/bug-main-instance.md b/.github/ISSUE_TEMPLATE/bug-main-instance.md deleted file mode 100644 index 088811b3..00000000 --- a/.github/ISSUE_TEMPLATE/bug-main-instance.md +++ /dev/null @@ -1,36 +0,0 @@ ---- -name: main instance bug report -about: report an issue with cobalt.tools or api.cobalt.tools -title: '[short description of the bug]' -labels: main instance issue -assignees: '' - ---- - -### bug description -clear and concise description of what the issue is. - -### reproduction steps -steps to reproduce the described behavior. -here's an example of what it could look like: -1. go to '...' -2. click on '....' -3. download [media type] from [service] -4. see error - -### screenshots -if applicable, add screenshots or screen recordings to support your explanation. -if not, remove this section. - -### links -if applicable, add links that cause the issue. more = better. -if not, remove this section. - -### platform information -- OS [e.g. iOS, windows] -- browser [e.g. chrome, safari, firefox] -- version [e.g. 115] - -### additional context -add any other context about the problem here if applicable. -if not, remove this section. diff --git a/.github/ISSUE_TEMPLATE/bug-main-instance.yml b/.github/ISSUE_TEMPLATE/bug-main-instance.yml new file mode 100644 index 00000000..5763dbe8 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug-main-instance.yml @@ -0,0 +1,47 @@ +name: main instance bug report +description: "report an issue with cobalt.tools or api.cobalt.tools" +labels: ["main instance issue"] +body: + - type: textarea + id: bug-description + attributes: + label: bug description + description: "clear and concise description of what the issue is." + validations: + required: true + - type: textarea + id: repro-steps + attributes: + label: reproduction steps + description: steps to reproduce the described behavior. + placeholder: | + 1. go to '...' + 2. click on '....' + 3. download [media type] from [service] + 4. see error + validations: + required: true + - type: textarea + id: screenshots + attributes: + label: screenshots + description: if applicable, add screenshots or screen recordings to support your explanation. + - type: textarea + id: links + attributes: + label: links + description: if applicable, add links that cause the issue. more = better. + render: shell + - type: input + id: platform + attributes: + label: platform information + description: "the operating system, browser and their versions where you encounter the issue" + placeholder: safari 7 on mac os x 10.8 + validations: + required: true + - type: textarea + id: more-context + attributes: + label: additional context + description: add any other context about the problem here if applicable. \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/bug-report.md b/.github/ISSUE_TEMPLATE/bug-report.md deleted file mode 100644 index 4370171c..00000000 --- a/.github/ISSUE_TEMPLATE/bug-report.md +++ /dev/null @@ -1,36 +0,0 @@ ---- -name: bug report -about: report a global issue with the cobalt codebase -title: '[short description of the bug]' -labels: bug -assignees: '' - ---- - -### bug description -clear and concise description of what the issue is. - -### reproduction steps -steps to reproduce the described behavior. -here's an example of what it could look like: -1. go to '...' -2. click on '....' -3. download [media type] from [service] -4. see error - -### screenshots -if applicable, add screenshots or screen recordings to support your explanation. -if not, remove this section. - -### links -if applicable, add links that cause the issue. more = better. -if not, remove this section. - -### platform information -- OS [e.g. iOS, windows] -- browser [e.g. chrome, safari, firefox] -- version [e.g. 115] - -### additional context -add any other context about the problem here if applicable. -if not, remove this section. diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml new file mode 100644 index 00000000..3161dcd4 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -0,0 +1,47 @@ +name: bug report +description: report a global issue with the cobalt codebase +labels: ["bug"] +body: + - type: textarea + id: bug-description + attributes: + label: bug description + description: "clear and concise description of what the issue is." + validations: + required: true + - type: textarea + id: repro-steps + attributes: + label: reproduction steps + description: steps to reproduce the described behavior. + placeholder: | + 1. go to '...' + 2. click on '....' + 3. download [media type] from [service] + 4. see error + validations: + required: true + - type: textarea + id: screenshots + attributes: + label: screenshots + description: if applicable, add screenshots or screen recordings to support your explanation. + - type: textarea + id: links + attributes: + label: links + description: if applicable, add links that cause the issue. more = better. + render: shell + - type: input + id: platform + attributes: + label: platform information + description: "the operating system, browser and their versions where you encounter the issue" + placeholder: safari 7 on mac os x 10.8 + validations: + required: true + - type: textarea + id: more-context + attributes: + label: additional context + description: add any other context about the problem here if applicable. \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/feature-request.md b/.github/ISSUE_TEMPLATE/feature-request.md deleted file mode 100644 index 806b2bdf..00000000 --- a/.github/ISSUE_TEMPLATE/feature-request.md +++ /dev/null @@ -1,15 +0,0 @@ ---- -name: feature request -about: suggest a feature for cobalt -title: '[short feature request description]' -labels: feature request -assignees: '' - ---- - -### describe the feature you'd like to see -clear and concise description of the feature you want to see in cobalt. - -### additional context -if applicable, add any other context or screenshots related to the feature request here. -if not, remove this section. diff --git a/.github/ISSUE_TEMPLATE/feature-request.yml b/.github/ISSUE_TEMPLATE/feature-request.yml new file mode 100644 index 00000000..abeb6ea3 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature-request.yml @@ -0,0 +1,23 @@ +name: feature request +description: suggest a feature for cobalt +labels: ["feature request"] +body: + - type: markdown + attributes: + value: | + thanks for taking the time to make a feature request! + before you start, please make to read the "adding features or support for services" section of + our [contributor guidelines](https://github.com/imputnet/cobalt/blob/current/CONTRIBUTING.md#adding-features-or-support-for-services) + to make sure your request is a good fit for cobalt. + - type: textarea + id: feat-description + attributes: + label: describe the feature you'd like to see + description: "clear and concise description of the feature you want to see in cobalt." + validations: + required: true + - type: textarea + id: more-context + attributes: + label: additional context + description: add any other context about the problem here if applicable. \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/hosting-help.md b/.github/ISSUE_TEMPLATE/hosting-help.md deleted file mode 100644 index d10a677b..00000000 --- a/.github/ISSUE_TEMPLATE/hosting-help.md +++ /dev/null @@ -1,12 +0,0 @@ ---- -name: instance hosting help -about: ask any question regarding cobalt instance hosting -title: '[short description of the problem]' -labels: instance hosting help -assignees: '' - ---- - -### problem description -describe what issue you're having, clearly and concisely. -support your description with screenshots/links/etc when needed. diff --git a/.github/ISSUE_TEMPLATE/hosting-help.yml b/.github/ISSUE_TEMPLATE/hosting-help.yml new file mode 100644 index 00000000..ea0e43fb --- /dev/null +++ b/.github/ISSUE_TEMPLATE/hosting-help.yml @@ -0,0 +1,21 @@ +name: instance hosting help +description: ask any question regarding cobalt instance hosting +labels: ["instance hosting help"] +body: + - type: textarea + id: problem-description + attributes: + label: problem description + description: | + describe what issue you're having, clearly and concisely. + support your description with screenshots/links/etc when needed. + validations: + required: true + - type: textarea + id: configuration + attributes: + label: your instance configuration + description: | + if applicable, add or describe your instance configuration (e.g. compose file) or any changes you made to it. + please **do not share senstive information** such as secret keys or the contents of your cookies file! + render: shell \ No newline at end of file diff --git a/.github/ISSUE_TEMPLATE/service-request.md b/.github/ISSUE_TEMPLATE/service-request.md deleted file mode 100644 index ca948656..00000000 --- a/.github/ISSUE_TEMPLATE/service-request.md +++ /dev/null @@ -1,18 +0,0 @@ ---- -name: service request -about: request service support in cobalt -title: 'add support for [service name]' -labels: service request -assignees: '' - ---- - -### service name & description -provide the service name and brief description of what it is. - -### link samples for the service you'd like cobalt to support -list of links that cobalt should recognize. -could be regular video link, shared video link, mobile video link, shortened link, etc. - -### additional context -any additional context or screenshots should go here. if there aren't any, just remove this part. diff --git a/.github/ISSUE_TEMPLATE/service-request.yml b/.github/ISSUE_TEMPLATE/service-request.yml new file mode 100644 index 00000000..2b710d19 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/service-request.yml @@ -0,0 +1,40 @@ +name: service request +description: "request service support in cobalt" +title: "add support for [service name]" +labels: ["service request"] +body: + - type: markdown + attributes: + value: | + thanks for taking the time to make a service request! + before you start, please make to read the "adding features or support for services" section of + our [contributor guidelines](https://github.com/imputnet/cobalt/blob/current/CONTRIBUTING.md#adding-features-or-support-for-services) + to make sure your request is a good fit for cobalt. + - type: input + id: service-name + attributes: + label: service name + validations: + required: true + - type: textarea + id: service-description + attributes: + label: service description + description: a brief description of what the service is and/or what it provides + validations: + required: true + - type: textarea + id: link-samples + attributes: + label: link samples + description: | + list of links that cobalt should recognize. + could be regular video link, shared video link, mobile video link, shortened link, etc. + render: shell + validations: + required: true + - type: textarea + id: more-context + attributes: + label: additional context + description: any additional context or screenshots should go here. From 37d4bdb6edfadb653ed95c5d13ac73325726035b Mon Sep 17 00:00:00 2001 From: dumbmoron Date: Sun, 8 Sep 2024 15:02:33 +0000 Subject: [PATCH 4/5] github: disallow blank issues and add discord link --- .github/ISSUE_TEMPLATE/config.yml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/config.yml diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 00000000..dfa685ce --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,7 @@ +blank_issues_enabled: false +contact_links: + - name: discord community + url: https://discord.gg/pQPt8HBUPu + about: | + ask questions and discuss cobalt with others at any time. + usually faster responses as more people are there to help. \ No newline at end of file From 620c644bdfb7b47a43a70524e8f9df408553baf5 Mon Sep 17 00:00:00 2001 From: dumbmoron Date: Sun, 8 Sep 2024 15:09:02 +0000 Subject: [PATCH 5/5] github: reformat markdown description of request templates --- .github/ISSUE_TEMPLATE/feature-request.yml | 3 +-- .github/ISSUE_TEMPLATE/service-request.yml | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/feature-request.yml b/.github/ISSUE_TEMPLATE/feature-request.yml index abeb6ea3..8140e41a 100644 --- a/.github/ISSUE_TEMPLATE/feature-request.yml +++ b/.github/ISSUE_TEMPLATE/feature-request.yml @@ -7,8 +7,7 @@ body: value: | thanks for taking the time to make a feature request! before you start, please make to read the "adding features or support for services" section of - our [contributor guidelines](https://github.com/imputnet/cobalt/blob/current/CONTRIBUTING.md#adding-features-or-support-for-services) - to make sure your request is a good fit for cobalt. + our [contributor guidelines](https://github.com/imputnet/cobalt/blob/current/CONTRIBUTING.md#adding-features-or-support-for-services) to make sure your request is a good fit for cobalt. - type: textarea id: feat-description attributes: diff --git a/.github/ISSUE_TEMPLATE/service-request.yml b/.github/ISSUE_TEMPLATE/service-request.yml index 2b710d19..1d2b5b25 100644 --- a/.github/ISSUE_TEMPLATE/service-request.yml +++ b/.github/ISSUE_TEMPLATE/service-request.yml @@ -8,8 +8,7 @@ body: value: | thanks for taking the time to make a service request! before you start, please make to read the "adding features or support for services" section of - our [contributor guidelines](https://github.com/imputnet/cobalt/blob/current/CONTRIBUTING.md#adding-features-or-support-for-services) - to make sure your request is a good fit for cobalt. + our [contributor guidelines](https://github.com/imputnet/cobalt/blob/current/CONTRIBUTING.md#adding-features-or-support-for-services) to make sure your request is a good fit for cobalt. - type: input id: service-name attributes: