Remove fetch_issue_page_url from comictalker etc.
This commit is contained in:
parent
c1c8f4eb6e
commit
3ea44b7ca7
@ -20,7 +20,7 @@ TODO: This should be re-factored using subclasses!
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
from typing import Callable, cast
|
||||
from typing import Callable
|
||||
|
||||
from PyQt5 import QtCore, QtGui, QtWidgets, uic
|
||||
|
||||
@ -212,9 +212,8 @@ class CoverImageWidget(QtWidgets.QWidget):
|
||||
self.label.setText("Searching for alt. covers...")
|
||||
|
||||
# page URL should already be cached, so no need to defer
|
||||
issue_page_url = self.talker_api.fetch_issue_page_url(self.issue_id)
|
||||
ComicTalker.alt_url_list_fetch_complete = self.sig.emit_list
|
||||
self.talker_api.async_fetch_alternate_cover_urls(utils.xlate(self.issue_id), cast(str, issue_page_url))
|
||||
self.talker_api.async_fetch_alternate_cover_urls(utils.xlate(self.issue_id))
|
||||
|
||||
def alt_cover_url_list_fetch_complete(self, url_list: list[str]) -> None:
|
||||
if url_list:
|
||||
|
@ -271,7 +271,7 @@ class IssueIdentifier:
|
||||
raise IssueIdentifierCancelled
|
||||
|
||||
if use_remote_alternates:
|
||||
alt_img_url_list = self.talker_api.fetch_alternate_cover_urls(issue_id, page_url)
|
||||
alt_img_url_list = self.talker_api.fetch_alternate_cover_urls(issue_id)
|
||||
for alt_url in alt_img_url_list:
|
||||
try:
|
||||
alt_url_image_data = ImageFetcher().fetch(alt_url, blocking=True)
|
||||
|
@ -145,9 +145,9 @@ class ComicTalker:
|
||||
)
|
||||
|
||||
# For issueidentifer
|
||||
def fetch_alternate_cover_urls(self, issue_id: int, issue_page_url: str) -> list[str]:
|
||||
def fetch_alternate_cover_urls(self, issue_id: int) -> list[str]:
|
||||
try:
|
||||
alt_covers = self.talker.fetch_alternate_cover_urls(issue_id, issue_page_url)
|
||||
alt_covers = self.talker.fetch_alternate_cover_urls(issue_id)
|
||||
return alt_covers
|
||||
except NotImplementedError:
|
||||
logger.warning(f"{self.talker.source_details.name} has not implemented: 'fetch_alternate_cover_urls'")
|
||||
@ -200,23 +200,14 @@ class ComicTalker:
|
||||
except NotImplementedError:
|
||||
logger.warning(f"{self.talker.source_details.name} has not implemented: 'async_fetch_issue_cover_urls'")
|
||||
|
||||
# Used by coverimagewidget.start_alt_cover_search
|
||||
def fetch_issue_page_url(self, issue_id: int) -> str | None:
|
||||
try:
|
||||
page_url = self.talker.fetch_issue_page_url(issue_id)
|
||||
return page_url
|
||||
except NotImplementedError:
|
||||
logger.warning(f"{self.talker.source_details.name} has not implemented: 'fetch_issue_page_url'")
|
||||
return None
|
||||
|
||||
def async_fetch_alternate_cover_urls(self, issue_id: int, issue_page_url: str) -> None:
|
||||
def async_fetch_alternate_cover_urls(self, issue_id: int) -> None:
|
||||
try:
|
||||
# TODO: Figure out async
|
||||
url_list = self.fetch_alternate_cover_urls(issue_id, issue_page_url)
|
||||
url_list = self.fetch_alternate_cover_urls(issue_id)
|
||||
ComicTalker.alt_url_list_fetch_complete(url_list)
|
||||
logger.info("Should be downloading alt image list: %s", url_list)
|
||||
return
|
||||
|
||||
self.talker.async_fetch_alternate_cover_urls(issue_id, issue_page_url)
|
||||
self.talker.async_fetch_alternate_cover_urls(issue_id)
|
||||
except NotImplementedError:
|
||||
logger.warning(f"{self.talker.source_details.name} has not implemented: 'async_fetch_alternate_cover_urls'")
|
||||
|
@ -203,7 +203,7 @@ class TalkerBase:
|
||||
def fetch_issue_data_by_issue_id(self, issue_id: int) -> GenericMetadata:
|
||||
raise NotImplementedError
|
||||
|
||||
def fetch_alternate_cover_urls(self, issue_id: int, issue_page_url: str) -> list[str]:
|
||||
def fetch_alternate_cover_urls(self, issue_id: int) -> list[str]:
|
||||
raise NotImplementedError
|
||||
|
||||
def fetch_issues_by_volume_issue_num_and_year(
|
||||
@ -218,9 +218,5 @@ class TalkerBase:
|
||||
def async_fetch_issue_cover_urls(self, issue_id: int) -> None:
|
||||
raise NotImplementedError
|
||||
|
||||
# Used by coverimagewidget.start_alt_cover_search
|
||||
def fetch_issue_page_url(self, issue_id: int) -> str | None:
|
||||
raise NotImplementedError
|
||||
|
||||
def async_fetch_alternate_cover_urls(self, issue_id: int, issue_page_url: str) -> None:
|
||||
def async_fetch_alternate_cover_urls(self, issue_id: int) -> None:
|
||||
raise NotImplementedError
|
||||
|
@ -979,11 +979,12 @@ class ComicVineTalker(TalkerBase):
|
||||
cvc = ComicCacher()
|
||||
cvc.add_issue_select_details(self.source_name, issue_id, image_url, thumb_url, cover_date, page_url)
|
||||
|
||||
def fetch_alternate_cover_urls(self, issue_id: int, issue_page_url: str) -> list[str]:
|
||||
def fetch_alternate_cover_urls(self, issue_id: int) -> list[str]:
|
||||
url_list = self.fetch_cached_alternate_cover_urls(issue_id)
|
||||
if url_list:
|
||||
return url_list
|
||||
|
||||
issue_page_url = self.fetch_issue_page_url(issue_id)
|
||||
# scrape the CV issue page URL to get the alternate cover URLs
|
||||
content = requests.get(issue_page_url, headers={"user-agent": "comictagger/" + ctversion.version}).text
|
||||
alt_cover_url_list = self.parse_out_alt_cover_urls(content)
|
||||
@ -1076,9 +1077,9 @@ class ComicVineTalker(TalkerBase):
|
||||
|
||||
ComicTalker.url_fetch_complete(image_url, thumb_url)
|
||||
|
||||
def async_fetch_alternate_cover_urls(self, issue_id: int, issue_page_url: str) -> None:
|
||||
def async_fetch_alternate_cover_urls(self, issue_id: int) -> None:
|
||||
# bypass async for now
|
||||
url_list = self.fetch_alternate_cover_urls(issue_id, issue_page_url)
|
||||
url_list = self.fetch_alternate_cover_urls(issue_id)
|
||||
ComicTalker.alt_url_list_fetch_complete(url_list)
|
||||
return
|
||||
|
||||
@ -1088,6 +1089,8 @@ class ComicVineTalker(TalkerBase):
|
||||
if url_list:
|
||||
ComicTalker.alt_url_list_fetch_complete(url_list)
|
||||
|
||||
issue_page_url = self.fetch_issue_page_url(issue_id)
|
||||
|
||||
self.nam.finished.connect(self.async_fetch_alternate_cover_urls_complete)
|
||||
self.nam.get(QtNetwork.QNetworkRequest(QtCore.QUrl(str(issue_page_url))))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user