Skip to content

Commit

Permalink
Add custom format to settings
Browse files Browse the repository at this point in the history
  • Loading branch information
asadman1523 committed Jan 2, 2021
1 parent a8df663 commit 4ad1134
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion RenameTool.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ def run(self):

# Some title may have actors name, remove it
for actor in actors:
print(actor in title)
title = title.replace(actor, '')
title = title.replace('\n', ' ').strip()

Expand Down Expand Up @@ -136,6 +135,7 @@ def run(self):
pass
i = i + 1
self.countChanged.emit(101)
print('Finish')
except:
print("Unexpected error:" + str(sys.exc_info()))
raise
Expand Down
19 changes: 12 additions & 7 deletions odvrt.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import pathlib
import sys
import re
import time
import threading
import sys

from PyQt5.QtCore import Qt
from PyQt5 import QtWidgets, QtCore, QtGui
from PyQt5.QtCore import Qt
from PyQt5.QtWidgets import QTableWidgetItem, QFileDialog, QDialog, QPushButton, QLabel, QProgressBar

from RenameTool import RenameTool
Expand All @@ -14,6 +12,7 @@

class MainWindow(QtWidgets.QMainWindow):
fileList = []
settings = {0:'downloadImg=False', 1:'formatStr=%code %title %actor'}
fileNames = None
downloadImage = False
configPath = pathlib.Path('config.ini')
Expand All @@ -26,7 +25,7 @@ def __init__(self):
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.setAcceptDrops(True)
# 讀取設定
# Read settings
try:
if not self.configPath.exists():
self.configPath.touch()
Expand All @@ -41,6 +40,9 @@ def __init__(self):
else:
self.ui.downloadImgCheckBox.setChecked(False)
self.downloadImage = False
if "formatStr" in t:
result = re.findall('=(.+)$', t)
self.ui.formatStr.setText(result[0])
except:
# print("Unexpected error:", sys.exc_info()[0])
raise
Expand Down Expand Up @@ -128,6 +130,9 @@ def runBtnClicked(self):

def showProgressAndRun(self):
try:
# Save format
self.configPath.write_text("\n".join(['formatStr='+self.ui.formatStr.text() , 'downloadImg='+str(self.downloadImage)]))

self.confirmDialog.close()
self.progressbar = self.CustomProgressBar()
self.progressbar.move(-500, -500)
Expand Down Expand Up @@ -180,10 +185,10 @@ def downloadImgChecked(self):
try:
if self.ui.downloadImgCheckBox.isChecked():
self.downloadImage = True
self.configPath.write_text("downloadImg=True")
self.settings[0] = True
else:
self.downloadImage = False
self.configPath.write_text("downloadImg=False")
self.settings[0] = False
except:
pass

Expand Down

0 comments on commit 4ad1134

Please sign in to comment.