-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
108 changed files
with
2,145 additions
and
529 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
# This workflow will install Python dependencies and build the Albayan application using cx-Freeze on Windows. | ||
|
||
name: Albayan_beta | ||
|
||
on: | ||
push: | ||
branches: [ "albayan_beta" ] | ||
pull_request: | ||
branches: [ "albayan_beta" ] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
runs-on: windows-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Python 3.12 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: "3.12" | ||
|
||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install cx-Freeze | ||
if (Test-Path "requirements.txt") { pip install -r requirements.txt } | ||
- name: Build with cx-Freeze | ||
run: | | ||
python setup.py build | ||
- name: Rename main.exe to albayan.exe | ||
run: | | ||
Rename-Item -Path "albayan_build\main.exe" -NewName "albayan.exe" | ||
- name: Download and install Inno Setup | ||
run: | | ||
Invoke-WebRequest -Uri https://jrsoftware.org/download.php/is.exe -OutFile is.exe | ||
Start-Process -Wait -FilePath .\is.exe -ArgumentList '/VERYSILENT', '/SUPPRESSMSGBOXES', '/NORESTART', '/SP' | ||
- name: Download Arabic and Vietnamese language files | ||
run: | | ||
Invoke-WebRequest -Uri https://raw.githubusercontent.com/jrsoftware/issrc/main/Files/Languages/Unofficial/Arabic.isl -OutFile "C:\Program Files (x86)\Inno Setup 6\Languages\Arabic.isl" | ||
Invoke-WebRequest -Uri https://raw.githubusercontent.com/jrsoftware/issrc/main/Files/Languages/Unofficial/Vietnamese.isl -OutFile "C:\Program Files (x86)\Inno Setup 6\Languages\Vietnamese.isl" | ||
- name: Package with Inno Setup | ||
run: | | ||
Start-Process -Wait -FilePath "C:\Program Files (x86)\Inno Setup 6\ISCC.exe" -ArgumentList "albayan.iss" | ||
- name: Upload compressed build output | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: albayan-beta-build | ||
path: albayan_build\AlbayanSetup.exe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Ignore Python bytecode files | ||
__pycache__/ | ||
|
||
# Ignore virtual environment directory | ||
albayan_env/ |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
@echo off | ||
set VENV_DIR=albayan_env | ||
|
||
if not exist %VENV_DIR% ( | ||
echo Creating virtual environment... | ||
py -3.12 -m venv %VENV_DIR% | ||
) | ||
|
||
call %VENV_DIR%\Scripts\activate | ||
|
||
echo Updating pip... | ||
python -m pip install --upgrade pip | ||
|
||
if exist requirements.txt ( | ||
echo Installing/updating libraries from requirements.txt... | ||
pip install -r requirements.txt --upgrade | ||
) else ( | ||
echo requirements.txt not found! | ||
exit /b 1 | ||
) | ||
|
||
pip show cx-freeze >nul 2>&1 | ||
if %errorlevel% neq 0 ( | ||
echo Installing cx-Freeze... | ||
pip install cx-freeze | ||
) | ||
|
||
if exist setup.py ( | ||
echo Building the program with cx-Freeze... | ||
python setup.py build | ||
) else ( | ||
echo setup.py not found! | ||
exit /b 1 | ||
) | ||
|
||
deactivate | ||
echo Done! | ||
pause |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import os | ||
import sqlite3 | ||
from typing import List, Dict, Optional | ||
from functools import lru_cache | ||
from exceptions.database import DBNotFoundError | ||
|
||
|
||
class RecitersManager: | ||
def __init__(self, db_path: str) -> None: | ||
self.db_path = db_path | ||
|
||
def _connect(self) -> sqlite3.Connection: | ||
|
||
if not os.path.isfile(self.db_path): | ||
raise DBNotFoundError(self.db_path) | ||
|
||
conn = sqlite3.connect(self.db_path) | ||
conn.row_factory = sqlite3.Row | ||
|
||
return conn | ||
|
||
def get_reciters(self) -> List[sqlite3.Row]: | ||
"""Fetches all reciters from the database.""" | ||
with self._connect() as conn: | ||
cursor = conn.cursor() | ||
cursor.execute(""" | ||
SELECT *, | ||
CASE | ||
WHEN bitrate < 64 THEN 'Low' | ||
WHEN bitrate BETWEEN 64 AND 128 THEN 'Medium' | ||
ELSE 'High' | ||
END AS quality | ||
FROM reciters | ||
ORDER BY name, bitrate; | ||
""") | ||
|
||
return cursor.fetchall() | ||
|
||
@lru_cache(maxsize=1) | ||
def _get_base_url(self, reciter_id: int) -> Optional[str]: | ||
with self._connect() as conn: | ||
cursor = conn.cursor() | ||
cursor.execute("SELECT url FROM reciters WHERE id = ?", (reciter_id,)) | ||
result = cursor.fetchone() | ||
if result: | ||
return result["url"] | ||
return None | ||
|
||
def get_url(self, reciter_id: int, surah_number: int, aya_number: int) -> Optional[str]: | ||
base_url = self._get_base_url(reciter_id) | ||
if base_url: | ||
return f"{base_url}{surah_number:03}{aya_number:03}.mp3" | ||
return None | ||
|
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.