Push tokens to redis for Invidious
Some checks are pending
Docker build image / build (push) Waiting to run
Some checks are pending
Docker build image / build (push) Waiting to run
This commit is contained in:
parent
521da81f57
commit
cf41dd9509
4 changed files with 63 additions and 0 deletions
33
.forgejo/workflows/ci.yml
Normal file
33
.forgejo/workflows/ci.yml
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
name: Docker build image
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
push:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: 'main'
|
||||||
|
steps:
|
||||||
|
- name: Check Out Repo
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Login to git.nadeko.net
|
||||||
|
uses: docker/login-action@v2
|
||||||
|
with:
|
||||||
|
registry: git.nadeko.net
|
||||||
|
username: ${{ secrets.USERNAME }}
|
||||||
|
password: ${{ secrets.PASSWORD }}
|
||||||
|
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v2
|
||||||
|
with:
|
||||||
|
version: latest
|
||||||
|
|
||||||
|
- name: Build and push docker image
|
||||||
|
uses: docker/build-push-action@v3
|
||||||
|
with:
|
||||||
|
context: ./
|
||||||
|
file: ./Dockerfile
|
||||||
|
platforms: linux/amd64
|
||||||
|
push: true
|
||||||
|
tags: git.nadeko.net/Fijxu/youtube-po-token-generator:latest
|
6
Dockerfile
Normal file
6
Dockerfile
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
FROM node:20-alpine
|
||||||
|
WORKDIR /app
|
||||||
|
COPY package*.json ./
|
||||||
|
RUN npm install
|
||||||
|
COPY . .
|
||||||
|
CMD [ "node", "index.js" ]
|
23
index.js
23
index.js
|
@ -1,5 +1,14 @@
|
||||||
const { createTask } = require('./lib/task')
|
const { createTask } = require('./lib/task')
|
||||||
const { fetchVisitorData } = require('./lib/workflow')
|
const { fetchVisitorData } = require('./lib/workflow')
|
||||||
|
const { Redis } = require('ioredis')
|
||||||
|
|
||||||
|
|
||||||
|
const redis = new Redis({ host: process.env.HOST || config.host });
|
||||||
|
|
||||||
|
redis.on('error', (error) => {
|
||||||
|
console.error('Could not connect to Redis:', error);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
|
|
||||||
const generate = async () => {
|
const generate = async () => {
|
||||||
const visitorData = await fetchVisitorData()
|
const visitorData = await fetchVisitorData()
|
||||||
|
@ -8,4 +17,18 @@ const generate = async () => {
|
||||||
return { visitorData, poToken }
|
return { visitorData, poToken }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const run = async () => {
|
||||||
|
try {
|
||||||
|
const { visitorData, poToken } = await generate();
|
||||||
|
p = redis.set("invidious:po_token", poToken)
|
||||||
|
v = redis.set("invidious:visitor_data", visitorData)
|
||||||
|
} catch(e) {
|
||||||
|
console.error(`Fuck: ${e}`)
|
||||||
|
}
|
||||||
|
console.log("New tokens sent to redis")
|
||||||
|
}
|
||||||
|
|
||||||
|
run();
|
||||||
|
setTimeout(run, (process.env.RENEW_INTERVAL || 60) * 1000)
|
||||||
|
|
||||||
module.exports = { generate }
|
module.exports = { generate }
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"ioredis": "^5.4.1",
|
||||||
"jsdom": "^24.1.1"
|
"jsdom": "^24.1.1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
|
|
Loading…
Reference in a new issue