Skip to content

Commit

Permalink
Take Ruff's Recommendations Really Rigorously (#196)
Browse files Browse the repository at this point in the history
Bumps [docker/login-action](https://github.com/docker/login-action) from 3.2.0 to 3.3.0.
- [Release notes](https://github.com/docker/login-action/releases)
- [Commits](docker/login-action@0d4c9c5...9780b0c)

---
updated-dependencies:
- dependency-name: docker/login-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Dependabot monitoring PyPi dependencies(deps): Bump m3u8 (#190)

Bumps [m3u8](https://github.com/globocom/m3u8) from 5.1.0 to 5.2.0.
- [Release notes](https://github.com/globocom/m3u8/releases)
- [Commits](globocom/m3u8@5.1.0...5.2.0)

---
updated-dependencies:
- dependency-name: m3u8
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Dependabot monitoring PyPi dependencies(deps): Bump m3u8 (#192)

Bumps [m3u8](https://github.com/globocom/m3u8) from 5.2.0 to 5.3.0.
- [Release notes](https://github.com/globocom/m3u8/releases)
- [Commits](globocom/m3u8@5.2.0...5.3.0)

---
updated-dependencies:
- dependency-name: m3u8
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Dependabot monitoring PyPi dependencies(deps): Bump m3u8 (#193)

Bumps [m3u8](https://github.com/globocom/m3u8) from 5.3.0 to 6.0.0.
- [Release notes](https://github.com/globocom/m3u8/releases)
- [Commits](globocom/m3u8@5.3.0...6.0.0)

---
updated-dependencies:
- dependency-name: m3u8
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Edit multiple files to satisfy Ruff linter.

* Pass keyword argument in album.py

* Format artist.py according to Ruff

* Edit dash.py to appease Ruff linter

* Rename TidalManifestException to TidalManifestError, per Ruff

* Reformat to appease Ruff

* Dependabot monitoring PyPi dependencies(deps): Bump typer (#194)

Bumps [typer](https://github.com/fastapi/typer) from 0.12.3 to 0.12.4.
- [Release notes](https://github.com/fastapi/typer/releases)
- [Changelog](https://github.com/fastapi/typer/blob/master/docs/release-notes.md)
- [Commits](fastapi/typer@0.12.3...0.12.4)

---
updated-dependencies:
- dependency-name: typer
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Dependabot monitoring PyPi dependencies(deps): Bump typer (#195)

Bumps [typer](https://github.com/fastapi/typer) from 0.12.4 to 0.12.5.
- [Release notes](https://github.com/fastapi/typer/releases)
- [Changelog](https://github.com/fastapi/typer/blob/master/docs/release-notes.md)
- [Commits](fastapi/typer@0.12.4...0.12.5)

---
updated-dependencies:
- dependency-name: typer
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Make a raft of Ruff-demanded formatting changes.

* Format pyinstaller.py based on Ruff linting.

* Add docstring to setup.py

* Remove crucial packages from TYPE_CHECKING block.

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
ebb-earl-co and dependabot[bot] authored Sep 1, 2024
1 parent fdc58e2 commit bb51d63
Show file tree
Hide file tree
Showing 18 changed files with 1,659 additions and 715 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
uses: docker/setup-buildx-action@v3

- name: Log in to the Container registry
uses: docker/login-action@0d4c9c5ea7693da7b068278f7b52bda2a190a446
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
Expand Down
91 changes: 56 additions & 35 deletions pyinstaller.py
Original file line number Diff line number Diff line change
@@ -1,119 +1,138 @@
from contextlib import closing
"""A version of main.py with current Python syntax just for use with pyinstaller."""

from __future__ import annotations

import logging
from contextlib import closing
from pathlib import Path
from typing import Optional, Union

import typer
from cachecontrol import CacheControl
from platformdirs import user_music_path
from typing_extensions import Annotated

from tidal_wave.album import Album
from tidal_wave.artist import Artist
from tidal_wave.login import login, AudioFormat, LogLevel
from tidal_wave.login import AudioFormat, LogLevel, login
from tidal_wave.mix import Mix
from tidal_wave.models import (
match_tidal_url,
TidalAlbum,
TidalArtist,
TidalMix,
TidalPlaylist,
TidalTrack,
TidalVideo,
match_tidal_url,
)
from tidal_wave.playlist import Playlist
from tidal_wave.track import Track
from tidal_wave.video import Video
from tidal_wave.utils import is_tidal_api_reachable

from cachecontrol import CacheControl
from platformdirs import user_music_path
import typer
from typing_extensions import Annotated
from tidal_wave.video import Video

__version__ = "2024.7.1"


# https://typer.tiangolo.com/tutorial/options/version/#fix-with-is_eager
def version_callback(value: bool) -> None:
def version_callback(value: bool) -> None: # noqa: FBT001
"""Pass this function to typer to specify eager option behavior."""
if value:
print(f"tidal-wave {__version__}")
raise typer.Exit()
print(f"tidal-wave {__version__}") # noqa: T201
raise typer.Exit(code=0)


app = typer.Typer()
_user_music_path: Path = user_music_path()


@app.command()
def main(
tidal_url: Annotated[
str,
typer.Argument(
help="The Tidal album or artist or mix or playlist or track or video to download"
help="The URL to the TIDAL resource that is desired to retrieve.",
),
],
audio_format: Annotated[
AudioFormat, typer.Option(case_sensitive=False)
AudioFormat,
typer.Option(case_sensitive=False),
] = AudioFormat.lossless.value,
output_directory: Annotated[
Path,
typer.Argument(
help="The parent directory under which directory(ies) of files will be written"
help="The directory under which directory(ies) of files will be written",
),
] = user_music_path(),
] = _user_music_path,
loglevel: Annotated[
LogLevel, typer.Option(case_sensitive=False)
LogLevel,
typer.Option(case_sensitive=False),
] = LogLevel.info.value,
include_eps_singles: Annotated[
include_eps_singles: Annotated[ # noqa: FBT002
bool,
typer.Option(
"--include-eps-singles",
help="No-op unless passing TIDAL artist. Whether to include artist's EPs and singles with albums",
help=(
"No-op unless passing TIDAL artist. Whether to include artist's EPs and"
" singles with albums"
),
),
] = False,
no_extra_files: Annotated[
no_extra_files: Annotated[ # noqa: FBT002
bool,
typer.Option(
"--no-extra-files",
help="Whether to not even attempt to retrieve artist bio, artist image, album credits, album review, or playlist m3u8",
help=(
"Whether to not even attempt to retrieve artist bio, artist image, "
"album credits, album review, or playlist m3u8"
),
),
] = False,
no_flatten: Annotated[
no_flatten: Annotated[ # noqa: FBT002
bool,
typer.Option(
"--no-flatten",
help="Whether to treat playlists or mixes as a list of tracks/videos and, as such, retrieve them independently",
help=(
"Whether to treat playlists or mixes as a list of tracks/videos and, "
"as such, retrieve them independently"
),
),
] = False,
transparent: Annotated[
transparent: Annotated[ # noqa: FBT002
bool,
typer.Option(
"--transparent",
help="Whether to dump JSON responses from TIDAL API; maximum verbosity",
),
] = False,
version: Annotated[
Optional[bool],
version: Annotated[ # noqa: ARG001
bool | None,
typer.Option("--version", callback=version_callback, is_eager=True),
] = None,
):
"""Parse command line arguments and retrieve data from TIDAL."""
logging.basicConfig(
format="%(asctime)s,%(msecs)03d %(levelname)-8s [%(filename)s:%(lineno)d] %(message)s",
datefmt="%Y-%m-%d:%H:%M:%S",
level=logging.getLevelName(loglevel.value),
)
logger = logging.getLogger(__name__)

tidal_resource: Optional[
Union[TidalAlbum, TidalMix, TidalPlaylist, TidalTrack, TidalVideo]
] = match_tidal_url(tidal_url)
tidal_resource: (
TidalAlbum | TidalMix | TidalPlaylist | TidalTrack | TidalVideo | None
) = match_tidal_url(tidal_url)

if tidal_resource is None:
logger.critical(
f"Cannot parse '{tidal_url}' as a TIDAL album, artist, mix, playlist, track, or video URL"
_msg: str = (
f"Cannot parse '{tidal_url}' as a TIDAL album, artist, mix, playlist, "
"track, or video URL"
)
logger.critical(_msg)
raise typer.Exit(code=1)

# Check Internet connectivity, and whether api.tidal.com is up
if not is_tidal_api_reachable():
user_wishes_to_continue: bool = typer.confirm(
"\nEven though tidal-wave cannot seem to connect to the Internet, "
"would you like program execution to continue?"
"would you like program execution to continue?",
)
if not user_wishes_to_continue:
raise typer.Exit(code=1)
Expand Down Expand Up @@ -150,7 +169,8 @@ def main(
raise typer.Exit(code=0)
case TidalArtist():
artist = Artist(
artist_id=tidal_resource.tidal_id, transparent=transparent
artist_id=tidal_resource.tidal_id,
transparent=transparent,
)
artist.get(
session=session,
Expand All @@ -169,7 +189,8 @@ def main(
raise typer.Exit(code=0)
case TidalPlaylist():
playlist = Playlist(
playlist_id=tidal_resource.tidal_id, transparent=transparent
playlist_id=tidal_resource.tidal_id,
transparent=transparent,
)
if no_flatten:
playlist.get_elements(
Expand Down
34 changes: 21 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,14 @@ requires = ["setuptools", "wheel"]
universal = 0 # Make the generated wheels have "py3" tag
[project]
name = "tidal-wave"
version = "2024.7.1"
dynamic = ["version"]
description = "A tool to wave at the TIDAL music service."
authors = [
{name = "colinho", email = "[email protected]"}
]
maintainers = [
{name = "colinho", email = "[email protected]"}
]
license = {file = "LICENSE"}
readme = {file = "README.md", content-type = "text/markdown"}
requires-python = ">3.7,<3.13"
classifiers=[
authors = [{ name = "colinho", email = "[email protected]" }]
maintainers = [{ name = "colinho", email = "[email protected]" }]
license = { file = "LICENSE" }
readme = { file = "README.md", content-type = "text/markdown" }
requires-python = ">=3.8,<3.13"
classifiers = [
"Intended Audience :: End Users/Desktop",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
Expand All @@ -33,13 +29,25 @@ dependencies = [
"dataclass-wizard==0.22.3",
"ffmpeg-python==0.2.0",
"mutagen==1.47.0",
"m3u8==5.1.0",
"m3u8==6.0.0",
"platformdirs==4.2.2",
"pycryptodome==3.20.0",
"requests[socks]==2.32.3",
"typer==0.12.3"
"typer==0.12.5",
]
[project.scripts]
tidal-wave = "tidal_wave.main:app"
[project.urls]
Homepage = "https://github.com/ebb-earl-co/tidal-wave"

[tool.ruff]
target-version = "py38"

[tool.setuptools.dynamic]
version = {attr = "tidal_wave.main.__version__"}

[tool.uv]
dev-dependencies = [
"pyinstaller==6.7.0",
"ruff"
]
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ cachecontrol==0.14.0
dataclass-wizard==0.22.3
ffmpeg-python==0.2.0
mutagen==1.47.0
m3u8==5.1.0
m3u8==6.0.0
platformdirs==4.2.2
pycryptodome==3.20.0
requests[socks]==2.32.3
typer==0.12.3
typer==0.12.5
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python3

"""Provide a shim to pyproject.toml-based building of this package."""
import setuptools

if __name__ == "__main__":
Expand Down
2 changes: 2 additions & 0 deletions tidal_wave/__main__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
"""tidal_wave is a module that retrieves data from TIDAL API and writes it to disk."""

from .main import app

app()
Loading

0 comments on commit bb51d63

Please sign in to comment.