1
0
mirror of https://github.com/ciromattia/kcc synced 2025-12-12 17:26:23 +00:00

Removed MCD support

This commit is contained in:
Paweł Jastrzębski
2019-03-06 16:16:26 +01:00
parent 7f719a22ad
commit c07a9657ef
7 changed files with 11 additions and 76 deletions

View File

@@ -112,19 +112,6 @@
<item row="6" column="1"> <item row="6" column="1">
<widget class="QLineEdit" name="coloristLine"/> <widget class="QLineEdit" name="coloristLine"/>
</item> </item>
<item row="7" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;a href=&quot;https://github.com/ciromattia/kcc/wiki/Manga-Cover-Database-support&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;MUid:&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="QLineEdit" name="muidLine"/>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>

View File

@@ -24,6 +24,7 @@ from urllib.request import urlopen, urlretrieve, Request
from time import sleep from time import sleep
from shutil import move from shutil import move
from subprocess import STDOUT, PIPE from subprocess import STDOUT, PIPE
# noinspection PyUnresolvedReferences
from PyQt5 import QtGui, QtCore, QtWidgets, QtNetwork from PyQt5 import QtGui, QtCore, QtWidgets, QtNetwork
from xml.dom.minidom import parse from xml.dom.minidom import parse
from xml.sax.saxutils import escape from xml.sax.saxutils import escape
@@ -887,6 +888,7 @@ class KCCGUI(KCC_ui.Ui_mainWindow):
self.targetDirectory = '' self.targetDirectory = ''
self.sentry = Client(release=__version__) self.sentry = Client(release=__version__)
if sys.platform.startswith('win'): if sys.platform.startswith('win'):
# noinspection PyUnresolvedReferences
from psutil import BELOW_NORMAL_PRIORITY_CLASS from psutil import BELOW_NORMAL_PRIORITY_CLASS
self.p = Process(os.getpid()) self.p = Process(os.getpid())
self.p.nice(BELOW_NORMAL_PRIORITY_CLASS) self.p.nice(BELOW_NORMAL_PRIORITY_CLASS)
@@ -935,7 +937,7 @@ class KCCGUI(KCC_ui.Ui_mainWindow):
"Kobo Aura ONE": {'PVOptions': False, 'ForceExpert': False, 'DefaultFormat': 1, "Kobo Aura ONE": {'PVOptions': False, 'ForceExpert': False, 'DefaultFormat': 1,
'DefaultUpscale': True, 'Label': 'KoAO'}, 'DefaultUpscale': True, 'Label': 'KoAO'},
"Kobo Forma": {'PVOptions': False, 'ForceExpert': False, 'DefaultFormat': 1, "Kobo Forma": {'PVOptions': False, 'ForceExpert': False, 'DefaultFormat': 1,
'DefaultUpscale': True, 'Label': 'KoF'}, 'DefaultUpscale': True, 'Label': 'KoF'},
"Other": {'PVOptions': False, 'ForceExpert': True, 'DefaultFormat': 1, "Other": {'PVOptions': False, 'ForceExpert': True, 'DefaultFormat': 1,
'DefaultUpscale': False, 'Label': 'OTHER'}, 'DefaultUpscale': False, 'Label': 'OTHER'},
"Kindle 1": {'PVOptions': False, 'ForceExpert': False, 'DefaultFormat': 0, "Kindle 1": {'PVOptions': False, 'ForceExpert': False, 'DefaultFormat': 0,
@@ -1084,11 +1086,8 @@ class KCCGUI_MetaEditor(KCC_ui_editor.Ui_editorDialog):
self.editorWidget.setEnabled(True) self.editorWidget.setEnabled(True)
self.okButton.setEnabled(True) self.okButton.setEnabled(True)
self.statusLabel.setText('Separate authors with a comma.') self.statusLabel.setText('Separate authors with a comma.')
for field in (self.seriesLine, self.volumeLine, self.numberLine, self.muidLine): for field in (self.seriesLine, self.volumeLine, self.numberLine):
if field.objectName() == 'muidLine': field.setText(self.parser.data[field.objectName().capitalize()[:-4]])
field.setText(self.parser.data['MUid'])
else:
field.setText(self.parser.data[field.objectName().capitalize()[:-4]])
for field in (self.writerLine, self.pencillerLine, self.inkerLine, self.coloristLine): for field in (self.writerLine, self.pencillerLine, self.inkerLine, self.coloristLine):
field.setText(', '.join(self.parser.data[field.objectName().capitalize()[:-4] + 's'])) field.setText(', '.join(self.parser.data[field.objectName().capitalize()[:-4] + 's']))
if self.seriesLine.text() == '': if self.seriesLine.text() == '':
@@ -1098,12 +1097,9 @@ class KCCGUI_MetaEditor(KCC_ui_editor.Ui_editorDialog):
self.seriesLine.setText(file.split('\\')[-1].split('/')[-1].split('.')[0]) self.seriesLine.setText(file.split('\\')[-1].split('/')[-1].split('.')[0])
def saveData(self): def saveData(self):
for field in (self.volumeLine, self.numberLine, self.muidLine): for field in (self.volumeLine, self.numberLine):
if field.text().isnumeric() or self.cleanData(field.text()) == '': if field.text().isnumeric() or self.cleanData(field.text()) == '':
if field.objectName() == 'muidLine': self.parser.data[field.objectName().capitalize()[:-4]] = self.cleanData(field.text())
self.parser.data['MUid'] = self.cleanData(field.text())
else:
self.parser.data[field.objectName().capitalize()[:-4]] = self.cleanData(field.text())
else: else:
self.statusLabel.setText(field.objectName().capitalize()[:-4] + ' field must be a number.') self.statusLabel.setText(field.objectName().capitalize()[:-4] + ' field must be a number.')
break break

View File

@@ -66,13 +66,6 @@ class Ui_editorDialog(object):
self.coloristLine = QtWidgets.QLineEdit(self.editorWidget) self.coloristLine = QtWidgets.QLineEdit(self.editorWidget)
self.coloristLine.setObjectName("coloristLine") self.coloristLine.setObjectName("coloristLine")
self.gridLayout.addWidget(self.coloristLine, 6, 1, 1, 1) self.gridLayout.addWidget(self.coloristLine, 6, 1, 1, 1)
self.label_8 = QtWidgets.QLabel(self.editorWidget)
self.label_8.setOpenExternalLinks(True)
self.label_8.setObjectName("label_8")
self.gridLayout.addWidget(self.label_8, 7, 0, 1, 1)
self.muidLine = QtWidgets.QLineEdit(self.editorWidget)
self.muidLine.setObjectName("muidLine")
self.gridLayout.addWidget(self.muidLine, 7, 1, 1, 1)
self.verticalLayout.addWidget(self.editorWidget) self.verticalLayout.addWidget(self.editorWidget)
self.optionWidget = QtWidgets.QWidget(editorDialog) self.optionWidget = QtWidgets.QWidget(editorDialog)
self.optionWidget.setObjectName("optionWidget") self.optionWidget.setObjectName("optionWidget")
@@ -117,7 +110,6 @@ class Ui_editorDialog(object):
self.label_5.setText(_translate("editorDialog", "Penciller:")) self.label_5.setText(_translate("editorDialog", "Penciller:"))
self.label_6.setText(_translate("editorDialog", "Inker:")) self.label_6.setText(_translate("editorDialog", "Inker:"))
self.label_7.setText(_translate("editorDialog", "Colorist:")) self.label_7.setText(_translate("editorDialog", "Colorist:"))
self.label_8.setText(_translate("editorDialog", "<html><head/><body><p><a href=\"https://github.com/ciromattia/kcc/wiki/Manga-Cover-Database-support\"><span style=\" text-decoration: underline; color:#0000ff;\">MUid:</span></a></p></body></html>"))
self.okButton.setText(_translate("editorDialog", "Save")) self.okButton.setText(_translate("editorDialog", "Save"))
self.cancelButton.setText(_translate("editorDialog", "Cancel")) self.cancelButton.setText(_translate("editorDialog", "Cancel"))

View File

@@ -23,8 +23,6 @@ import sys
from time import strftime, gmtime from time import strftime, gmtime
from copy import copy from copy import copy
from glob import glob, escape from glob import glob, escape
from json import loads
from urllib.request import Request, urlopen
from re import sub from re import sub
from stat import S_IWRITE, S_IREAD, S_IEXEC from stat import S_IWRITE, S_IREAD, S_IEXEC
from zipfile import ZipFile, ZIP_STORED, ZIP_DEFLATED from zipfile import ZipFile, ZIP_STORED, ZIP_DEFLATED
@@ -648,7 +646,6 @@ def getOutputFilename(srcpath, wantedname, ext, tomenumber):
def getComicInfo(path, originalpath): def getComicInfo(path, originalpath):
xmlPath = os.path.join(path, 'ComicInfo.xml') xmlPath = os.path.join(path, 'ComicInfo.xml')
options.authors = ['KCC'] options.authors = ['KCC']
options.remoteCovers = {}
options.chapters = [] options.chapters = []
options.summary = '' options.summary = ''
titleSuffix = '' titleSuffix = ''
@@ -683,8 +680,6 @@ def getComicInfo(path, originalpath):
options.authors.sort() options.authors.sort()
else: else:
options.authors = ['KCC'] options.authors = ['KCC']
if xml.data['MUid']:
options.remoteCovers = getCoversFromMCB(xml.data['MUid'])
if xml.data['Bookmarks']: if xml.data['Bookmarks']:
options.chapters = xml.data['Bookmarks'] options.chapters = xml.data['Bookmarks']
if xml.data['Summary']: if xml.data['Summary']:
@@ -692,20 +687,6 @@ def getComicInfo(path, originalpath):
os.remove(xmlPath) os.remove(xmlPath)
def getCoversFromMCB(mangaid):
covers = {}
try:
jsonRaw = urlopen(Request('http://mcd.iosphe.re/api/v1/series/' + mangaid + '/',
headers={'User-Agent': 'KindleComicConverter/' + __version__}))
jsonData = loads(jsonRaw.read().decode('utf-8'))
for volume in jsonData['Covers']['a']:
if volume['Side'] == 'front':
covers[int(volume['Volume'])] = volume['Raw']
except Exception:
return {}
return covers
def getDirectorySize(start_path='.'): def getDirectorySize(start_path='.'):
total_size = 0 total_size = 0
for dirpath, _, filenames in os.walk(start_path): for dirpath, _, filenames in os.walk(start_path):

View File

@@ -20,12 +20,8 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import os import os
from io import BytesIO
from urllib.request import Request, urlopen
from urllib.parse import quote
from PIL import Image, ImageOps, ImageStat, ImageChops, ImageFilter from PIL import Image, ImageOps, ImageStat, ImageChops, ImageFilter
from .shared import md5Checksum from .shared import md5Checksum
from . import __version__
class ProfileData: class ProfileData:
@@ -347,15 +343,7 @@ class Cover:
self.tomeid = 1 self.tomeid = 1
else: else:
self.tomeid = tomeid self.tomeid = tomeid
if self.tomeid in self.options.remoteCovers: self.image = Image.open(source)
try:
source = urlopen(Request(quote(self.options.remoteCovers[self.tomeid]).replace('%3A', ':', 1),
headers={'User-Agent': 'KindleComicConverter/' + __version__})).read()
self.image = Image.open(BytesIO(source))
except Exception:
self.image = Image.open(source)
else:
self.image = Image.open(source)
self.process() self.process()
def process(self): def process(self):

View File

@@ -18,7 +18,6 @@
import os import os
from xml.dom.minidom import parse, Document from xml.dom.minidom import parse, Document
from re import compile
from tempfile import mkdtemp from tempfile import mkdtemp
from shutil import rmtree from shutil import rmtree
from . import comicarchive from . import comicarchive
@@ -35,7 +34,6 @@ class MetadataParser:
'Inkers': [], 'Inkers': [],
'Colorists': [], 'Colorists': [],
'Summary': '', 'Summary': '',
'MUid': '',
'Bookmarks': []} 'Bookmarks': []}
self.rawdata = None self.rawdata = None
self.format = None self.format = None
@@ -67,11 +65,6 @@ class MetadataParser:
self.data[field + 's'].append(person) self.data[field + 's'].append(person)
self.data[field + 's'] = list(set(self.data[field + 's'])) self.data[field + 's'] = list(set(self.data[field + 's']))
self.data[field + 's'].sort() self.data[field + 's'].sort()
if len(self.rawdata.getElementsByTagName('ScanInformation')) != 0:
coverId = compile('(MCD\\()(\\d+)(\\))')\
.search(self.rawdata.getElementsByTagName('ScanInformation')[0].firstChild.nodeValue)
if coverId:
self.data['MUid'] = coverId.group(2)
if len(self.rawdata.getElementsByTagName('Page')) != 0: if len(self.rawdata.getElementsByTagName('Page')) != 0:
for page in self.rawdata.getElementsByTagName('Page'): for page in self.rawdata.getElementsByTagName('Page'):
if 'Bookmark' in page.attributes and 'Image' in page.attributes: if 'Bookmark' in page.attributes and 'Image' in page.attributes:
@@ -84,8 +77,7 @@ class MetadataParser:
for row in (['Series', self.data['Series']], ['Volume', self.data['Volume']], for row in (['Series', self.data['Series']], ['Volume', self.data['Volume']],
['Number', self.data['Number']], ['Writer', ', '.join(self.data['Writers'])], ['Number', self.data['Number']], ['Writer', ', '.join(self.data['Writers'])],
['Penciller', ', '.join(self.data['Pencillers'])], ['Inker', ', '.join(self.data['Inkers'])], ['Penciller', ', '.join(self.data['Pencillers'])], ['Inker', ', '.join(self.data['Inkers'])],
['Colorist', ', '.join(self.data['Colorists'])], ['Summary', self.data['Summary']], ['Colorist', ', '.join(self.data['Colorists'])], ['Summary', self.data['Summary']]):
['ScanInformation', 'MCD(' + self.data['MUid'] + ')' if self.data['MUid'] else '']):
if self.rawdata.getElementsByTagName(row[0]): if self.rawdata.getElementsByTagName(row[0]):
node = self.rawdata.getElementsByTagName(row[0])[0] node = self.rawdata.getElementsByTagName(row[0])[0]
if row[1]: if row[1]:
@@ -106,8 +98,7 @@ class MetadataParser:
for row in (['Series', self.data['Series']], ['Volume', self.data['Volume']], for row in (['Series', self.data['Series']], ['Volume', self.data['Volume']],
['Number', self.data['Number']], ['Writer', ', '.join(self.data['Writers'])], ['Number', self.data['Number']], ['Writer', ', '.join(self.data['Writers'])],
['Penciller', ', '.join(self.data['Pencillers'])], ['Inker', ', '.join(self.data['Inkers'])], ['Penciller', ', '.join(self.data['Pencillers'])], ['Inker', ', '.join(self.data['Inkers'])],
['Colorist', ', '.join(self.data['Colorists'])], ['Summary', self.data['Summary']], ['Colorist', ', '.join(self.data['Colorists'])], ['Summary', self.data['Summary']]):
['ScanInformation', 'MCD(' + self.data['MUid'] + ')' if self.data['MUid'] else '']):
if row[1]: if row[1]:
main = doc.createElement(row[0]) main = doc.createElement(row[0])
root.appendChild(main) root.appendChild(main)

View File

@@ -46,7 +46,7 @@ class BuildBinaryCommand(distutils.cmd.Command):
os.system('appdmg kcc.json dist/KindleComicConverter_osx_' + VERSION + '.dmg') os.system('appdmg kcc.json dist/KindleComicConverter_osx_' + VERSION + '.dmg')
exit(0) exit(0)
elif sys.platform == 'win32': elif sys.platform == 'win32':
os.system('pyinstaller -y -F -i icons\comic2ebook.ico -n KCC -w --noupx kcc.py') os.system('pyinstaller -y -F -i icons\\comic2ebook.ico -n KCC -w --noupx kcc.py')
exit(0) exit(0)
else: else:
os.system('pyinstaller -y -F kcc.py') os.system('pyinstaller -y -F kcc.py')