diff --git a/tg-upload.py b/tg-upload.py index 0e2ebb6..c4d8932 100644 --- a/tg-upload.py +++ b/tg-upload.py @@ -757,13 +757,13 @@ def get_chatid(raw_id): video.save_frame(f"thumb/THUMB_{PurePath(_path).stem}.jpg", t=int(args.thumb)) thumb_path = f"thumb/THUMB_{PurePath(_path).stem}.jpg" if not args.height: - args.height = video.h + media_height = video.h if not args.width: - args.width = video.w + media_width = video.w if args.duration == -1: - args.duration = floor(video.duration) + media_duration = floor(video.duration) start_time = time() - client.send_video(chat_id, _path, progress=upload_progress, duration=args.duration, parse_mode=parse_mode, caption=caption.format(file_name = PurePath(filename).stem, file_format = PurePath(filename).suffix, file_size_b = file_size, file_size_kb = file_size / 1024, file_size_mb = file_size / (1024 * 1024), file_size_gb = file_size / (1024 * 1024 * 1024), file_sha256 = file_sha256, file_md5 = file_md5, creation_time = creation_time, modification_time = modification_time, width=args.width, height=args.height, duration=args.duration, path = PurePath(_path)), has_spoiler=args.spoiler, width=int(args.width), height=int(args.height), thumb=thumb_path, file_name=filename, supports_streaming=args.disable_stream, disable_notification=args.silent, ttl_seconds=args.self_destruct, protect_content=args.protect, reply_to_message_id=args.reply_to) + client.send_video(chat_id, _path, progress=upload_progress, duration=media_duration, parse_mode=parse_mode, caption=caption.format(file_name = PurePath(filename).stem, file_format = PurePath(filename).suffix, file_size_b = file_size, file_size_kb = file_size / 1024, file_size_mb = file_size / (1024 * 1024), file_size_gb = file_size / (1024 * 1024 * 1024), file_sha256 = file_sha256, file_md5 = file_md5, creation_time = creation_time, modification_time = modification_time, width=media_width, height=media_height, duration=media_duration, path = PurePath(_path)), has_spoiler=args.spoiler, width=int(media_width), height=int(media_height), thumb=thumb_path, file_name=filename, supports_streaming=args.disable_stream, disable_notification=args.silent, ttl_seconds=args.self_destruct, protect_content=args.protect, reply_to_message_id=args.reply_to) Path(_path).unlink(missing_ok=True) if args.delete_on_done else None except Exception as error_code: print(f"\nAn error occured!\n{error_code}") @@ -801,10 +801,10 @@ def get_chatid(raw_id): filename = filename.replace(args.replace[0], args.replace[1]) if args.duration == -1: with AudioFileClip(_path) as audio: - args.duration = floor(audio.duration) + media_duration = floor(audio.duration) file_size, file_sha256, file_md5, creation_time, modification_time = file_info(_path, caption) start_time = time() - client.send_audio(chat_id, _path, progress=upload_progress, duration=args.duration, parse_mode=parse_mode, caption=caption.format(file_name = PurePath(filename).stem, file_format = PurePath(filename).suffix, file_size_b = file_size, file_size_kb = file_size / 1024, file_size_mb = file_size / (1024 * 1024), file_size_gb = file_size / (1024 * 1024 * 1024), file_sha256 = file_sha256, file_md5 = file_md5, creation_time = creation_time, modification_time = modification_time, duration=args.duration, path = PurePath(_path)), performer=args.artist, title=args.title, thumb=args.thumb, file_name=filename, disable_notification=args.silent, protect_content=args.protect, reply_to_message_id=args.reply_to) + client.send_audio(chat_id, _path, progress=upload_progress, duration=media_duration, parse_mode=parse_mode, caption=caption.format(file_name = PurePath(filename).stem, file_format = PurePath(filename).suffix, file_size_b = file_size, file_size_kb = file_size / 1024, file_size_mb = file_size / (1024 * 1024), file_size_gb = file_size / (1024 * 1024 * 1024), file_sha256 = file_sha256, file_md5 = file_md5, creation_time = creation_time, modification_time = modification_time, duration=media_duration, path = PurePath(_path)), performer=args.artist, title=args.title, thumb=args.thumb, file_name=filename, disable_notification=args.silent, protect_content=args.protect, reply_to_message_id=args.reply_to) Path(_path).unlink(missing_ok=True) if args.delete_on_done else None except Exception as error_code: print(f"\nAn error occured!\n{error_code}")