diff --git a/bauh/gems/web/__init__.py b/bauh/gems/web/__init__.py index 252098bd..27eed23d 100644 --- a/bauh/gems/web/__init__.py +++ b/bauh/gems/web/__init__.py @@ -19,3 +19,4 @@ ELECTRON_SHA256_URL = 'https://github.com/electron/electron/releases/download/v{ URL_ENVIRONMENT_SETTINGS = 'https://raw.githubusercontent.com/vinifmor/bauh-files/master/web/environment.yml' DESKTOP_ENTRY_PATH_PATTERN = DESKTOP_ENTRIES_DIR + '/bauh.web.{name}.desktop' URL_FIX_PATTERN = "https://raw.githubusercontent.com/vinifmor/bauh-files/master/web/fix/{url}.js" +UA_CHROME = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36' diff --git a/bauh/gems/web/controller.py b/bauh/gems/web/controller.py index dab0fc39..90396c52 100644 --- a/bauh/gems/web/controller.py +++ b/bauh/gems/web/controller.py @@ -23,8 +23,7 @@ from bauh.api.abstract.view import MessageType, MultipleSelectComponent, InputOp from bauh.api.constants import DESKTOP_ENTRIES_DIR from bauh.commons.html import bold from bauh.commons.system import ProcessHandler, get_dir_size, get_human_size_str -from bauh.gems.web import INSTALLED_PATH, nativefier, DESKTOP_ENTRY_PATH_PATTERN, URL_FIX_PATTERN, environment, \ - ENV_PATH +from bauh.gems.web import INSTALLED_PATH, nativefier, DESKTOP_ENTRY_PATH_PATTERN, URL_FIX_PATTERN, ENV_PATH, UA_CHROME from bauh.gems.web.environment import EnvironmentUpdater from bauh.gems.web.model import WebApplication @@ -43,7 +42,7 @@ except: RE_PROTOCOL_STRIP = re.compile(r'[a-zA-Z]+://') RE_SEVERAL_SPACES = re.compile(r'\s+') -RE_SYMBOLS_SPLIT = re.compile(r'[\-|_\s]') +RE_SYMBOLS_SPLIT = re.compile(r'[\-|_\s:]') class WebApplicationManager(SoftwareManager): @@ -90,8 +89,12 @@ class WebApplicationManager(SoftwareManager): if icon_url and not icon_url.startswith('http'): icon_url = url + (icon_url if icon_url.startswith('/') else '/{}'.format(icon_url)) - if icon_url: - return icon_url + if not icon_url: + icon_tag = soup.head.find('meta', attrs={"property": 'og:image'}) + icon_url = icon_tag.get('content') if icon_tag else None + + if icon_url: + return icon_url def _get_fix_for(self, url_no_protocol: str) -> str: res = self.http_client.get(URL_FIX_PATTERN.format(url=url_no_protocol)) @@ -120,7 +123,7 @@ class WebApplicationManager(SoftwareManager): if installed_matches: res.installed.extend(installed_matches) else: - url_res = self.http_client.get(url, headers={'Accept-language': self._get_lang_header()}, ignore_ssl=True, single_call=True) + url_res = self.http_client.get(url, headers={'Accept-language': self._get_lang_header(), 'User-Agent': UA_CHROME}, ignore_ssl=True, single_call=True) if url_res: soup = BeautifulSoup(url_res.text, 'lxml', parse_only=SoupStrainer('head')) diff --git a/bauh/gems/web/resources/locale/en b/bauh/gems/web/resources/locale/en index 99a86289..1c5fef8a 100644 --- a/bauh/gems/web/resources/locale/en +++ b/bauh/gems/web/resources/locale/en @@ -32,8 +32,8 @@ web.install.option.allow_urls.tip=It allows the application to internally open a web.install.option.tray.label=Tray mode web.install.option.tray.off.label=Off web.install.option.tray.off.tip=Off -web.install.option.tray.default.label=Default -web.install.option.tray.default.tip=The app icon will be attached to the system tray allowing it to be quickly opened +web.install.option.tray.default.label=Open and attach +web.install.option.tray.default.tip=The app icon will be attached to the system tray after being opened web.install.option.tray.min.label=Start minimized web.install.option.tray.min.tip=The app will be started minimized as an icon in the system tray web.install.option.category.none=none diff --git a/bauh/gems/web/resources/locale/pt b/bauh/gems/web/resources/locale/pt index 67a43c09..876d06e8 100644 --- a/bauh/gems/web/resources/locale/pt +++ b/bauh/gems/web/resources/locale/pt @@ -32,8 +32,8 @@ web.install.option.allow_urls.tip=Permite que o aplicativo abra internamente end web.install.option.tray.label=Modo bandeja web.install.option.tray.off.label=Desligado web.install.option.tray.off.tip=Desligado -web.install.option.tray.default.label=Padrão -web.install.option.tray.default.tip=O ícone do aplicativo será anexado a bandeja do sistema permitindo que o mesma seja rapidamente aberto +web.install.option.tray.default.label=Abrir e anexar +web.install.option.tray.default.tip=O ícone do aplicativo será anexado a bandeja do sistema após aberto web.install.option.tray.min.label=Iniciar minimizado web.install.option.tray.min.tip=O aplicativo será iniciado minimizado como um ícone da bandeja do sistema web.install.option.category.none=nenhuma diff --git a/bauh/gems/web/resources/suggestions.yml b/bauh/gems/web/resources/suggestions.yml index 7ff720eb..e21d3822 100644 --- a/bauh/gems/web/resources/suggestions.yml +++ b/bauh/gems/web/resources/suggestions.yml @@ -1,29 +1,72 @@ youtube: + name: YouTube url: https://youtube.com + category: Network facebook: + name: Facebook url: https://facebook.com + category: Network + options: + - tray_min outlook: + name: Outlook url: https://outlook.live.com + category: Network options: - allow_urls twitch: + name: Twitch url: https://twitch.tv + category: Network whatsapp: + name: WhatsApp url: https://web.whatsapp.com + category: Network options: - tray_min telegram: - url: https://web.whatsapp.com + name: Telegram + url: https://web.telegram.org + category: Network options: - tray_min slack: name: Slack url: https://slack.com + category: Network options: - - tray_min \ No newline at end of file + - tray_min + +hangouts: + name: Hangouts + url: https://hangouts.google.com + category: Network + options: + - tray_min + +office: + name: Microsoft Office + url: https://office.com + category: office + options: + - allow_urls + +reddit: + name: Reddit + url: https://reddit.com + category: network + options: + - tray_min + +google-drive: + name: Drive + url: https://drive.google.com + category: Utility + options: + - tray_min