mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 01:14:15 +02:00
[fix][ui] not able to render redirected icons
This commit is contained in:
@@ -7,7 +7,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||
## [0.8.1]
|
||||
### Improvements
|
||||
- All icons are now SVG files
|
||||
- HDPI support ( by [octopusSD](https://github.com/octopusSD) )
|
||||
- HDPI support improvements ( by [octopusSD](https://github.com/octopusSD) )
|
||||
- Web:
|
||||
- not using HTTP sessions anymore to perform the searches. It seems to avoid URLs not being found after an internet drop event.
|
||||
- supporting JPEG images as custom icons
|
||||
@@ -17,10 +17,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
||||
|
||||
### Fixes
|
||||
- missing categories i18n [48](https://github.com/vinifmor/bauh/issues/48)
|
||||
- not verifying if an icon path is a file
|
||||
- Web:
|
||||
- not handling HTTP connection issues
|
||||
- not passing the Home path as a String ( does not work in Python 3.5 )
|
||||
- UI:
|
||||
- not verifying if an icon path is a file
|
||||
- minor fixes
|
||||
|
||||
### UI
|
||||
- Default **Type** icon removed from the Type filter to make the design more consistent with the Category filter.
|
||||
|
||||
@@ -9,6 +9,7 @@ from pathlib import Path
|
||||
from threading import Thread
|
||||
from typing import List, Type, Set, Tuple
|
||||
|
||||
import requests
|
||||
import yaml
|
||||
from colorama import Fore
|
||||
from requests import exceptions
|
||||
@@ -152,14 +153,14 @@ class WebApplicationManager(SoftwareManager):
|
||||
def serialize_to_disk(self, pkg: SoftwarePackage, icon_bytes: bytes, only_icon: bool):
|
||||
super(WebApplicationManager, self).serialize_to_disk(pkg=pkg, icon_bytes=None, only_icon=False)
|
||||
|
||||
def _map_url(self, url: str) -> "BeautifulSoup":
|
||||
def _map_url(self, url: str) -> Tuple["BeautifulSoup", requests.Response]:
|
||||
headers = {'Accept-language': self._get_lang_header(), 'User-Agent': UA_CHROME}
|
||||
|
||||
try:
|
||||
url_res = self.http_client.get(url, headers=headers, ignore_ssl=True, single_call=True, session=False)
|
||||
|
||||
if url_res:
|
||||
return BeautifulSoup(url_res.text, 'lxml', parse_only=SoupStrainer('head'))
|
||||
return BeautifulSoup(url_res.text, 'lxml', parse_only=SoupStrainer('head')), url_res
|
||||
except exceptions.ConnectionError as e:
|
||||
self.logger.warning("Could not get {}: {}".format(url, e.__class__.__name__))
|
||||
|
||||
@@ -182,14 +183,21 @@ class WebApplicationManager(SoftwareManager):
|
||||
if installed_matches:
|
||||
res.installed.extend(installed_matches)
|
||||
else:
|
||||
soup = self._map_url(url)
|
||||
soup_map = self._map_url(url)
|
||||
|
||||
if soup_map:
|
||||
soup, response = soup_map[0], soup_map[1]
|
||||
|
||||
final_url = response.url
|
||||
|
||||
if final_url.endswith('/'):
|
||||
final_url = final_url[0:-1]
|
||||
|
||||
if soup:
|
||||
name = self._get_app_name(url_no_protocol, soup)
|
||||
desc = self._get_app_description(url, soup)
|
||||
icon_url = self._get_app_icon_url(url, soup)
|
||||
desc = self._get_app_description(final_url, soup)
|
||||
icon_url = self._get_app_icon_url(final_url, soup)
|
||||
|
||||
app = WebApplication(url=url, name=name, description=desc, icon_url=icon_url)
|
||||
app = WebApplication(url=final_url, name=name, description=desc, icon_url=icon_url)
|
||||
|
||||
if self.env_settings.get('electron') and self.env_settings['electron'].get('version'):
|
||||
app.version = self.env_settings['electron']['version']
|
||||
@@ -747,9 +755,16 @@ class WebApplicationManager(SoftwareManager):
|
||||
pass
|
||||
|
||||
def _fill_suggestion(self, app: WebApplication):
|
||||
soup = self._map_url(app.url)
|
||||
soup_map = self._map_url(app.url)
|
||||
|
||||
if soup_map:
|
||||
soup, res = soup_map[0], soup_map[1]
|
||||
|
||||
app.url = res.url
|
||||
|
||||
if app.url.endswith('/'):
|
||||
app.url = app.url[0:-1]
|
||||
|
||||
if soup:
|
||||
if not app.name:
|
||||
app.name = self._get_app_name(app.url, soup)
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ from bauh.commons.html import strip_html
|
||||
from bauh.view.qt import dialog
|
||||
from bauh.view.qt.components import IconButton
|
||||
from bauh.view.qt.view_model import PackageView, PackageViewStatus
|
||||
from bauh.view.qt.view_utils import load_resource_icon
|
||||
from bauh.view.util import resource
|
||||
from bauh.view.util.translation import I18n
|
||||
|
||||
@@ -154,7 +153,9 @@ class AppsTable(QTableWidget):
|
||||
if app_v.status == PackageViewStatus.LOADING and app_v.model.status == PackageStatus.READY:
|
||||
|
||||
if self.download_icons:
|
||||
self.network_man.get(QNetworkRequest(QUrl(app_v.model.icon_url)))
|
||||
icon_request = QNetworkRequest(QUrl(app_v.model.icon_url))
|
||||
icon_request.setAttribute(QNetworkRequest.FollowRedirectsAttribute, True)
|
||||
self.network_man.get(icon_request)
|
||||
|
||||
self._update_row(app_v, change_update_col=False)
|
||||
app_v.status = PackageViewStatus.READY
|
||||
|
||||
@@ -837,7 +837,7 @@ class ManageWindow(QWidget):
|
||||
|
||||
new_width = max(table_width, toolbar_width, topbar_width)
|
||||
|
||||
if accept_lower_width or new_width > self.width():
|
||||
if (self.pkgs and accept_lower_width) or new_width > self.width():
|
||||
self.resize(new_width, self.height())
|
||||
|
||||
if self.first_refresh:
|
||||
|
||||
Reference in New Issue
Block a user