Skip to content

Commit

Permalink
changes from develop-fluent
Browse files Browse the repository at this point in the history
  • Loading branch information
brandonzorn committed Mar 30, 2024
1 parent d29c29c commit 4f9d5f2
Show file tree
Hide file tree
Showing 34 changed files with 68 additions and 51 deletions.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
inline-quotes=double
import-order-style=google
max-line-length = 120
extend-ignore = R503,R502,F401
extend-ignore = R503,R502,F401,N802
exclude =
.git,
__pycache__,
Expand Down
Binary file removed .github/Images/app_icon.png
Binary file not shown.
Binary file removed .github/Screenshots/nl_1.png
Binary file not shown.
Binary file removed .github/Screenshots/nl_2.png
Binary file not shown.
Binary file removed .github/Screenshots/nl_3.png
Binary file not shown.
4 changes: 2 additions & 2 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ name: Python application

on:
push:
branches: [ "master", "develop" ]
branches: [ "master", "develop", "develop-fluent"]
pull_request:
branches: [ "master", "develop" ]
branches: [ "master", "develop", "develop-fluent"]

permissions:
contents: read
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## Nlight

![Nlight](./.github/Images/app_icon.png)
![Nlight](https://github.com/brandonzorn/Nlight/assets/68778953/2e2d3ed8-eef6-4b44-a824-7d38c7a78ea9)


Open source manga and ranobe reading application

Expand Down
5 changes: 3 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
from PySide6.QtWidgets import QApplication

from nlightreader import ParentWindow
from nlightreader.consts import APP_VERSION, APP_NAME, Icons
from nlightreader.consts.app import APP_VERSION, APP_NAME
from nlightreader.consts.files import Icons
from nlightreader.utils import get_locale, get_ui_style, Thread


Expand Down Expand Up @@ -45,7 +46,6 @@ def __init__(self):
self.setWindowTitle(APP_NAME)
self._theme_updater = Thread(target=self.theme_listener, callback=self.update_style)
self._theme_updater.start()
self.show()

@staticmethod
def theme_listener():
Expand Down Expand Up @@ -74,4 +74,5 @@ def closeEvent(self, event):
app = App(sys.argv)
Path(f"{platformdirs.user_data_dir()}/{APP_NAME}").mkdir(parents=True, exist_ok=True)
window = MainWindow()
window.show()
sys.exit(app.exec())
2 changes: 1 addition & 1 deletion make_version_file.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pyinstaller_versionfile

from nlightreader.consts import APP_VERSION, APP_NAME
from nlightreader.consts.app import APP_VERSION, APP_NAME

pyinstaller_versionfile.create_versionfile(
output_file="pkg_res/version_info.txt",
Expand Down
7 changes: 1 addition & 6 deletions nlightreader/consts/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
from .app import APP_NAME, APP_VERSION
from .colors import ItemsColors, StyleColors
from .enums import Nl, lib_lists_en, parse_lib_list
from .files import Styles, Icons, LangIcons, Translations
from .paths import TOKEN_PATH
from .urls import *
from . import app, colors, enums, files, paths, urls
2 changes: 1 addition & 1 deletion nlightreader/dialogs/Rate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from PySide6.QtWidgets import QDialog, QLayout

from data.ui.dialogs.rate import Ui_Dialog
from nlightreader.consts import lib_lists_en, parse_lib_list
from nlightreader.consts.enums import lib_lists_en, parse_lib_list
from nlightreader.items import Manga
from nlightreader.utils import translate
from nlightreader.utils.catalog_manager import get_catalog, get_lib_catalog
Expand Down
2 changes: 1 addition & 1 deletion nlightreader/items/RequestForm.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from nlightreader.consts import Nl
from nlightreader.consts.enums import Nl
from nlightreader.items.sort_items import Order, Genre, Kind


Expand Down
2 changes: 1 addition & 1 deletion nlightreader/items/manga_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from PySide6.QtCore import QLocale

from nlightreader.consts import Nl
from nlightreader.consts.enums import Nl
from nlightreader.items.BaseItem import BaseItem
from nlightreader.items.sort_items import Genre

Expand Down
26 changes: 15 additions & 11 deletions nlightreader/parsers/Shikimori.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import logging

import requests
from PySide6.QtWidgets import QApplication
from requests_oauthlib import OAuth2Session

from nlightreader.consts import URL_SHIKIMORI_API, SHIKIMORI_HEADERS, URL_SHIKIMORI, URL_SHIKIMORI_TOKEN, Nl
from nlightreader.consts.urls import URL_SHIKIMORI_API, SHIKIMORI_HEADERS, URL_SHIKIMORI, URL_SHIKIMORI_TOKEN
from nlightreader.consts.enums import Nl
from nlightreader.consts.items import ShikimoriItems
from nlightreader.items import Manga, RequestForm, Genre, Kind, User, UserRate, Character, Order
from nlightreader.parsers.catalog import AbstractCatalog, LibParser
Expand All @@ -14,7 +17,7 @@
try:
from keys import SHIKIMORI_CLIENT_SECRET, SHIKIMORI_CLIENT_ID
except (ModuleNotFoundError, ImportError):
print("Shikimori API keys not found")
logging.info("Shikimori API keys not found")
SHIKIMORI_CLIENT_SECRET, SHIKIMORI_CLIENT_ID = "", ""


Expand Down Expand Up @@ -278,7 +281,7 @@ def fetch_token(self, code):
try:
self.client.fetch_token(URL_SHIKIMORI_TOKEN, code, client_secret=self.client_secret)
except Exception as e:
print(e)
logging.error(e)
TokenManager.save_token(self.token, ShikimoriLib.CATALOG_NAME)
return self.token

Expand All @@ -301,7 +304,7 @@ def refresh_token(self):
"Authorization": f"Bearer {TokenManager.load_token(ShikimoriLib.CATALOG_NAME).get('access_token')}"})
return self.token
except Exception as e:
print(e)
logging.error(e)

