Skip to content

Commit

Permalink
feat(main): add auto_upload_minimal_size
Browse files Browse the repository at this point in the history
  • Loading branch information
hldh214 committed Sep 17, 2020
1 parent 823fb5f commit 20614a9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions config.sample.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ credentials_file = ""
[source."668668"]
enabled = true
auto_upload = true
auto_upload_minimal_size = 1024
source_type = "huya"
room_id = "668668"
title = "风行云 - {datetime} - 录像"
Expand All @@ -16,6 +17,7 @@ credentials_file = ""
[source."deer98"]
enabled = true
auto_upload = false
auto_upload_minimal_size = 1024
source_type = "panda"
room_id = "10535725"
sess_key = "018c6d30a09720dd7aba6a9113fa5227bc9c78e033eb1a2be5fec88af599e3c6"
Expand Down
8 changes: 8 additions & 0 deletions recorder/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ def record_thread(source_type, room_id, interval=5, **kwargs):
if not kwargs['auto_upload']:
continue

if kwargs['auto_upload_minimal_size'] > get_file_size(output_file):
logger.info(f'auto_upload_minimal_size > get_file_size(output_file): {output_file}')
continue

# move to upload folder
dst_dir = os.path.join(upload_path, source_type, room_id)
pathlib.Path(dst_dir).mkdir(parents=True, exist_ok=True)
Expand Down Expand Up @@ -166,6 +170,10 @@ def upload_validator(youtube):
).start()


def get_file_size(path):
return '{:f}'.format(pathlib.Path(path).stat().st_size / 1024 / 1024)


def main():
config = get_config()
youtube = recorder.destination.youtube.Youtube(config['youtube'])
Expand Down

0 comments on commit 20614a9

Please sign in to comment.