Fix minor problems with user IDs and datetime
This commit is contained in:
@@ -55,16 +55,13 @@ async def message_handler(_, message: Message):
|
|||||||
"No TikTok URLs found! Nothing to download!"
|
"No TikTok URLs found! Nothing to download!"
|
||||||
)
|
)
|
||||||
|
|
||||||
success_count = 0
|
|
||||||
for i, url in enumerate(urls):
|
for i, url in enumerate(urls):
|
||||||
msg = f"Downloading video {i+1}/{len(urls)}..."
|
msg = f"Downloading video {i+1}/{len(urls)}..."
|
||||||
log.info(msg)
|
log.info(msg)
|
||||||
await message.reply_text(msg)
|
await message.reply_text(msg)
|
||||||
outcome = utils.download_tt_video(STORAGE, url)
|
utils.download_tt_video(STORAGE, url)
|
||||||
success_count += 1 if outcome else 0
|
|
||||||
|
|
||||||
await message.reply_text(f"{success_count}/{len(urls)} "
|
await message.reply_text("Done.")
|
||||||
"video(s) downloaded")
|
|
||||||
|
|
||||||
|
|
||||||
@app.on_message(filters.media)
|
@app.on_message(filters.media)
|
||||||
|
|||||||
@@ -1,18 +1,22 @@
|
|||||||
import os
|
import os
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
|
||||||
|
from telegram_downloader_bot.logger import log
|
||||||
|
|
||||||
# Comma separated list of Telegram IDs that this bot will respond to
|
# Comma separated list of Telegram IDs that this bot will respond to
|
||||||
allowed_ids_raw = os.getenv("ALLOWED_IDS", "")
|
allowed_ids_raw = os.getenv("ALLOWED_IDS", "")
|
||||||
allowed_ids = allowed_ids_raw.split(",")
|
allowed_ids = allowed_ids_raw.split(",")
|
||||||
|
allowed_ids = [int(x) for x in allowed_ids]
|
||||||
print(allowed_ids_raw)
|
|
||||||
print(allowed_ids)
|
|
||||||
|
|
||||||
|
|
||||||
def protected(func):
|
def protected(func):
|
||||||
@wraps(func)
|
@wraps(func)
|
||||||
async def wrapper(client, message):
|
async def wrapper(client, message):
|
||||||
if message.from_user.id not in allowed_ids:
|
if int(message.from_user.id) not in allowed_ids:
|
||||||
|
log.warning(
|
||||||
|
f"User with ID {message.from_user.id} attempted to text this bot!")
|
||||||
|
log.info(
|
||||||
|
f"Only users allowed are: {' '.join(allowed_ids)}")
|
||||||
return await message.reply_text("You are not on the list!")
|
return await message.reply_text("You are not on the list!")
|
||||||
return await func(client, message)
|
return await func(client, message)
|
||||||
return wrapper
|
return wrapper
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ def download_tt_video(storage_path: str, url: str) -> None:
|
|||||||
Makes sure the video integrity is correct."""
|
Makes sure the video integrity is correct."""
|
||||||
|
|
||||||
videos = snaptik(url)
|
videos = snaptik(url)
|
||||||
now = datetime.datetime.now()
|
now = datetime.now()
|
||||||
|
|
||||||
for video in videos:
|
for video in videos:
|
||||||
video_filename = now.strftime("video-tiktok-%Y-%m-%d_%H-%M-%S.mp4")
|
video_filename = now.strftime("video-tiktok-%Y-%m-%d_%H-%M-%S.mp4")
|
||||||
|
|||||||
Reference in New Issue
Block a user