mirror of
https://github.com/saphid/frame-control.git
synced 2026-10-06 08:00:32 +02:00
Merge branch 'art-sources' into apk-store-fixes
This commit is contained in:
commit
2f9ddeea76
5 files changed
+18
-9
No files matched your search
@@ -37,7 +37,7 @@ class PublisherSources(unittest.TestCase):
|
||||
self.assertTrue(entry['summary'])
|
||||
images = entry['images']
|
||||
self.assertEqual(entry['icon'], images['icon'])
|
||||
for url in [images['icon'], images['banner']] + images['screenshots']:
|
||||
for url in [u for u in [images['icon'], images['banner']] if u] + images['screenshots']:
|
||||
self.assertTrue(url.startswith('https://'))
|
||||
self.assertEqual(evidence[url]['status'], 200)
|
||||
self.assertTrue(evidence[url]['image'])
|
||||
@@ -53,8 +53,7 @@ class PublisherSources(unittest.TestCase):
|
||||
self.assertEqual(entry['images'], curated['images'])
|
||||
unknown = github.details(github.sources()[0], 'unknown/project')
|
||||
self.assertEqual(unknown['icon'], 'https://github.com/unknown.png')
|
||||
self.assertEqual(unknown['images']['banner'],
|
||||
'https://opengraph.githubassets.com/1/unknown/project')
|
||||
self.assertIsNone(unknown['images']['banner'])
|
||||
|
||||
def test_real_releases(self):
|
||||
for key, repo in [('khronos', 'KhronosGroup/OpenXR-SDK-Source'),
|
||||
@@ -79,8 +78,7 @@ class PublisherSources(unittest.TestCase):
|
||||
for entry, repo in zip(entries, data['items']):
|
||||
self.assertEqual(entry['icon'], repo['owner']['avatar_url'])
|
||||
self.assertEqual(entry['images']['icon'], entry['icon'])
|
||||
self.assertEqual(entry['images']['banner'],
|
||||
'https://opengraph.githubassets.com/1/' + repo['full_name'])
|
||||
self.assertIsNone(entry['images']['banner'])
|
||||
self.assertEqual(entry['images']['screenshots'], [])
|
||||
self.assertFalse(github.details(github.sources()[0], 'unknown/project')['downloadable'])
|
||||
with self.assertRaises(SourceError):
|
||||
|
||||
@@ -244,6 +244,10 @@ class ArtworkTests(unittest.TestCase):
|
||||
data = (FIXTURES / 'icon.jpg').read_bytes()
|
||||
self.assertEqual(art.image_type(data), 'jpg')
|
||||
self.assertEqual(art.image_type(data + b'\0' * 64), 'jpg') # trailing padding after EOI
|
||||
gif = b'GIF89a' + struct.pack('<HH', 640, 360) + b'\0' * 20 # gameplay GIFs: first frame drawn
|
||||
self.assertEqual(art.image_type(gif), 'gif')
|
||||
with self.assertRaises(ValueError):
|
||||
art.image_type(b'GIF89a' + struct.pack('<HH', 0, 360) + b'\0' * 20)
|
||||
with self.assertRaises(ValueError):
|
||||
art.image_type(data[:30])
|
||||
|
||||
|
||||
@@ -35,7 +35,8 @@ def _entry(source, c, approved=True):
|
||||
artwork = c.get('images') or {}
|
||||
icon = artwork.get('icon') or c.get('icon') or 'https://github.com/' + c['repo'].split('/')[0] + '.png'
|
||||
images = {'icon': icon,
|
||||
'banner': artwork.get('banner') or 'https://opengraph.githubassets.com/1/' + c['repo'],
|
||||
# No GitHub social-preview card: it's repo text and stats, not art; the UI draws a fallback.
|
||||
'banner': artwork.get('banner'),
|
||||
'screenshots': list(artwork.get('screenshots') or [])}
|
||||
return {'source': source['id'], 'id': c['repo'], 'package': None,
|
||||
'name': c['name'], 'summary': c.get('summary') or '', 'icon': icon,
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
"allow_prerelease": false,
|
||||
"images": {
|
||||
"icon": "https://raw.githubusercontent.com/KhronosGroup/OpenXR-SDK-Source/3ed64d0f9bb680f24b80a085091e5c8fab38f7b7/src/tests/hello_xr/android_resources/vulkan/mipmap-xxxhdpi/ic_helloxr_launcher.png",
|
||||
"banner": "https://opengraph.githubassets.com/1/KhronosGroup/OpenXR-SDK-Source",
|
||||
"banner": null,
|
||||
"screenshots": []
|
||||
},
|
||||
"icon": "https://raw.githubusercontent.com/KhronosGroup/OpenXR-SDK-Source/3ed64d0f9bb680f24b80a085091e5c8fab38f7b7/src/tests/hello_xr/android_resources/vulkan/mipmap-xxxhdpi/ic_helloxr_launcher.png"
|
||||
@@ -60,7 +60,7 @@
|
||||
"allow_prerelease": false,
|
||||
"images": {
|
||||
"icon": "https://raw.githubusercontent.com/arpruss/OpenSaberPlus/8c5295cdaadf02ea7418b0c6cbea20240ba913af/icon.png",
|
||||
"banner": "https://opengraph.githubassets.com/1/arpruss/OpenSaberPlus",
|
||||
"banner": "https://raw.githubusercontent.com/arpruss/OpenSaberPlus/8c5295cdaadf02ea7418b0c6cbea20240ba913af/doc/images/OS0.4.0_1.gif",
|
||||
"screenshots": [
|
||||
"https://raw.githubusercontent.com/arpruss/OpenSaberPlus/8c5295cdaadf02ea7418b0c6cbea20240ba913af/doc/images/OS0.4.0_1.gif",
|
||||
"https://raw.githubusercontent.com/arpruss/OpenSaberPlus/8c5295cdaadf02ea7418b0c6cbea20240ba913af/doc/images/OS0.4.0_2.gif",
|
||||
|
||||
+7
-1
@@ -34,6 +34,12 @@ def image_type(data):
|
||||
if data.startswith(PNG):
|
||||
png_size(data)
|
||||
return 'png'
|
||||
if data[:6] in (b'GIF87a', b'GIF89a') and len(data) >= 10:
|
||||
# Gameplay GIFs are common source screenshots; the Frame's Chromium draws their first frame.
|
||||
w, h = struct.unpack_from('<HH', data, 6)
|
||||
if w and h and w * h <= MAX_PIXELS and max(w, h) <= 8192:
|
||||
return 'gif'
|
||||
raise ValueError('artwork GIF has unsupported dimensions')
|
||||
if data.startswith(b'\xff\xd8'):
|
||||
# Check JPEG SOF dimensions without depending on an image library; trailing padding is fine.
|
||||
pos = 2
|
||||
@@ -52,7 +58,7 @@ def image_type(data):
|
||||
return 'jpg'
|
||||
break
|
||||
pos += size
|
||||
raise ValueError('artwork must be a supported PNG or JPEG')
|
||||
raise ValueError('artwork must be a supported PNG, JPEG or GIF')
|
||||
|
||||
|
||||
def fetch(value, deadline=None):
|
||||
|
||||
Reference in new issue
Block a user