Created
December 19, 2023 03:34
-
-
Save EkkoG/a7f52d5a102aa8ce20923b1575df5728 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import transmissionrpc | |
import argparse | |
def main(tc): | |
# get session stats | |
stats = tc.session_stats() | |
def printttt(s): | |
print(f"总活动时间: {s['secondsActive'] / 86400:.2f} 天") | |
print(f"总上传量: {s['uploadedBytes'] / 1024 / 1024 / 1024:.2f} GB") | |
print(f"平均上传速度: {s['uploadedBytes'] / s['secondsActive'] / 1024 / 1024:.2f} MB/s") | |
# uplaod per day | |
print(f"平均每天上传: {s['uploadedBytes'] / s['secondsActive'] / 1024 / 1024 / 1024 * 86400:.2f} GB") | |
print(f"预计一月上传: {s['uploadedBytes'] / s['secondsActive'] / 1024 / 1024 / 1024 / 1024 * 86400 * 30:.2f} TB") | |
print(f"预计一年上传: {s['uploadedBytes'] / s['secondsActive'] / 1024 / 1024 / 1024 / 1024 * 86400 * 365:.2f} TB") | |
print("历史数据:") | |
printttt(stats.cumulative_stats) | |
print("\n最近数据:") | |
printttt(stats.current_stats) | |
def clean(tc): | |
for t in tc.get_torrents(arguments=['id', 'name', 'status', 'percentDone', 'rateDownload', 'rateUpload', 'eta', 'error', 'errorString']): | |
error = t.__getattr__('errorString') | |
if error: | |
print(t.name, error) | |
# if 'No data found!' in t.__getattr__('errorString'): | |
# print(t.name, t.__getattr__('errorString')) | |
# tc.remove_torrent(t.id, delete_data=False) | |
if __name__ == '__main__': | |
parser = argparse.ArgumentParser() | |
parser.add_argument('--host', default='127.0.0.1') | |
parser.add_argument('--port', default=9091) | |
parser.add_argument('--user', default='transmission') | |
parser.add_argument('--password', default='transmission') | |
args = parser.parse_args() | |
tc = transmissionrpc.Client(args.host, port=args.port, user=args.user, password=args.password) | |
main(tc) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment