Skip to content

Commit

Permalink
הוספת ספריית jib_to_heb
Browse files Browse the repository at this point in the history
לצורך תיקון שגיאה בבניית ה-APK
  • Loading branch information
NHLOCAL committed Dec 22, 2024
1 parent 558a38c commit 0ebcb24
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 2 deletions.
1 change: 1 addition & 0 deletions .github/workflows/apk-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ on:
# Allows you to run this workflow manually from the Actions tab of the repository
workflow_dispatch:


env:
# https://flet.dev/docs/publish#versioning
BUILD_NUMBER: 1
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ authors = [{ name = "NHLOCAL", email = "[email protected]" }]
dependencies = [
"flet",
"music_tag",
"jibrish_to_hebrew",
"requests",
"chardet"
]
Expand Down
1 change: 0 additions & 1 deletion requirements-apk.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
flet
music_tag
jibrish_to_hebrew
requests
chardet
70 changes: 70 additions & 0 deletions src/core/jibrish_to_hebrew.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
def fix_jibrish(string, mode="heb"):
"""
A function that converts a garbled string to Hebrew
You can insert a string in Hebrew to convert it to gibberish and vice versa
Parameters:
Parameter 1 = A text string
Parameter 2 (optional) = setting the conversion mode to Hebrew or gibberish - accepts "heb" or "jib"
"""

heb_to_jib = {'א': 'à', 'ב': 'á', 'ג': 'â', 'ד': 'ã', 'ה': 'ä', 'ו': 'å', 'ז': 'æ', 'ח': 'ç', 'ט': 'è', 'י': 'é', 'כ': 'ë', 'ל': 'ì', 'מ': 'î','נ': 'ð', 'ס': 'ñ', 'ע': 'ò', 'פ': 'ô', 'צ': 'ö', 'ק': '÷', 'ר': 'ø', 'ש': 'ù', 'ת': 'ú', 'ך': 'ê', 'ם': 'í', 'ן': 'ï', 'ף': 'ó', 'ץ': 'õ'}
jib_to_heb = {'à': 'א', 'á': 'ב', 'â': 'ג', 'ã': 'ד', 'ä': 'ה', 'å': 'ו', 'æ': 'ז', 'ç': 'ח', 'è': 'ט', 'é': 'י', 'ë': 'כ', 'ì': 'ל', 'î': 'מ', 'ð': 'נ', 'ñ': 'ס', 'ò': 'ע', 'ô': 'פ', 'ö': 'צ', '÷': 'ק', 'ø': 'ר', 'ù': 'ש', 'ú': 'ת', 'ê': 'ך', 'í': 'ם', 'ï': 'ן', 'ó': 'ף', 'õ': 'ץ'}

new_string = ""

for letter in string:
if mode == "heb":
if letter in jib_to_heb:
new_letter = jib_to_heb[letter]
new_string += new_letter
else:
new_string += letter
elif mode == "jib":
if letter in heb_to_jib:
new_letter = heb_to_jib[letter]
new_string += new_letter
else:
new_string += letter
else:
if letter in "אבגדהוזחטיכלמנסעפצקרשתךםןףץ":
mode = "jib"
if letter in heb_to_jib:
new_letter = heb_to_jib[letter]
new_string += new_letter
else:
new_string += letter
elif letter in "àáâãäåæçèéëìîðñòôö÷øùúêíïóõ":
mode = "heb"
if letter in jib_to_heb:
new_letter = jib_to_heb[letter]
new_string += new_letter
else:
new_string += letter
else:
new_string += letter

return new_string



def check_jibrish(string):
"""
A function to check if a certain string contains correct Hebrew or corrupted Hebrew
Suitable for checking metadata of songs
Parameters:
Parameter 1 = A text string
"""

if any(c in "àáâãäåæçèéëìîðñòôö÷øùúêíïóõ" for c in string):
return True
else:
return False


if __name__ == '__main__':
string = "àìáåí ìà éãåò & - 3"
print(fix_jibrish(string))

0 comments on commit 0ebcb24

Please sign in to comment.