Skip to content

Commit

Permalink
chore: add workflow, fix return types
Browse files Browse the repository at this point in the history
  • Loading branch information
1blckhrt committed Dec 2, 2024
1 parent 4b55cfa commit 8e0314a
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 7 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/pyinstaller.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: PyInstaller Workflow

on:
push:
branches:
- main

jobs:
build:
runs-on: windows-latest

steps:
- name: Check out repository
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.12.6'

- name: Install Poetry
run: |
iex ((New-Object System.Net.WebClient).DownloadString('https://install.python-poetry.org'))
$env:PATH = "$env:USERPROFILE\.poetry\bin;$env:PATH"
- name: Install dependencies using Poetry
run: |
poetry install --no-dev
- name: Install PyInstaller
run: poetry add pyinstaller --dev

- name: Define version and build with PyInstaller
run: |
$version = "1.1"
$outputName = "1blckhrt_video_generator_v$version.exe"
poetry run pyinstaller --onefile --name $outputName src\main.py
Rename-Item "dist\main.exe" $outputName
- name: Upload PyInstaller build artifacts
uses: actions/upload-artifact@v2
with:
name: built-application
path: dist\1blckhrt_video_generator_v1.1.exe

- name: Create GitHub Release
id: create_release
uses: softprops/action-gh-release@v1
with:
tag_name: v1.1
release_name: "Release v1.1"
files: dist\1blckhrt_video_generator_v1.1.exe
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14 changes: 7 additions & 7 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def browse_files(file_type: str) -> str:
return filename


def ensure_16_9_aspect_ratio(image_path: str, output_path: str):
def ensure_16_9_aspect_ratio(image_path: str, output_path: str) -> str:
"""
Ensures the image has a 16:9 aspect ratio by resizing or padding it,
and ensures both dimensions are divisible by 2.
Expand Down Expand Up @@ -59,7 +59,7 @@ def ensure_16_9_aspect_ratio(image_path: str, output_path: str):
return output_path


def ensure_even_dimensions(img):
def ensure_even_dimensions(img) -> Image:
"""
Ensures both width and height are divisible by 2.
:param img: PIL Image object
Expand Down Expand Up @@ -95,7 +95,7 @@ def get_output_path() -> str:
return output_path


def combine_audio_image(audio_path: str, image_path: str, output_path: str):
def combine_audio_image(audio_path: str, image_path: str, output_path: str) -> None:
"""
Combines an image with audio to create a video using ffmpeg.
:param image_path: Path to the image file
Expand Down Expand Up @@ -134,10 +134,10 @@ def combine_audio_image(audio_path: str, image_path: str, output_path: str):
messagebox.showinfo("Success", f"Output saved to: {output_path}")

except subprocess.CalledProcessError as e:
messagebox.showerror("Error", f"An error occurred: {e}")
messagebox.showerror("Error", f"Please check that you have ffmpeg installed. An error occurred: {e}")


def remove_adjusted_image(image_path: str):
def remove_adjusted_image(image_path: str) -> None:
"""
Removes the adjusted image file if it exists.
:param image_path: Path to the adjusted image file
Expand All @@ -149,7 +149,7 @@ def remove_adjusted_image(image_path: str):
messagebox.showerror("Error", f"An error occurred: {e}")


def main():
def main() -> None:
window = tk.Tk()
window.title("(@1blckhrt) Audio and Image Merger")
window.geometry("500x500")
Expand Down Expand Up @@ -208,7 +208,7 @@ def set_image_path():
fg="white",
)

def combine_and_cleanup():
def combine_and_cleanup() -> None:
if not audio_path.get() or not image_path.get():
messagebox.showwarning("Warning", "Please select both an audio and image file.")
return
Expand Down

0 comments on commit 8e0314a

Please sign in to comment.