copy file to other path

#282
This commit is contained in:
Benny 2023-08-26 13:04:29 +02:00
parent dd2af8dcc0
commit 56b0dd2a04
No known key found for this signature in database
GPG key ID: 6CD0DBDA5235D481
3 changed files with 9 additions and 1 deletions

View file

@ -146,7 +146,7 @@ You can configure all the following environment variables:
* FREE_DOWNLOAD: free download count per day
* TOKEN_PRICE: token price per 1 USD
* GOOGLE_API_KEY: YouTube API key, required for YouTube video subscription.
* RCLONE_PATH: rclone path to upload files to cloud storage
## 3.2 Set up init data
If you only need basic functionality, you can skip this step.

View file

@ -64,3 +64,4 @@ TOKEN_PRICE = os.getenv("BUY_UNIT", 20) # one USD=20 credits
RATE_LIMIT = os.getenv("RATE_LIMIT", 20)
SS_YOUTUBE = os.getenv("SS_YOUTUBE", "https://ytdlbot.dmesg.app?token=123456")
RCLONE_PATH = os.getenv("RCLONE")

View file

@ -13,6 +13,7 @@ import os
import pathlib
import random
import re
import shutil
import subprocess
import tempfile
import threading
@ -42,6 +43,7 @@ from config import (
ENABLE_QUEUE,
ENABLE_VIP,
OWNER,
RCLONE_PATH,
RATE_LIMIT,
WORKERS,
)
@ -278,6 +280,11 @@ def ytdl_normal_download(client: Client, bot_msg: typing.Union[types.Message, ty
bot_msg.edit_text("Download success!✅")
# setup rclone environment var to back up the downloaded file
if RCLONE_PATH:
for item in os.listdir(temp_dir.name):
logging.info("Copying %s to %s", item, RCLONE_PATH)
shutil.copy(os.path.join(temp_dir.name, item), RCLONE_PATH)
temp_dir.cleanup()