mirror of
https://github.com/yihong0618/Kindle_download_helper.git
synced 2025-11-22 07:59:04 +08:00
feat: webbrowser open and format with black
This commit is contained in:
@@ -69,6 +69,11 @@ pip3 install -r requirements.txt
|
||||
|
||||
## Enjoy
|
||||
|
||||
## 贡献
|
||||
|
||||
1. 任何 issues PR welcome
|
||||
2. `black kindle.py`
|
||||
|
||||
## 赞赏
|
||||
|
||||
- 谢谢就够啦
|
||||
|
||||
20
kindle.py
20
kindle.py
@@ -3,18 +3,17 @@ Note some download code from: https://github.com/sghctoma/bOOkp
|
||||
Great Thanks
|
||||
"""
|
||||
|
||||
import argparse
|
||||
import html
|
||||
from http.cookies import SimpleCookie
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import json
|
||||
import urllib
|
||||
import urllib3
|
||||
from http.cookies import SimpleCookie
|
||||
|
||||
import browsercookie
|
||||
import requests
|
||||
import argparse
|
||||
import urllib3
|
||||
|
||||
logger = logging.getLogger("kindle")
|
||||
|
||||
@@ -111,6 +110,17 @@ class Kindle:
|
||||
)
|
||||
devices = r.json()
|
||||
if devices.get("error"):
|
||||
# help user open it directly.
|
||||
import webbrowser
|
||||
|
||||
try:
|
||||
logger.info(
|
||||
"Opening the url to get cookie...You can wait for the page to finish loading and retry"
|
||||
)
|
||||
webbrowser.open(self.urls["bookall"])
|
||||
except:
|
||||
# just do nothing
|
||||
pass
|
||||
raise Exception(
|
||||
f"Error: {devices.get('error')}, please visit {self.urls['bookall']} to revoke the csrftoken and cookie"
|
||||
)
|
||||
|
||||
@@ -2,9 +2,10 @@ import logging
|
||||
import os
|
||||
import sys
|
||||
import traceback
|
||||
from typing import NamedTuple
|
||||
import webbrowser
|
||||
from PySide6 import QtWidgets, QtCore, QtGui
|
||||
from typing import NamedTuple
|
||||
|
||||
from PySide6 import QtCore, QtGui, QtWidgets
|
||||
|
||||
import kindle
|
||||
from ui_kindle import Ui_MainDialog
|
||||
|
||||
Reference in New Issue
Block a user