From 18c5a0184e3f2339fb0b6f3de77ce59c15c2313d Mon Sep 17 00:00:00 2001 From: Cesar Mendivil Date: Sun, 22 Mar 2026 09:47:50 -0700 Subject: [PATCH] feat: add dotenv support for environment configuration and update cookies handling --- .env.example | 5 +++++ cookies.txt | 13 ++++++------- index.js | 5 +++-- package-lock.json | 13 +++++++++++++ package.json | 1 + 5 files changed, 28 insertions(+), 9 deletions(-) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..0bf24bc --- /dev/null +++ b/.env.example @@ -0,0 +1,5 @@ +# Example .env for tubapi-node +# Path to node binary used by yt-dlp JS runtime fallback +NODE_PATH=/usr/bin/node +# Port for the API server +PORT=8282 diff --git a/cookies.txt b/cookies.txt index aac8b5a..71a2a6e 100644 --- a/cookies.txt +++ b/cookies.txt @@ -7,13 +7,12 @@ .youtube.com TRUE / TRUE 1789709402 __Secure-1PSIDTS sidts-CjQBBj1CYiRV7UVF_NUth-Gfo95O96s1Cs-1NuMHMJPiT7n_HlJPWYuFOcN1oT5CG8TLiIaHEAA .youtube.com TRUE / TRUE 1789709402 __Secure-3PSIDTS sidts-CjQBBj1CYiRV7UVF_NUth-Gfo95O96s1Cs-1NuMHMJPiT7n_HlJPWYuFOcN1oT5CG8TLiIaHEAA .youtube.com TRUE / TRUE 1805695434 __Secure-3PSIDCC AKEyXzXoh06KK4RlJVNA9_d9X7nQTUeTyjck38lMhpTSlrPdPM4WJmXwY1Dwcb04bGAEFsfBOA -.youtube.com TRUE / TRUE 1789717979 VISITOR_INFO1_LIVE tao8KQuuHoU -.youtube.com TRUE / TRUE 1789717979 VISITOR_PRIVACY_METADATA CgJNWBIEGgAgGQ%3D%3D +.youtube.com TRUE / TRUE 1789749904 VISITOR_INFO1_LIVE tao8KQuuHoU +.youtube.com TRUE / TRUE 1789749904 VISITOR_PRIVACY_METADATA CgJNWBIEGgAgGQ%3D%3D .youtube.com TRUE / TRUE 1789702583 __Secure-YNID 16.YT=vu9HeA2iqnPH-ADjGUgMWcecXN8tAYkSOswDaAH2YJDti3-DJqQNwyMyan0-6fTAnS8DJXEOTQjcx9WcOO7eoZXbiTQIyc06NpWwnZgBks8y8hM1zLBOwLJgUDID6rMU__elM4SZzXDER7cRrHpK8JBH-BwHmrTr9SLuwxjQy07uDTxhr43IC-Xkc4qgUc0sJIHVDChce5CjKSfYK9FXCOoWW1gzxZ2YUJRrKt5UR5rLaLD8wUvEgesYFEen8bNP1FvBE4TGLl_l7N9EiZFvnI7cwIC-nz2jdlYb-AegSCtZzDTin0Jp0036TozvB6nTIYS-aNTwIw2Fo1F6w8vRhQ .youtube.com TRUE / TRUE 1789702583 __Secure-ROLLOUT_TOKEN CJvoma2RkvyUPhC78ITB9aqTAxjHlq76ybKTAw%3D%3D -.youtube.com TRUE / TRUE 1837237978 __Secure-YT_TVFAS t=492746&s=2 -.youtube.com TRUE / TRUE 1789717978 DEVICE_INFO ChxOell4T1RrME9EVXdNRGd5TXpjNU1ETXlNUT09ENq//s0GGMr9/c0G -.youtube.com TRUE / TRUE 1774166662 GPS 1 +.youtube.com TRUE / TRUE 1837269903 __Secure-YT_TVFAS t=492746&s=2 +.youtube.com TRUE / TRUE 1789749903 DEVICE_INFO ChxOell4T1RrME9EVXdNRGd5TXpjNU1ETXlNUT09EI+5gM4GGMr9/c0G .youtube.com TRUE / TRUE 0 SOCS CAI -.youtube.com TRUE / TRUE 0 YSC 7WQi0NEj8Ag -.youtube.com TRUE /tv TRUE 1806997978 __Secure-YT_DERP CMyH7KS6Aw%3D%3D +.youtube.com TRUE / TRUE 1774199702 GPS 1 +.youtube.com TRUE /tv TRUE 1807029903 __Secure-YT_DERP CMyH7KS6Aw%3D%3D diff --git a/index.js b/index.js index db4a0d1..321ea69 100644 --- a/index.js +++ b/index.js @@ -1,13 +1,14 @@ +require('dotenv').config(); const express = require('express'); const { spawn } = require('child_process'); const path = require('path'); const fs = require('fs'); const multer = require('multer'); const app = express(); -const PORT = process.env.PORT || 8282; +const PORT = process.env.PORT ? Number(process.env.PORT) : 8282; // CONFIGURACIÓN DE RUTAS -const NODE_PATH = '/usr/bin/node'; +const NODE_PATH = process.env.NODE_PATH || '/usr/bin/node'; const COOKIES_FILE = path.resolve(__dirname, 'cookies.txt'); const COOKIES_PATH = COOKIES_FILE; const { warmAndExportCookies, exportCookiesFromBotProfile } = require('./cookiewarmer'); diff --git a/package-lock.json b/package-lock.json index 1769ea5..46a3cfa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,7 @@ "hasInstallScript": true, "license": "MIT", "dependencies": { + "dotenv": "^16.1.4", "express": "^4.18.2", "multer": "^1.4.5-lts.1", "playwright": "^1.58.2", @@ -1209,6 +1210,18 @@ "npm": "1.2.8000 || >= 1.4.16" } }, + "node_modules/dotenv": { + "version": "16.6.1", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.6.1.tgz", + "integrity": "sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, "node_modules/dunder-proto": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", diff --git a/package.json b/package.json index 0f5b9f3..99b396b 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "dependencies": { "express": "^4.18.2", "multer": "^1.4.5-lts.1", + "dotenv": "^16.1.4", "playwright": "^1.58.2", "playwright-extra": "^4.3.6", "puppeteer-extra-plugin-stealth": "^2.11.2"