Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
farfun committed Dec 15, 2024
1 parent 4281811 commit a4dfffc
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 14 deletions.
2 changes: 1 addition & 1 deletion extbuild/fundrive-lanzou/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "fundrive-lanzou"
version = "1.2.62"
version = "1.2.63"
description = "fundrive"
readme = "README.md"
requires-python = ">=3.8"
Expand Down
3 changes: 3 additions & 0 deletions logs/all.log
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
2024-12-15 19:11:53.733 |INFO | funbuild.core.core : core: 86 | funbuild | - fundrive build
2024-12-15 19:11:53.745 |INFO | funbuild.core.core : core: 74 | funbuild | - fundrive pull
2024-12-15 19:12:09.127 |INFO | funbuild.core.core : core: 78 | funbuild | - fundrive push
2024-12-15 19:18:48.283 |INFO | funbuild.core.core : core: 86 | funbuild | - fundrive build
2024-12-15 19:18:48.284 |INFO | funbuild.core.core : core: 74 | funbuild | - fundrive pull
2024-12-15 19:19:02.131 |INFO | funbuild.core.core : core: 78 | funbuild | - fundrive push
3 changes: 3 additions & 0 deletions logs/funbuild.log
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
2024-12-15 19:11:53.733 |INFO | funbuild.core.core : core: 86 | funbuild | - fundrive build
2024-12-15 19:11:53.745 |INFO | funbuild.core.core : core: 74 | funbuild | - fundrive pull
2024-12-15 19:12:09.127 |INFO | funbuild.core.core : core: 78 | funbuild | - fundrive push
2024-12-15 19:18:48.283 |INFO | funbuild.core.core : core: 86 | funbuild | - fundrive build
2024-12-15 19:18:48.284 |INFO | funbuild.core.core : core: 74 | funbuild | - fundrive pull
2024-12-15 19:19:02.131 |INFO | funbuild.core.core : core: 78 | funbuild | - fundrive push
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "fundrive"
version = "1.2.62"
version = "1.2.63"
description = "fundrive"
readme = "README.md"
requires-python = ">=3.8"
Expand Down
29 changes: 19 additions & 10 deletions src/fundrive/drives/wenshushu/drive.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,17 @@
import os
import subprocess
import time
import traceback
from concurrent.futures import ThreadPoolExecutor

import orjson
import requests
from fundrive.core import BaseDrive as BaseDrive2
from funget import simple_download
from funutil import getLogger
from tqdm import tqdm

from fundrive.core import BaseDrive as BaseDrive2
logger = getLogger("fundrive")


class BaseDrive:
Expand All @@ -36,7 +39,7 @@ def storage(self):
rest_space = int(rsp["data"]["rest_space"])
send_space = int(rsp["data"]["send_space"])
storage_space = rest_space + send_space
print(
logger.info(
"当前已用空间:{}GB,剩余空间:{}GB,总空间:{}GB".format(
round(send_space / 1024**3, 2),
round(rest_space / 1024**3, 2),
Expand Down Expand Up @@ -182,8 +185,8 @@ def copysend(self, boxid, taskid, preid):
json={"bid": boxid, "tid": taskid, "ufileid": preid},
)
rsp = r.json()
print(f"个人管理链接:{rsp['data']['mgr_url']}")
print(f"公共链接:{rsp['data']['public_url']}")
logger.info(f"个人管理链接:{rsp['data']['mgr_url']}")
logger.info(f"公共链接:{rsp['data']['public_url']}")

def sha1_str(self, s):
cm = hashlib.sha1(s.encode()).hexdigest()
Expand All @@ -198,6 +201,8 @@ def calc_file_hash(self, hash_type, block=None):
hash_code = hashlib.md5(block).hexdigest()
elif hash_type == "SHA1":
hash_code = hashlib.sha1(block).hexdigest()
else:
raise NotImplementedError
return hash_code

def get_cipherheader(self, epochtime, token, data):
Expand All @@ -206,7 +211,7 @@ def get_cipherheader(self, epochtime, token, data):
from Cryptodome.Cipher import DES
from Cryptodome.Util import Padding
except Exception as e:
print(e)
logger.info(f"error: {e} traceback: {traceback.format_exc()}")
subprocess.check_call(["pip", "install", "pycryptodomex"])
import base58
from Cryptodome.Cipher import DES
Expand Down Expand Up @@ -267,7 +272,7 @@ def fast(self):
hash_codes += self.calc_file_hash("MD5", block)
payload["hash"]["cm"] = self.sha1_str(hash_codes)
elif can_fast and ufile:
print(f"文件{name}可以被秒传!")
logger.info(f"文件{name}可以被秒传!")
self.get_process(upId)
self.copysend(boxid, taskid, preid)

Expand Down Expand Up @@ -338,10 +343,10 @@ def mgrtask(self, tid):
days, remainder = divmod(int(float(expire)), 3600 * 24)
hours, remainder = divmod(remainder, 3600)
minutes, seconds = divmod(remainder, 60)
print(f"文件过期时间:{days}{hours}{minutes}{seconds}秒")
logger.info(f"文件过期时间:{days}{hours}{minutes}{seconds}秒")

file_size = rsp["data"]["file_size"]
print(f"文件大小:{round(int(file_size) / 1024 ** 2, 2)}MB")
logger.info(f"文件大小:{round(int(file_size) / 1024 ** 2, 2)}MB")
return rsp["data"]["boxid"], rsp["data"]["ufileid"] # pid

def sign_url(self, fid):
Expand Down Expand Up @@ -401,8 +406,10 @@ def upload_file(
uploader = Uploader(drive=self.drive, file_path=file_path)
try:
uploader.upload()
return True
except Exception as e:
print(e)
logger.info(f"error: {e} traceback: {traceback.format_exc()}")
return False

def download_file(
self, share_url=None, dir_path="./cache", overwrite=False, *args, **kwargs
Expand All @@ -412,5 +419,7 @@ def download_file(
)
try:
downloader.download()
return True
except Exception as e:
print(e)
logger.info(f"error: {e} traceback: {traceback.format_exc()}")
return False
4 changes: 2 additions & 2 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a4dfffc

Please sign in to comment.