Skip to content

Commit

Permalink
fix #35 #31 #24 #19 #10
Browse files Browse the repository at this point in the history
  • Loading branch information
yaronzz committed Jul 14, 2023
1 parent 1ab4737 commit 65ec3b8
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 18 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
/b2a/__pycache__
/__init__.spec
/b2a_gui/
build.sh
2 changes: 1 addition & 1 deletion b2a/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
https://github.com/yaronzz/BaiduYunToAliYun
'''
VERSION = '2022.07.07.1'
VERSION = '2023.07.04.1'

aliplat = AliPlat()
bdyplat = BdyPlat()
Expand Down
34 changes: 20 additions & 14 deletions b2a/bdyplat.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
@Contact : [email protected]
@Desc :
"""
import os
import subprocess
import aigpy
from baidupcs_py.baidupcs import BaiduPCSApi
# from common.io import RangeRequestIO
Expand Down Expand Up @@ -120,21 +122,25 @@ def downloadFile(self, fileAttr: FileAttr, localFilePath: str) -> bool:
# stream.close()
# return True

headers = {
"Cookie ": "; ".join(
[f"{k}={v if v is not None else ''}" for k, v in self.key.api.cookies.items()]
),
"User-Agent": "netdisk;2.2.51.6;netdisk;10.0.63;PC;android-android",
"Connection": "Keep-Alive",
}

link = self.__safeAPI__('download_link', fileAttr.path)
if not link or len(link) <= 0:
return False
# headers = {
# "Cookie ": "; ".join(
# [f"{k}={v if v is not None else ''}" for k, v in self.key.api.cookies.items()]
# ),
# "User-Agent": "netdisk;2.2.51.6;netdisk;10.0.63;PC;android-android",
# "Connection": "Keep-Alive",
# }

dl = Downloader(link, headers, localFilePath, fileAttr.size, 6)
check = dl.run()
return check
# link = self.__safeAPI__('download_link', fileAttr.path)
# if not link or len(link) <= 0:
# return False

# dl = Downloader(link, headers, localFilePath, fileAttr.size, 1)
# check = dl.run()
# return check

cmd = f'BaiduPCS-Py download -o \"{path}\" \"{fileAttr.path}\"'
child = subprocess.run(cmd)
return child.returncode == 0

def uploadFile(self, localFilePath: str, remoteFilePath: str) -> bool:
return False
Expand Down
4 changes: 2 additions & 2 deletions b2a/trans.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def moveFile(self, item: FileAttr, saveLocal=False):
localFilePath = self.downloadPath + item.path
localSize = aigpy.file.getSize(localFilePath)
if localSize <= 0:
tmpFile = localFilePath + ".tmp"
tmpFile = localFilePath# + ".tmp"
check = self._bdyplat.downloadFile(item, tmpFile)
if not check:
aigpy.path.remove(tmpFile)
Expand All @@ -65,7 +65,7 @@ def moveFile(self, item: FileAttr, saveLocal=False):
return False
else:
printInfo("下载成功!")
os.rename(tmpFile, localFilePath)
# os.rename(tmpFile, localFilePath)

check = self._aliplat.uploadFile(localFilePath, uploadFilePath)
if not check:
Expand Down
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ uvicorn~=0.13.4
fastapi~=0.63.0
Jinja2~=2.11.3
b2a~=2021.7.23.2
PyQt5~=5.15.1
PyQt5~=5.15.1
BaiduPCS-Py~=0.6.32

0 comments on commit 65ec3b8

Please sign in to comment.