Replacing requests validation with urlparse.

This commit is contained in:
MichaelFitzurka 2022-04-01 09:48:53 -04:00
parent 8c5d4869f9
commit 2a3620ea21

View File

@ -25,13 +25,14 @@ import json
import webbrowser
import re
import pickle
import requests
#import signal
from PyQt5 import QtCore, QtGui, QtWidgets, uic
from PyQt5 import QtNetwork
from PyQt5.QtCore import QUrl
from urllib.parse import urlparse
#from comicarchive import ComicArchive
#from pageloader import PageLoader
from .volumeselectionwindow import VolumeSelectionWindow
@ -1376,15 +1377,20 @@ class TaggerWindow(QtWidgets.QMainWindow):
def openWebLink(self):
if self.leWebLink is not None:
web_link = self.leWebLink.text().strip();
if web_link:
try:
requests.get(web_link)
webbrowser.open_new_tab(web_link)
except:
QtWidgets.QMessageBox.information(
self,
self.tr("Web Link"),
self.tr("Web Link is invalid."))
valid = False;
try:
result = urlparse(web_link)
valid = all([result.scheme in ["http", "https"], result.netloc])
except:
pass
if valid:
webbrowser.open_new_tab(web_link)
else:
QtWidgets.QMessageBox.warning(
self,
self.tr("Web Link"),
self.tr("Web Link is invalid."))
def showSettings(self):