def request(self, method, url, *, params=None, json=None, ignore_authorize=False):
if ((not ignore_authorize and not self.is_authorized) or
Expand All @@ -313,13 +316,14 @@ def request(self, method, url, *, params=None, json=None, ignore_authorize=False
response.raise_for_status()
return response
except requests.exceptions.RequestException as e:
print(f"Error fetching URL: {url}")
print(f" Reason: {e}")
print(f" Headers: {self.client.headers}")
print(f" Params: {params}")
print(f" Cookies: {self.client.cookies}")
print(f" Json: {json}")
return
logging.error(
f"\n\tError fetching URL: {url}\n"
f"\t\tReason: {e}\n"
f"\t\tHeaders: {self.client.headers}\n"
f"\t\tParams: {params}\n"
f"\t\tCookies: {self.client.cookies}\n"
f"\t\tJson: {json}\n",
)

def check_auth(self):
url = f"{URL_SHIKIMORI_API}/users/whoami"
Expand Down
2 changes: 1 addition & 1 deletion nlightreader/parsers/catalog.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from nlightreader.consts import DEFAULT_HEADERS
from nlightreader.consts.urls import DEFAULT_HEADERS
from nlightreader.consts.items.parser_items import ParserItems
from nlightreader.items import Manga, Chapter, Image, RequestForm, Genre, Kind, Order, Character, User, UserRate

Expand Down
2 changes: 1 addition & 1 deletion nlightreader/parsers/catalogs_base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from nlightreader.consts import Nl
from nlightreader.consts.enums import Nl
from nlightreader.parsers.catalog import AbstractCatalog


Expand Down
3 changes: 2 additions & 1 deletion nlightreader/parsers/hentai_manga/allhentai_hmanga.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from bs4 import BeautifulSoup

from nlightreader.consts import URL_ALLHENTAI, URL_ALLHENTAI_API, Nl
from nlightreader.consts.urls import URL_ALLHENTAI, URL_ALLHENTAI_API
from nlightreader.consts.enums import Nl
from nlightreader.items import Manga, Chapter, Image
from nlightreader.parsers.catalogs_base import AbstractHentaiMangaCatalog
from nlightreader.utils.utils import get_html, make_request
Expand Down
2 changes: 1 addition & 1 deletion nlightreader/parsers/hentai_manga/nhentai_hmanga.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from bs4 import BeautifulSoup

from nlightreader.consts import URL_NHENTAI, URL_NHENTAI_API
from nlightreader.consts.urls import URL_NHENTAI, URL_NHENTAI_API
from nlightreader.items import Manga, Chapter, Image
from nlightreader.parsers.catalogs_base import AbstractHentaiMangaCatalog
from nlightreader.utils.utils import get_html
Expand Down
3 changes: 2 additions & 1 deletion nlightreader/parsers/manga/Lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

from bs4 import BeautifulSoup

from nlightreader.consts import URL_SLASHLIB, URL_MANGALIB, Nl
from nlightreader.consts.urls import URL_SLASHLIB, URL_MANGALIB
from nlightreader.consts.enums import Nl
from nlightreader.items import RequestForm, Manga, Chapter, Image
from nlightreader.parsers.catalog import AbstractCatalog
from nlightreader.parsers.catalogs_base import AbstractMangaCatalog
Expand Down
3 changes: 2 additions & 1 deletion nlightreader/parsers/manga/desu_manga.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from nlightreader.consts import URL_DESU_API, DESU_HEADERS, URL_DESU, Nl
from nlightreader.consts.urls import URL_DESU_API, DESU_HEADERS, URL_DESU
from nlightreader.consts.enums import Nl
from nlightreader.consts.items import DesuItems
from nlightreader.items import Manga, Chapter, Image, Genre, RequestForm
from nlightreader.parsers.catalogs_base import AbstractMangaCatalog
Expand Down
7 changes: 5 additions & 2 deletions nlightreader/parsers/manga/mangadex_manga.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
from nlightreader.consts import URL_MANGA_DEX_API, URL_MANGA_DEX, Nl, MANGA_DEX_HEADERS, URL_MANGA_DEX_TOKEN
import logging

from nlightreader.consts.urls import URL_MANGA_DEX_API, URL_MANGA_DEX, MANGA_DEX_HEADERS, URL_MANGA_DEX_TOKEN
from nlightreader.consts.enums import Nl
from nlightreader.items import Manga, Chapter, Image, Genre, RequestForm, User, Kind
from nlightreader.parsers.catalog import LibParser
from nlightreader.parsers.catalogs_base import AbstractMangaCatalog
Expand All @@ -9,7 +12,7 @@
try:
from keys import MANGADEX_CLIENT_ID, MANGADEX_CLIENT_SECRET
except (ModuleNotFoundError, ImportError):
print("MangaDex API keys not found")
logging.info("MangaDex API keys not found")
MANGADEX_CLIENT_ID, MANGADEX_CLIENT_SECRET = "", ""


Expand Down
3 changes: 2 additions & 1 deletion nlightreader/parsers/manga/remanga_manga.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from nlightreader.consts import URL_REMANGA_API, URL_REMANGA, Nl
from nlightreader.consts.urls import URL_REMANGA_API, URL_REMANGA
from nlightreader.consts.enums import Nl
from nlightreader.consts.items import RemangaItems
from nlightreader.items import RequestForm, Manga, Chapter, Image
from nlightreader.parsers.catalogs_base import AbstractMangaCatalog
Expand Down
3 changes: 2 additions & 1 deletion nlightreader/parsers/ranobe/ranobehub_ranobe.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import bs4.element
from bs4 import BeautifulSoup

from nlightreader.consts import URL_RANOBEHUB_API, URL_RANOBEHUB, Nl
from nlightreader.consts.urls import URL_RANOBEHUB_API, URL_RANOBEHUB
from nlightreader.consts.enums import Nl
from nlightreader.consts.items import RanobehubItems
from nlightreader.items import RequestForm, Manga, Chapter, Image
from nlightreader.parsers.catalogs_base import AbstractRanobeCatalog
Expand Down
3 changes: 2 additions & 1 deletion nlightreader/parsers/ranobe/rulate_ranobe.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

from bs4 import BeautifulSoup

from nlightreader.consts import URL_RULATE, URL_EROLATE, Nl
from nlightreader.consts.urls import URL_RULATE, URL_EROLATE
from nlightreader.consts.enums import Nl
from nlightreader.consts.items import RulateItems
from nlightreader.items import Manga, Chapter, Image, RequestForm
from nlightreader.parsers.catalogs_base import AbstractRanobeCatalog
Expand Down
3 changes: 2 additions & 1 deletion nlightreader/utils/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
import platformdirs
from sqlalchemy.dialects.sqlite import insert

from nlightreader.consts import APP_NAME, Nl
from nlightreader.consts.app import APP_NAME
from nlightreader.consts.enums import Nl
from nlightreader.items import Chapter, Manga, HistoryNote
from nlightreader.utils.decorators import singleton

Expand Down
3 changes: 2 additions & 1 deletion nlightreader/utils/file_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
import platformdirs
from PySide6.QtGui import QPixmap

from nlightreader.consts import APP_NAME, Nl
from nlightreader.consts.app import APP_NAME
from nlightreader.consts.enums import Nl
from nlightreader.items import Manga, Chapter, Character


Expand Down
2 changes: 1 addition & 1 deletion nlightreader/utils/token.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json
from pathlib import Path

from nlightreader.consts import TOKEN_PATH
from nlightreader.consts.paths import TOKEN_PATH


class TokenManager:
Expand Down
4 changes: 3 additions & 1 deletion nlightreader/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
from PySide6.QtCore import QLocale
from PySide6.QtWidgets import QApplication

from nlightreader.consts import DEFAULT_HEADERS, Nl, StyleColors
from nlightreader.consts.urls import DEFAULT_HEADERS
from nlightreader.consts.enums import Nl
from nlightreader.consts.colors import StyleColors
from nlightreader.consts.files import LangIcons, Translations, Styles


Expand Down
2 changes: 1 addition & 1 deletion nlightreader/widgets/NlightTemplates/BaseWidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from PySide6.QtCore import Signal, QMutex, Slot
from PySide6.QtWidgets import QWidget

from nlightreader.consts import Nl
from nlightreader.consts.enums import Nl
from nlightreader.items import Manga, RequestForm
from nlightreader.utils import Thread
from nlightreader.widgets.NlightContainers.manga_area import MangaArea
Expand Down
2 changes: 1 addition & 1 deletion nlightreader/widgets/NlightTemplates/History.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from PySide6.QtWidgets import QWidget, QTreeWidgetItem

from data.ui.widgets.history import Ui_Form
from nlightreader.consts import ItemsColors
from nlightreader.consts.colors import ItemsColors
from nlightreader.contexts import HistoryNoteMenu
from nlightreader.items import HistoryNote, Manga
from nlightreader.utils import Database
Expand Down
10 changes: 6 additions & 4 deletions nlightreader/widgets/NlightTemplates/Info.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import logging

from PySide6.QtCore import Qt, QSize, Slot, Signal, QThreadPool
from PySide6.QtGui import QIcon
from PySide6.QtWidgets import QWidget, QListWidgetItem, QTreeWidgetItem

from data.ui.widgets.info import Ui_Form
from nlightreader.consts import lib_lists_en, ItemsColors, Nl
from nlightreader.consts.enums import lib_lists_en, Nl
from nlightreader.consts.colors import ItemsColors
from nlightreader.contexts import ReadMarkMenu
from nlightreader.dialogs import FormRate, FormCharacter
from nlightreader.items import Manga, Character, Chapter, HistoryNote
Expand Down Expand Up @@ -124,7 +127,7 @@ def info_setup():
self.manga = self.catalog.get_manga(manga)
self.db.add_manga(self.manga)
except Exception as e:
print(e)
logging.error(e)
self.setup_error.emit()

Worker(target=info_setup, callback=self.update_additional_info).start(pool=self.thread_pool)
Expand Down Expand Up @@ -199,13 +202,12 @@ def get_chapters(self):
def get_chapters():
self.chapters = self.catalog.get_chapters(self.manga)
self.chapters.reverse()
# self.chapters.sort(key=lambda ch: ch.language.value if ch.language.value else False)
self.sort_chapters()
self.db.add_chapters(self.chapters, self.manga)

def update_chapters():
self.ui.items_tree.clear()
self.ui.items_frame.setVisible(bool(self.chapters))
self.sort_chapters()
for lang in self.sorted_chapters:
lang_item = QTreeWidgetItem([translate("NlLanguage", lang.to_full_str())])
lang_item.setIcon(0, QIcon(get_language_icon(lang)))
Expand Down
2 changes: 1 addition & 1 deletion nlightreader/widgets/NlightTemplates/Library.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from data.ui.widgets.library import Ui_Form

from nlightreader.consts import Nl
from nlightreader.consts.enums import Nl
from nlightreader.items import Manga
from nlightreader.parsers import LocalLib
from nlightreader.widgets.NlightContainers.manga_area import MangaArea
Expand Down
2 changes: 1 addition & 1 deletion nlightreader/widgets/NlightTemplates/Shikimori.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from PySide6.QtCore import Slot

from data.ui.widgets.shikimori import Ui_Form
from nlightreader.consts import Nl
from nlightreader.consts.enums import Nl
from nlightreader.dialogs import FormAuth
from nlightreader.items import Manga
from nlightreader.parsers import ShikimoriLib
Expand Down
3 changes: 2 additions & 1 deletion nlightreader/windows/Reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
from PySide6.QtWidgets import QListWidgetItem, QMainWindow

from data.ui.windows.reader import Ui_ReaderWindow
from nlightreader.consts import ItemsColors, Nl
from nlightreader.consts.enums import Nl
from nlightreader.consts.colors import ItemsColors
from nlightreader.items import Manga, Chapter, Image, HistoryNote
from nlightreader.utils import Database, get_catalog, FileManager, translate, get_language_icon, Thread
from nlightreader.widgets.NlightContainers import TextArea
Expand Down

0 comments on commit 4f9d5f2

Please sign in to comment.