Clearer README & others

- Make README easier to read
- Supress RuntimeError when setting items to "Testing"
- Light reformatting
This commit is contained in:
cevoj35548 2023-05-30 23:49:15 -05:00
parent c7198f7764
commit 0931b34315
2 changed files with 41 additions and 23 deletions

View file

@ -1,14 +1,8 @@
"""
FMHY Dupe Checker
v1.17
== FMHY Dupe Checker ==
== by cevoj35548 ==
"""
__author__ = "cevoj"
__version__ = "1.17"
# networking
import grequests
import requests
import urllib3
@ -16,7 +10,6 @@ from fake_headers import Headers
from http.client import responses as status_codes
from requests.exceptions import ConnectTimeout, ReadTimeout, ConnectionError, SSLError
# gui
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtCore import pyqtSignal
from PyQt5 import uic
@ -25,7 +18,6 @@ import ctypes as ct
import darkdetect
from pyperclip import copy
# builtins
import sys
import os
import re
@ -39,6 +31,10 @@ from dataclasses import dataclass
from typing import Union
__author__ = "cevoj"
__version__ = "1.17"
# disable ssl warnings
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
# fake headers
@ -65,8 +61,8 @@ class StatusResp:
class LinkTest:
chunk_size = 50 # number of links to test at once
statusapi_url = b64decode('aHR0cHM6Ly9iYWNrZW5kLmh0dHBzdGF0dXMuaW8vYXBp').decode()
chunk_size = 50 # number of links to test at once
statusapi_url = b64decode('aHR0cHM6Ly9iYWNrZW5kLmh0dHBzdGF0dXMuaW8vYXBp').decode()
statusapi_headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:108.0) Gecko/20100101 Firefox/108.0',
'Accept': 'application/json, text/plain, */*',
@ -103,8 +99,7 @@ class LinkTest:
def handle_req(urls, items, callback, error_sig):
# process the request & send back to main event loop
dist_cnxns.put(1) # wait for when <3 instances of handle_req are running. blocks if full
for item in items:
item.setText(2, 'Testing...')
LinkTest.set_testing(items)
reqs = [
grequests.head(url, headers=headers.generate(), timeout=5, allow_redirects=True, verify=False)
for url in urls
@ -130,8 +125,7 @@ class LinkTest:
def thirdparty_req(urls, items, callback, error_sig):
# process the request & send back to main event loop
dist_cnxns.put(1) # wait for when <3 requests are running. blocks if full
for item in items:
item.setText(2, 'Testing...')
LinkTest.set_testing(items)
try:
resp = requests.post(
LinkTest.statusapi_url,
@ -169,6 +163,12 @@ class LinkTest:
)
# spawn thread to handle request
thread.start()
@staticmethod
def set_testing(items):
with suppress(RuntimeError):
for item in items:
item.setText(2, 'Testing...')
class UI(QMainWindow):

View file

@ -29,22 +29,40 @@ Run `FmhyChecker.pyw`
## Usage
### Comparing and copying links
### Comparing links to wiki
This tool takes links inputted into the field on the left, and checks if they are not already present in the wiki. Links will be automatically pulled using regex.
This tool takes links inputted into the field on the left, and checks if they are not already present in the wiki.
*Note that the ReGex is designed to ignore trailing `/`, `http`/`https`, and `www`/`ww1`...`2`...etc*
**Dupes** ***(already in wiki)*** will be indicated with a ❌, and **Unique links** ***(NOT in wiki)*** will have a ✅.
*Dupes* will be indicated with a ❌, and *unique* links will have a ✅. Once the scan is complete, the `Copy ❌` and `Copy ✅` buttons will be ungreyed, allowing you to copy all *dupe* or *unique* flagged links separated by a newline (`\n`).
Links will be automatically pulled using regex. The regex is designed to ignore trailing `/`, `http`/`https`, and `www`/`ww1`...`2`...etc to be as flexible as possible.
### Copying links
The UI provides 3 buttons to copy links to your clipboard.
| Button | What it copies |
|-|-|
| `Copy ❌` | Copies *duped* (❌) links |
| `Copy ✅` | Copies *unique* (✅) links |
| `Copy 🔍` | Only links that are *unique* (✅) **AND** *tested* with a *successful* response code (🟢)
### Broken link tester
![Usage video here](https://i.imgur.com/9BhHsaY.mp4)
**Usage video**
Selecting links and clicking `Test` will the URL's redirect chain. View a URL by hovering over its status code.
https://github.com/fmhy/dupe-checker/assets/125338382/e144e529-db6b-4989-a90e-e27f6881efb6
The `Copy 🔍` button will copy all links that are *unique* (✅) **and** *tested* to have successful responses (read more about status codes [here](https://httpstatus.io/http-status-codes)).
Selecting links and clicking `Test` will the fetch the URL's redirect chain. View more information by *hovering* over a status code.
| Status code | Indication |
|-|-|
| 🟢 `200`-`204` | Successful |
| 🔵 `301`-`307` | Redirect |
| 🟠 `400`-`410` | Client error |
| 🔴 `500`-`504` | Server error |
Read more about status codes [here](https://httpstatus.io/http-status-codes).
### CSV Exports