Fix talker settings validation

This commit is contained in:
Timmy Welch 2023-02-23 10:36:57 -08:00
parent fca5818874
commit 5b2a06870a
No known key found for this signature in database
3 changed files with 8 additions and 5 deletions

View File

@ -28,6 +28,7 @@ from PyQt5 import QtCore, QtGui, QtWidgets, uic
import comictaggerlib.ui.talkeruigenerator
from comicapi import utils
from comicapi.genericmetadata import md_test
from comictaggerlib import ctsettings
from comictaggerlib.ctversion import version
from comictaggerlib.filerenamer import FileRenamer, Replacement, Replacements
from comictaggerlib.imagefetcher import ImageFetcher
@ -466,9 +467,9 @@ class SettingsWindow(QtWidgets.QDialog):
QtWidgets.QDialog.accept(self)
def update_talkers_config(self) -> None:
cfg = settngs.normalize_config(self.config, True, True)
for talker, talker_obj in self.talkers.items():
talker_obj.parse_settings(cfg[0][f"talker_{talker}"])
ctsettings.talkers = self.talkers
self.config = ctsettings.plugin.validate_talker_settings(self.config)
del ctsettings.talkers
def select_rar(self) -> None:
self.select_file(self.leRarExePath, "RAR")

View File

@ -135,6 +135,8 @@ class ComicTalker:
if settings[f"{self.id}_url"]:
self.api_url = fix_url(settings[f"{self.id}_url"])
settings[f"{self.id}_url"] = self.api_url
if self.api_key == "":
self.api_key = self.default_api_key
if self.api_url == "":

View File

@ -14,6 +14,7 @@
from __future__ import annotations
import logging
import posixpath
import re
from urllib.parse import urlsplit
@ -30,8 +31,7 @@ logger = logging.getLogger(__name__)
def fix_url(url: str) -> str:
tmp_url = urlsplit(url)
# joinurl only works properly if there is a trailing slash
if tmp_url.path and tmp_url.path[-1] != "/":
tmp_url = tmp_url._replace(path=tmp_url.path + "/")
tmp_url = tmp_url._replace(path=posixpath.normpath(tmp_url.path) + "/")
return tmp_url.geturl()