Skip to content

Commit 9a216b4

Browse files
committed
v1.2.0
- new system used to generates emoji icons using pillow - fix some typo
1 parent 9b6937a commit 9a216b4

File tree

228 files changed

+32207
-16986
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

228 files changed

+32207
-16986
lines changed

README.md

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,22 @@
33

44
[![made with heart by Benjamin Oddou](https://img.shields.io/badge/made%20with%20%E2%99%A5%20by-benjamin%20oddou-ff2f35.svg?style=flat)](https://github.com/BenjaminOddou)
55
[![saythanks](https://img.shields.io/badge/say-thanks-bf0001.svg?style=flat)](https://saythanks.io/to/BenjaminOddou)
6-
[![Python 3.7+](https://img.shields.io/badge/python-3.7+-7f0000.svg)](https://www.python.org/downloads/macos/)
6+
[![Python 3.8+](https://img.shields.io/badge/python-3.8+-7f0000.svg)](https://www.python.org/downloads/macos/)
77

88
Welcome to the Alfred Emoji Wine repository: **An Alfred Workflow**
99

1010
## ✅ Prerequisites
1111

1212
* MacOS.
1313
* Alfred 5. Note that the [Alfred Powerpack](https://www.alfredapp.com/powerpack/) is required to use workflows.
14-
* Requires **python 3.7** or above.
14+
* Requires **python 3.8** or above.
1515

1616
## 🏎️ Data sources
1717

18-
This workflow combines multiple sources (see below) to build a local JSON API (`~/Library/Caches/com.runningwithcrayons.Alfred/Workflow Data/com.benjamino.emoji_wine`) along with an icons folder with base64 png images (≊1-4Ko per image).
18+
This workflow combines multiple sources (see below) to build a local JSON API (`~/Library/Caches/com.runningwithcrayons.Alfred/Workflow Data/com.benjamino.emoji_wine`) along with an icons folder with png images.
1919

2020
List of sources :
2121
* [Full list of latest emojis](https://unicode.org/Public/emoji/latest/emoji-test.txt) - Used to grab the full list of emojis.
22-
* [Classic emojis images](https://unicode.org/emoji/charts/full-emoji-list.html) - Used to grab list of classic emojis images.
23-
* [Skin Tone emojis images](https://unicode.org/emoji/charts/full-emoji-modifiers.html) - Used to grab list of skin toned emojis images.
2422
* [CLDR Data files annotations](https://github.com/unicode-org/cldr/tree/main/common/annotations) - Used to translate emojis titles and tags.
2523
* [CLDR Data files annotations derived](https://github.com/unicode-org/cldr/tree/main/common/annotationsDerived) - Used to translate emojis titles and tags.
2624

@@ -31,7 +29,7 @@ List of sources :
3129

3230
## 🧰 Setup the workflow
3331

34-
Install Python 3.7 or above. Check your version with :
32+
Install Python 3.8 or above. Check your version with :
3533

3634
```shell
3735
python --version

helper/fuse.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import os
2+
import sys
3+
sys.path.insert(0, './temp')
4+
from delocate.fuse import fuse_wheels
5+
6+
directory_path = os.path.join(os.getcwd(), 'temp')
7+
files = os.listdir(directory_path)
8+
wheel_files = [f for f in files if f.endswith('.whl')]
9+
base_name = wheel_files[0].split("-macosx")[0]
10+
final_binary = os.path.join(directory_path, f'{base_name}-macosx_11_0_universal2.whl')
11+
full_paths = [os.path.join(directory_path, file) for file in wheel_files]
12+
fuse_wheels(*full_paths, final_binary)
13+
print(final_binary)

helper/update.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
# Install platform agnostic version of Pillow (put this script inside the workflow folder along with fuse.py)
4+
mkdir -p temp
5+
pip3 install delocate -t temp # install delocate library in temp folder to fuse binaries
6+
pip3 download --only-binary=:all: --platform macosx_10_10_x86_64 Pillow -d temp # binary whl for intel chips
7+
pip3 download --only-binary=:all: --platform macosx_11_0_arm64 Pillow -d temp # binary whl for arm64 chips
8+
final_binary=$(python3 fuse.py) # fuse binaries into universal binary
9+
mkdir -p lib
10+
pip3 install "$final_binary" -t lib # install pillow using universal binary
11+
rm -r temp

public/search.webp

-5.21 KB
Loading

public/search_tag.webp

-418 Bytes
Loading

src/api.py

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,34 @@
11
import os
22
import re
33
import sys
4-
sys.path.insert(0, './lib')
5-
import base64
64
import json
7-
import time
85
import datetime
9-
from bs4 import BeautifulSoup
10-
from io import BytesIO
116
from urllib import request
7+
sys.path.insert(0, './lib')
128
import xml.etree.ElementTree as ET
13-
from utils import api_file_path, cache_folder_path, data_folder_path, icons_folder_path, display_notification, language
9+
from PIL import Image, ImageDraw, ImageFont
10+
from utils import api_file_path, data_folder_path, icons_folder_path, display_notification, language
1411

1512
display_notification('⏳ Please wait !', 'Emojis data is beeing gathered, this can take some time...')
16-
time.sleep(0.2)
1713

18-
for folder in [data_folder_path, cache_folder_path, icons_folder_path]:
14+
for folder in [data_folder_path, icons_folder_path]:
1915
if not os.path.exists(folder):
2016
os.mkdir(folder)
2117

2218
check_e_type = ['flag:', 'keycap:']
2319

24-
try:
25-
img_urls = ['https://unicode.org/emoji/charts/full-emoji-list.html', 'https://unicode.org/emoji/charts/full-emoji-modifiers.html']
26-
for url in img_urls:
27-
img_response = request.urlopen(url).read().decode('utf-8')
28-
soup = BeautifulSoup(img_response, 'html.parser')
29-
rows = soup.find_all('tr')
30-
for row in rows[1:]:
31-
cols = row.find_all('td')
32-
if cols:
33-
img_tag = cols[3].find('img')
34-
if img_tag:
35-
img_src = img_tag.get('src').split(',')[1]
36-
img_data = BytesIO(base64.b64decode(img_src))
37-
file_name = f'{cols[-1].text.replace("⊛", "").replace(":", "").strip()}.png'
38-
file_path = os.path.join(icons_folder_path, file_name)
39-
with open(file_path, 'wb') as file:
40-
file.write(img_data.getvalue())
20+
def convert_emoji_to_png(emoji, name):
21+
image_size = (128, 128)
22+
image = Image.new("RGBA", image_size, (0, 0, 0, 0)) # Set transparent background
23+
font_size = 64 # Adjusted font size
24+
font_path = "/System/Library/Fonts/Apple Color Emoji.ttc"
25+
font = ImageFont.truetype(font_path, font_size, encoding='unic')
26+
draw_position = (int((image_size[0] - font_size) / 2), int((image_size[1] - font_size) / 2))
27+
draw = ImageDraw.Draw(image)
28+
draw.text(draw_position, emoji, font=font, embedded_color=True)
29+
image.save(f"{icons_folder_path}/{name.replace(':', '')}.png", "PNG")
4130

31+
try:
4232
api_url = 'https://unicode.org/Public/emoji/latest/emoji-test.txt'
4333
api_response = request.urlopen(api_url).read().decode('utf-8')
4434
lines = [line.strip() for line in api_response.split('\n') if ('; fully-qualified' in line) or ('; component' in line)]
@@ -75,6 +65,7 @@
7565
'title': title,
7666
'tags': tags
7767
})
68+
convert_emoji_to_png(emoji, name)
7869

7970
with open('json/lang.json') as file:
8071
langs = json.load(file)

src/harvest.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
action, level, subaction, kID = lib[1], int(lib[2]), lib[3], lib[4]
1515

1616
if tags_data is None:
17-
os.mkdir(data_folder_path)
17+
try:
18+
os.mkdir(data_folder_path)
19+
except:
20+
pass
1821
with open(tags_file_path, 'w') as file:
1922
json.dump([], file)
2023

@@ -93,7 +96,7 @@
9396
list_emojis = ', '.join(obj['emojis'])
9497
list_emojis = '❌ No Emojis' if list_emojis == '' else f'Emojis: {list_emojis}'
9598
items.append({
96-
'title': obj['title'] if obj['title'] is not '' else 'No Title',
99+
'title': obj['title'] if obj['title'] != '' else 'No Title',
97100
'subtitle': list_emojis,
98101
'arg': f'_rerun;modify;2;;{obj["id"]}',
99102
'icon': {
@@ -106,7 +109,7 @@
106109
list_emojis = ', '.join(obj.get('emojis'))
107110
list_emojis = '❌ No Emojis' if list_emojis == '' else f'Emojis: {list_emojis}'
108111
items.append({
109-
'title': obj['title'] if obj['title'] is not '' else 'No Title',
112+
'title': obj['title'] if obj['title'] != '' else 'No Title',
110113
'subtitle': list_emojis,
111114
'arg': f'_tags;delete;;{obj["id"]};{"ǀ".join(lib)}',
112115
'icon': {

src/icons/emojipedia.webp

-4.33 KB
Loading

src/info.plist

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -802,11 +802,11 @@
802802
803803
* MacOS.
804804
* Alfred 5. Note that the [Alfred Powerpack](https://www.alfredapp.com/powerpack/) is required to use workflows.
805-
* Requires **python 3.7** or above.
805+
* Requires **python 3.8** or above.
806806
807807
## 🧰 Setup the workflow
808808
809-
Install Python 3.7 or above. Check your version with :
809+
Install Python 3.8 or above. Check your version with :
810810
811811
`python --version`
812812
@@ -1187,7 +1187,7 @@ note: not all emojis are available in all languages.</string>
11871187
</dict>
11881188
</array>
11891189
<key>version</key>
1190-
<string>1.1.2</string>
1190+
<string>1.2.0</string>
11911191
<key>webaddress</key>
11921192
<string>https://github.com/BenjaminOddou/alfred-emoji-wine</string>
11931193
</dict>
149 KB
Binary file not shown.

0 commit comments

Comments
 (0)