diff --git a/README.md b/README.md index bd96fdd..8c49dac 100644 --- a/README.md +++ b/README.md @@ -2,19 +2,28 @@ ## Description This bot can download music and videos from youtube. ## Installation -### Docker + +### Step 1 1) Install docker (how you can install it on linux: https://fullgream.tech/knowledge-base?post=docker-install) 2) Clone repository: `git clone https://git.fullgream.tech/fullgream/telegram_ytdlp_node.js.git` -3) Create file `cookies.txt` in program directory *(You can use **Get cookies.txt loccaly**: https://chromewebstore.google.com/detail/get-cookiestxt-locally/cclelndahbckbenkjhflpdbgdldlbecc)* -4) Create telegram bot, get token: https://t.me/BotFather -5) Edit file .env +### Step 2. If you will use MTProto API +1) Go to [https://my.telegram.org/apps](Telegram API Development Tools). And create API_ID and API Hash. +2) Go to `/src-tg` folder in clonned folder +3) Run docker container with command: `docker build -t telegram_create_session . && docker run -it --rm telegram_create_session && docker rmi telegram_create_session` +4) Type all answers +5) Write to `.env` file SESSION value and go to `..`. (Next steps of next part from step 3) +### Step 3 +1) Create file `cookies.txt` in program directory *(You can use **Get cookies.txt loccaly**: https://chromewebstore.google.com/detail/get-cookiestxt-locally/cclelndahbckbenkjhflpdbgdldlbecc)* +2) Create telegram bot, get token: https://t.me/BotFather +3) Edit file .env ```env BOT_TOKEN= ADMIN_LIST= (example: 123,321, 678, 911 , 228) WHITELIST= (example: 123,321, 678, 911 , 228) -SHOW_ALL_FORMATS= +API_ID= +API_HASH= +API_SESSION= +CHAT_ID= ``` -6) Build docker container: -`docker build -t ytdlp_node:release .` -7) Up docker container: -`docker run -d --name ytdlp_node --restart unless-stopped --env-file .env -v "$(pwd)/cookies.txt:/app/cookies.txt" ytdlp_node:release` +4) Build docker container: `docker build -t ytdlp_node:release .` +5) Up docker container: `docker run -d --name ytdlp_node --restart unless-stopped --env-file .env -v "$(pwd)/cookies.txt:/app/cookies.txt" ytdlp_node:release` diff --git a/src/bot.js b/src/bot.js index a38d1db..bec51b5 100644 --- a/src/bot.js +++ b/src/bot.js @@ -262,7 +262,7 @@ class VideosGarbageCollector { } removeTemp () { - if (Object.keys(tgChatsDownloaded) === 0) + if (Object.keys(tgChatsDownloaded).length === 0) removeTemp(); } } diff --git a/src/mtproto.js b/src/mtproto.js index 1f97cde..707b082 100644 --- a/src/mtproto.js +++ b/src/mtproto.js @@ -7,7 +7,7 @@ const path = require("path"); //const mime = require("mime"); const config = require("./config"); -const d = v => console.debug("DEBUG:", v) || v; +//const d = v => console.debug("DEBUG:", v) || v; class MTProtoUser { constructor(apiId, apiHash, sessionId) { const stringSession = new StringSession(sessionId); @@ -38,7 +38,7 @@ class MTProtoUser { const msg = await this.client.sendFile(config.mtproto.chatId, { file, caption: message, - thumb: d(options.thumb), + thumb: options.thumb, //filename: options.filename, supportsStreaming: true, });