mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-09 01:44:15 +02:00
screenshots button
This commit is contained in:
@@ -364,3 +364,9 @@ class AppImageManager(SoftwareManager):
|
||||
|
||||
def cache_to_disk(self, pkg: SoftwarePackage, icon_bytes: bytes, only_icon: bool):
|
||||
self.serialize_to_disk(pkg, icon_bytes, only_icon)
|
||||
|
||||
def get_screenshots(self, pkg: AppImage) -> List[str]:
|
||||
if pkg.has_screenshots():
|
||||
return [pkg.url_screenshot]
|
||||
|
||||
return []
|
||||
|
||||
@@ -10,7 +10,7 @@ CACHED_ATTRS = {'name', 'description', 'version', 'url_download', 'author', 'lic
|
||||
class AppImage(SoftwarePackage):
|
||||
|
||||
def __init__(self, name: str = None, description: str = None, github: str = None, source: str = None, version: str = None,
|
||||
url_download: str = None, url_icon: str = None, license: str = None, author: str = None,
|
||||
url_download: str = None, url_icon: str = None, url_screenshot: str = None, license: str = None, author: str = None,
|
||||
pictures: List[str] = None, icon_path: str = None, installed: bool = False,
|
||||
url_download_latest_version: str = None):
|
||||
super(AppImage, self).__init__(id=name, name=name, version=version, latest_version=version,
|
||||
@@ -21,6 +21,7 @@ class AppImage(SoftwarePackage):
|
||||
self.pictures = pictures
|
||||
self.url_download = url_download
|
||||
self.icon_path = icon_path
|
||||
self.url_screenshot = url_screenshot
|
||||
self.author = author
|
||||
self.url_download_latest_version = url_download_latest_version
|
||||
|
||||
@@ -80,3 +81,6 @@ class AppImage(SoftwarePackage):
|
||||
|
||||
def get_disk_icon_path(self):
|
||||
return self.icon_path
|
||||
|
||||
def has_screenshots(self):
|
||||
return not self.installed and self.url_screenshot
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APP_ATTRS = ('name', 'description', 'github', 'source', 'version', 'url_download', 'url_icon', 'license', 'author')
|
||||
APP_ATTRS = ('name', 'description', 'github', 'source', 'version', 'url_download', 'url_icon', 'url_screenshot', 'license', 'author')
|
||||
RELEASE_ATTRS = ('version', 'url_download', 'published_at')
|
||||
|
||||
|
||||
|
||||
@@ -731,3 +731,6 @@ class ArchManager(SoftwareManager):
|
||||
def launch(self, pkg: ArchPackage):
|
||||
if pkg.command:
|
||||
subprocess.Popen(pkg.command.split(' '))
|
||||
|
||||
def get_screenshots(self, pkg: SoftwarePackage) -> List[str]:
|
||||
pass
|
||||
|
||||
@@ -272,4 +272,14 @@ class FlatpakManager(SoftwareManager):
|
||||
return True
|
||||
|
||||
def launch(self, pkg: SoftwarePackage):
|
||||
flatpak.run(pkg.id)
|
||||
flatpak.run(str(pkg.id))
|
||||
|
||||
def get_screenshots(self, pkg: SoftwarePackage) -> List[str]:
|
||||
res = self.http_client.get_json('{}/apps/{}'.format(FLATHUB_API_URL, pkg.id))
|
||||
urls = []
|
||||
if res and res.get('screenshots'):
|
||||
for s in res['screenshots']:
|
||||
if s.get('imgDesktopUrl'):
|
||||
urls.append(s['imgDesktopUrl'])
|
||||
|
||||
return urls
|
||||
|
||||
@@ -191,3 +191,21 @@ class SnapManager(SoftwareManager):
|
||||
|
||||
def launch(self, pkg: SnapApplication):
|
||||
snap.run(pkg, self.context.logger)
|
||||
|
||||
def get_screenshots(self, pkg: SoftwarePackage) -> List[str]:
|
||||
res = self.http_client.get_json('{}/search?q={}'.format(SNAP_API_URL, pkg.name))
|
||||
|
||||
if res:
|
||||
if res.get('_embedded') and res['_embedded'].get('clickindex:package'):
|
||||
snap_data = res['_embedded']['clickindex:package'][0]
|
||||
|
||||
if snap_data.get('screenshot_urls'):
|
||||
return snap_data['screenshot_urls']
|
||||
else:
|
||||
self.logger.warning("No 'screenshots_urls' defined for {}".format(pkg))
|
||||
else:
|
||||
self.logger.error('It seems the API is returning a different response: {}'.format(res))
|
||||
else:
|
||||
self.logger.warning('Could not retrieve data for {}'.format(pkg))
|
||||
|
||||
return []
|
||||
|
||||
Reference in New Issue
Block a user