Skip to content

Commit

Permalink
copy file to other path
Browse files Browse the repository at this point in the history
  • Loading branch information
BennyThink committed Aug 26, 2023
1 parent dd2af8d commit 56b0dd2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions ytdlbot/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,4 @@
RATE_LIMIT = os.getenv("RATE_LIMIT", 20)

SS_YOUTUBE = os.getenv("SS_YOUTUBE", "https://ytdlbot.dmesg.app?token=123456")
RCLONE_PATH = os.getenv("RCLONE")
7 changes: 7 additions & 0 deletions ytdlbot/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import pathlib
import random
import re
import shutil
import subprocess
import tempfile
import threading
Expand Down Expand Up @@ -42,6 +43,7 @@
ENABLE_QUEUE,
ENABLE_VIP,
OWNER,
RCLONE_PATH,
RATE_LIMIT,
WORKERS,
)
Expand Down Expand Up @@ -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()


Expand Down

0 comments on commit 56b0dd2

Please sign in to comment.