send split files with personalized caption
Aikanairo opened this issue · 1 comments
- telegram-upload version: telegram-upload==0.7.1
- Python version: 3.11
- Operating System: arch
- Dependencies list (run
pip freeze
):
Description
Hi nekmo, thank you for the work you do
I would like to understand how your script handles the caption for files divided into multiple parts
even though I set a camption, the files are sent without a camption, i.e. only with the name in the caption.
Could you just show me the file that manages the caption for managing file uploads exceeding the limit?
thank you so much
I solved it like this
def process_large_file(self, file):
file_name = os.path.basename(file)
total_size = os.path.getsize(file)
parts = math.ceil(total_size / self.client.max_file_size)
zfill = int(math.log10(10)) + 1
for part in range(parts):
size = total_size - (part * self.client.max_file_size) if part >= parts - 1 else self.client.max_file_size
splitted_file = SplitFile(self.client, file, size, '{}.{}'.format(file_name, str(part).zfill(zfill)), caption=self.caption)
splitted_file.seek(self.client.max_file_size * part, split_seek=True)
yield splitted_file
def __init__(self, client: 'TelegramManagerClient', file: Union[str, bytes, int], max_read_size: int, name: str, caption: Union[str, None] = None):
super().__init__(client, file, caption=caption) # Pass caption to the superclass
self.max_read_size = max_read_size
self.remaining_size = max_read_size
self._name = name