Skip to content

Commit

Permalink
πŸ“œ fixed cli & added github workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
TrueMyst committed Dec 11, 2024
1 parent a63fffb commit 8c84ca2
Show file tree
Hide file tree
Showing 6 changed files with 231 additions and 153 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/publish-to-pypi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@

name: Upload Python Package To PyPi

on:
push:
branches:
- main

tags:
- 'v[0-9]+.[0-9]+.[0-9]'

jobs:
pypi-publish:
name: Upload release to PyPI
runs-on: ubuntu-latest

permissions:
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing

steps:
- uses: actions/checkout@v4

- name: Setup Python
uses: actions/[email protected]
with:
python-version: '3.x'

- name: Install Poetry Action
uses: snok/[email protected]
with:
virtualenvs-create: false

- name: Run Black
run: |
poetry add --dev black
poetry run black . --check
# Continue even if Black finds unformatted code
continue-on-error: true

- name: Poetry build
run: |
poetry build
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
6 changes: 3 additions & 3 deletions BeatPrints/poster.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def __init__(self, save_to: str):
Args:
save_to (str): Path where posters will be saved.
"""
self.save_to = save_to
self.save_to = os.path.realpath(os.path.expanduser(save_to))

def _add_common_text(
self,
Expand Down Expand Up @@ -140,7 +140,7 @@ def track(
poster.save(os.path.join(self.save_to, name))

print(
f"✨ Poster for {metadata.name} by {metadata.artist} saved to {os.path.realpath(self.save_to)}"
f"✨ Poster for {metadata.name} by {metadata.artist} saved to {self.save_to}"
)

def album(
Expand Down Expand Up @@ -209,5 +209,5 @@ def album(
name = utils.filename(metadata.name, metadata.artist)
poster.save(os.path.join(self.save_to, name))
print(
f"✨ Album poster for {metadata.name} by {metadata.artist} saved to {os.path.realpath(self.save_to)}"
f"✨ Album poster for {metadata.name} by {metadata.artist} saved to {self.save_to}"
)
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,49 @@ ps.track(metadata, highlighted_lyrics)
> pip install Pillow --global-option="build_ext" --config-settings="-I=/opt/homebrew/Cellar"
> ```
## πŸ₯ž CLI Setup
To get started with the BeatPrints CLI, you'll need to set up a configuration file.
### Windows
1. Create a folder named `BeatPrints` in the following directory:
```
C:\Users\<YourUsername>\AppData\Roaming\BeatPrints\
```
2. Inside this folder, create a file called `config.toml` with the following contents:
```toml
[general]
search_limit = 7
output_directory = "<path-to-save-your-posters>"
[credentials]
client_id = "your-client-id"
client_secret = "your-client-secret"
```

Replace `<path-to-save-your-posters>` with the path where you'd like to save the generated posters, and fill in the `client_id` and `client_secret` with your Spotify credentials.

### Linux or macOS

1. Create a folder named `BeatPrints` in your `~/.config/` directory:
```
~/.config/BeatPrints/
```

2. Inside this folder, create a file called `config.toml` with the same contents as mentioned above.

### Running the CLI

Once the config file is set up, you can run the BeatPrints CLI:

1. Open your terminal.
2. Type `beatprints` and press Enter.

Your poster will be saved in the output directory you specified in the `config.toml` file.

## πŸ–ΌοΈ Examples

Here are a few posters created with BeatPrints:
Expand Down
19 changes: 3 additions & 16 deletions cli/exutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from rich import box
from rich.table import Table
from questionary import Style
from typing import Union, List
from typing import List, Union

from BeatPrints.spotify import AlbumMetadata, TrackMetadata
from BeatPrints.spotify import TrackMetadata, AlbumMetadata

default = Style(
[
Expand Down Expand Up @@ -39,13 +39,7 @@ def clear() -> None:

def tablize_track(tracks: List[TrackMetadata]):
"""
Creates a pretty table for displaying track search results.
Args:
tracks (List[TrackMetadata]): List of track from Spotify API
Returns:
Table: Formatted rich table of tracks
Creates a pretty table for displaying track search results.
"""
table = Table(box=box.ROUNDED)

Expand All @@ -64,14 +58,7 @@ def tablize_track(tracks: List[TrackMetadata]):
def tablize_albums(albums: List[AlbumMetadata]) -> Table:
"""
Creates a pretty table for displaying album search results.
Args:
albums (List[AlbumMetadata]): List of album data from Spotify API
Returns:
Table: Formatted rich table of albums
"""

table = Table(box=box.ROUNDED)

table.add_column("*", justify="center", style="cyan")
Expand Down
Loading

0 comments on commit 8c84ca2

Please sign in to comment.