more stuff
This commit is contained in:
parent
cf83bbab73
commit
c222f91ef9
|
@ -29,7 +29,7 @@ class CappedBufferedReader(io.BufferedReader):
|
||||||
elif whence == os.SEEK_SET:
|
elif whence == os.SEEK_SET:
|
||||||
current_pos = self.tell()
|
current_pos = self.tell()
|
||||||
if current_pos > offset:
|
if current_pos > offset:
|
||||||
self.capped_size += current_pos
|
self.capped_size += current_pos - offset
|
||||||
return super().seek(offset, whence)
|
return super().seek(offset, whence)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -224,13 +224,13 @@ async def _upload_worker():
|
||||||
tempdir = tempdir_obj.name
|
tempdir = tempdir_obj.name
|
||||||
base_filename = video_json['id'] + '.mkv'
|
base_filename = video_json['id'] + '.mkv'
|
||||||
video_filename = os.path.join(tempdir, base_filename)
|
video_filename = os.path.join(tempdir, base_filename)
|
||||||
total_size = os.path.getsize(video_filename)
|
|
||||||
is_big = total_size > size_limit
|
|
||||||
files_sent = size_sent = 0
|
files_sent = size_sent = 0
|
||||||
messages = []
|
messages = []
|
||||||
file = bopen(video_filename, None)
|
file = bopen(video_filename, None)
|
||||||
|
file.seek(0, os.SEEK_END)
|
||||||
|
total_size = file.tell()
|
||||||
|
is_big = total_size > size_limit
|
||||||
while total_size > 0:
|
while total_size > 0:
|
||||||
file.capped_size = None
|
|
||||||
file.seek(size_sent)
|
file.seek(size_sent)
|
||||||
file.capped_size = size_limit
|
file.capped_size = size_limit
|
||||||
if is_big:
|
if is_big:
|
||||||
|
@ -238,12 +238,13 @@ async def _upload_worker():
|
||||||
else:
|
else:
|
||||||
file.name = base_filename
|
file.name = base_filename
|
||||||
messages.append((await client.send_message(config['config']['storage_chat_id'], f'Uploading {file.name}...', parse_mode=None)).id)
|
messages.append((await client.send_message(config['config']['storage_chat_id'], f'Uploading {file.name}...', parse_mode=None)).id)
|
||||||
message = await client.send_file(config['config']['storage_chat_id'], file, caption=file.name, parse_mode=None)
|
message = await client.send_file(config['config']['storage_chat_id'], file, caption=file.name, parse_mode=None, file_size=size_limit if total_size > size_limit else total_size)
|
||||||
total_size -= message.document.size
|
total_size -= message.document.size
|
||||||
if total_size > 0:
|
if total_size > 0:
|
||||||
size_sent += message.document.size
|
size_sent += message.document.size
|
||||||
files_sent += 1
|
files_sent += 1
|
||||||
file = bopen(video_filename, None)
|
file.capped_size = None
|
||||||
|
file.close()
|
||||||
if messages:
|
if messages:
|
||||||
await client.delete_messages(config['config']['storage_chat_id'], messages)
|
await client.delete_messages(config['config']['storage_chat_id'], messages)
|
||||||
finally:
|
finally:
|
||||||
|
|
Loading…
Reference in New Issue