Skip to content

Commit

Permalink
0.1.0 Alpha
Browse files Browse the repository at this point in the history
++ 正确处理 cookies
++ 种子结构树状视图
  • Loading branch information
tastysugar committed Mar 14, 2023
1 parent ea298ca commit a994577
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 23 deletions.
49 changes: 27 additions & 22 deletions OKPLogic.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
from html2phpbbcode.parser import HTML2PHPBBCode
from collections import defaultdict
import torrent_parser as tp
from ProcessWindow import MyConsole

VERSION = "v0.0.4 Alpha 内部测试版"
VERSION = "v0.1.0 Alpha"

CATEGORY = {
'Anime': ['Default', 'MV', 'TV', 'Movie', 'Collection', 'Raw', 'English'],
Expand Down Expand Up @@ -191,16 +192,12 @@ def sizeof_fmt(num, suffix="B"):
else:
nodes[str(path)] = length

print(f"{nodes=}")
sorted_nodes = sorted(nodes, key=lambda x: len(eval(x)))

print(f"{sorted_nodes=}")
sorted_nodes = sorted(nodes, key=lambda x: len(eval(x)))

for n in sorted_nodes:
if n == "[]":
continue
print(f'{eval(n)[:-1]}')
print(type(nodes[f'{eval(n)[:-1]}']))
item = QTreeWidgetItem(nodes[f'{eval(n)[:-1]}'])
item.setText(0, eval(n)[-1])
item.setText(1, sizeof_fmt(nodes[n]))
Expand Down Expand Up @@ -711,26 +708,34 @@ def publishRun(self):
with open("cookies.txt", "w", encoding='utf-8') as f:
f.write(self.profile['profiles'][self.menuSelectCookies.currentText()]['cookies'])

# p = subprocess.Popen([
# "OKP.Core.exe",
# self.textTorrentPath.text(),
# "-s", str(Path.cwd().joinpath("template.toml")),
# '--cookies', str(Path.cwd().joinpath("cookies.txt"))
# ], creationflags=subprocess.CREATE_NEW_CONSOLE)
self.console = MyConsole(self)
self.console.onFinished(self.updateCookies)
self.console.start("OKP.Core.exe", [
self.textTorrentPath.text(),
"-s", str(Path.cwd().joinpath("template.toml")),
'--cookies', str(Path.cwd().joinpath("cookies.txt"))
])
self.console.show()




# self.p = QProcess()
# self.p.start(
# "OKP.Core.exe",[
# self.textTorrentPath.text(),
# "-s", str(Path.cwd().joinpath("template.toml")),
# '--cookies', str(Path.cwd().joinpath("cookies.txt"))
# ]
# )
def updateCookies(self, int, exitStatus):
if exitStatus == QProcess.ExitStatus.NormalExit:
try:
with open("cookies.txt", "r", encoding="utf-8") as f:
newCookies = f.read()

self.profile["profiles"][self.menuSelectCookies.currentText()]["cookies"] = newCookies

# self.p.readyReadStandardOutput.connect()
# self.p.readyReadStandardError.connect()
with open(PROFILE_CONFIG, "w", encoding="utf-8") as file:
yaml.safe_dump(self.profile, file, encoding='utf-8',allow_unicode=True)

self.reloadProfile()

except:
return



class WarningDialog(QDialog, Ui_Dialog):
Expand Down
4 changes: 3 additions & 1 deletion ProcessWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ def __init__(self, parentWindow, *args, **kwargs):
self.vbox.addWidget(self.consoleWidget)
self.vbox.addWidget(self.publishButton)

self.setWindowTitle("OKP 运行中…")

#self.reader.start('python', ['test.py']) # start the process

def onPublishButton(self):
Expand All @@ -84,7 +86,7 @@ def onPublishButton(self):
def start(self, *args, **kargs):
self.reader.start(*args, **kargs)

def onFinished(self, func:function):
def onFinished(self, func):
self.reader.finished.connect(func)


Expand Down

0 comments on commit a994577

Please sign in to comment.