songbirdcli 0.2.0__tar.gz → 0.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {songbirdcli-0.2.0 → songbirdcli-0.2.2}/.github/workflows/docker.yml +4 -5
- songbirdcli-0.2.2/.github/workflows/pages.yaml +70 -0
- {songbirdcli-0.2.0 → songbirdcli-0.2.2}/.github/workflows/pypi-publish.yaml +1 -1
- {songbirdcli-0.2.0 → songbirdcli-0.2.2}/.github/workflows/style.yml +1 -1
- {songbirdcli-0.2.0 → songbirdcli-0.2.2}/.github/workflows/tests.yaml +1 -1
- {songbirdcli-0.2.0 → songbirdcli-0.2.2}/.gitignore +3 -0
- {songbirdcli-0.2.0 → songbirdcli-0.2.2}/Makefile +22 -0
- {songbirdcli-0.2.0 → songbirdcli-0.2.2}/PKG-INFO +10 -3
- {songbirdcli-0.2.0 → songbirdcli-0.2.2}/README.md +2 -0
- songbirdcli-0.2.2/docs/index.md +18 -0
- songbirdcli-0.2.2/docs/songbirdcli/cli.md +4 -0
- songbirdcli-0.2.2/docs/songbirdcli/helpers.md +4 -0
- songbirdcli-0.2.2/docs/songbirdcli/settings.md +4 -0
- songbirdcli-0.2.2/markdownlint.yaml +8 -0
- songbirdcli-0.2.2/mkdocs.yml +78 -0
- {songbirdcli-0.2.0 → songbirdcli-0.2.2}/pyproject.toml +11 -1
- {songbirdcli-0.2.0 → songbirdcli-0.2.2}/songbirdcli/cli.py +36 -13
- {songbirdcli-0.2.0 → songbirdcli-0.2.2}/songbirdcli/helpers.py +35 -7
- {songbirdcli-0.2.0 → songbirdcli-0.2.2}/songbirdcli/requirements.txt +2 -2
- {songbirdcli-0.2.0 → songbirdcli-0.2.2}/songbirdcli/settings.py +2 -2
- songbirdcli-0.2.2/songbirdcli/version.py +1 -0
- {songbirdcli-0.2.0 → songbirdcli-0.2.2}/songbirdcli.egg-info/PKG-INFO +10 -3
- {songbirdcli-0.2.0 → songbirdcli-0.2.2}/songbirdcli.egg-info/SOURCES.txt +7 -0
- {songbirdcli-0.2.0 → songbirdcli-0.2.2}/songbirdcli.egg-info/requires.txt +6 -2
- {songbirdcli-0.2.0 → songbirdcli-0.2.2}/songbirdcli.egg-info/top_level.txt +1 -0
- songbirdcli-0.2.2/tests/unit/test_cli.py +106 -0
- songbirdcli-0.2.0/songbirdcli/version.py +0 -1
- songbirdcli-0.2.0/tests/unit/test_cli.py +0 -63
- {songbirdcli-0.2.0 → songbirdcli-0.2.2}/.dockerignore +0 -0
- {songbirdcli-0.2.0 → songbirdcli-0.2.2}/Dockerfile +0 -0
- {songbirdcli-0.2.0 → songbirdcli-0.2.2}/LICENSE +0 -0
- {songbirdcli-0.2.0 → songbirdcli-0.2.2}/setup.cfg +0 -0
- {songbirdcli-0.2.0 → songbirdcli-0.2.2}/songbirdcli/requirements.txt.blank +0 -0
- {songbirdcli-0.2.0 → songbirdcli-0.2.2}/songbirdcli.egg-info/dependency_links.txt +0 -0
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
name:
|
|
1
|
+
name: docker
|
|
2
2
|
on:
|
|
3
3
|
push:
|
|
4
4
|
branches: [main]
|
|
5
|
+
tags: '*'
|
|
5
6
|
pull_request:
|
|
6
7
|
branches: [main]
|
|
7
|
-
release:
|
|
8
|
-
types: [published]
|
|
9
8
|
jobs:
|
|
10
9
|
build:
|
|
11
10
|
runs-on: ubuntu-22.04
|
|
@@ -26,7 +25,7 @@ jobs:
|
|
|
26
25
|
id: vars
|
|
27
26
|
run: |
|
|
28
27
|
tag="${GITHUB_SHA:0:8}"
|
|
29
|
-
if [
|
|
28
|
+
if [[ ${GITHUB_REF} == refs/tags* ]]; then
|
|
30
29
|
ref="${GITHUB_REF}"
|
|
31
30
|
tag=$(echo $GITHUB_REF | sed 's/refs\/tags\///g')
|
|
32
31
|
fi
|
|
@@ -56,7 +55,7 @@ jobs:
|
|
|
56
55
|
--file ./Dockerfile \
|
|
57
56
|
-o type=image,push=false .
|
|
58
57
|
- name: Run Buildx (push image)
|
|
59
|
-
if: success()
|
|
58
|
+
if: success() && (github.event_name == 'push' || startsWith(github.ref, 'refs/tags/')) # only trigger a build and push to docker registry on tag or commit sha off
|
|
60
59
|
run: |
|
|
61
60
|
docker buildx build --platform ${{ steps.prepare.outputs.DOCKER_PLATFORM_AMD64 }},${{ steps.prepare.outputs.DOCKER_PLATFORM_ARM }} \
|
|
62
61
|
--target ${{ steps.prepare.outputs.DOCKER_BUILD_TO_TARGET }} \
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
name: pages
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
branches: [main]
|
|
6
|
+
push:
|
|
7
|
+
tags:
|
|
8
|
+
- '*'
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
lint:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
if: github.event_name == 'pull_request'
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
- name: install requirements
|
|
17
|
+
run: |
|
|
18
|
+
sudo apt update
|
|
19
|
+
sudo apt install nodejs npm
|
|
20
|
+
sudo npm install -g markdownlint-cli
|
|
21
|
+
- name: lint
|
|
22
|
+
run: |
|
|
23
|
+
shopt -s globstar
|
|
24
|
+
shopt -s extglob
|
|
25
|
+
make docs-lint
|
|
26
|
+
|
|
27
|
+
test:
|
|
28
|
+
runs-on: ubuntu-latest
|
|
29
|
+
if: github.event_name == 'pull_request'
|
|
30
|
+
steps:
|
|
31
|
+
- uses: actions/checkout@v4
|
|
32
|
+
- name: set up Python 3.11
|
|
33
|
+
uses: actions/setup-python@v5
|
|
34
|
+
with:
|
|
35
|
+
python-version: 3.11
|
|
36
|
+
- name: install dependencies
|
|
37
|
+
run: |
|
|
38
|
+
python -m pip install --upgrade pip
|
|
39
|
+
pip install -e .[dev]
|
|
40
|
+
- name: test the site builds
|
|
41
|
+
run: make docs-build
|
|
42
|
+
|
|
43
|
+
deploy:
|
|
44
|
+
runs-on: ubuntu-latest
|
|
45
|
+
if: startsWith(github.ref, 'refs/tags/')
|
|
46
|
+
steps:
|
|
47
|
+
- uses: actions/checkout@v4
|
|
48
|
+
- name: set up Python 3.11
|
|
49
|
+
uses: actions/setup-python@v5
|
|
50
|
+
with:
|
|
51
|
+
python-version: 3.11
|
|
52
|
+
- name: install dependencies
|
|
53
|
+
run: |
|
|
54
|
+
python -m pip install --upgrade pip
|
|
55
|
+
pip install -e .[dev]
|
|
56
|
+
- name: get tag
|
|
57
|
+
id: tag
|
|
58
|
+
run: |
|
|
59
|
+
ref="${GITHUB_REF}"
|
|
60
|
+
tag=$(echo $GITHUB_REF | sed 's/refs\/tags\///g')
|
|
61
|
+
echo "tag=$tag" >> $GITHUB_OUTPUT
|
|
62
|
+
- name: deploy
|
|
63
|
+
# the below steps are referenced from
|
|
64
|
+
# https://github.com/jimporter/mike#deploying-via-ci
|
|
65
|
+
run: |
|
|
66
|
+
git fetch origin gh-pages --depth=1
|
|
67
|
+
git config user.name github-actions
|
|
68
|
+
git config user.email github-actions@github.com
|
|
69
|
+
mike deploy --push --update-aliases ${{ steps.tag.outputs.tag }} latest
|
|
70
|
+
mike set-default --push latest
|
|
@@ -66,6 +66,22 @@ update-requirements: env
|
|
|
66
66
|
pip install -r $(APP_NAME)/requirements.txt.blank
|
|
67
67
|
pip freeze --exclude-editable > $(APP_NAME)/$(REQUIREMENTS_FILE)
|
|
68
68
|
|
|
69
|
+
# documentation targets
|
|
70
|
+
.PHONY: docs-lint
|
|
71
|
+
docs-lint:
|
|
72
|
+
@echo linting files at docs/**/*.md
|
|
73
|
+
markdownlint docs/**/*.md
|
|
74
|
+
|
|
75
|
+
.PHONY: docs-serve
|
|
76
|
+
docs-serve:
|
|
77
|
+
@echo serving the site on http://localhost:8000
|
|
78
|
+
mkdocs serve
|
|
79
|
+
|
|
80
|
+
.PHONY: docs-build
|
|
81
|
+
docs-build:
|
|
82
|
+
@echo building the site
|
|
83
|
+
mkdocs build --strict --verbose --site-dir public
|
|
84
|
+
|
|
69
85
|
.PHONY: build
|
|
70
86
|
build:
|
|
71
87
|
docker build -t $(APP_NAME):latest .
|
|
@@ -110,8 +126,14 @@ lint:
|
|
|
110
126
|
black $(APP_NAME)/.
|
|
111
127
|
black tests
|
|
112
128
|
|
|
129
|
+
.PHONY: test-cov
|
|
130
|
+
test-stdout:
|
|
131
|
+
python -m pytest --cov=songbirdcli tests/unit -v
|
|
132
|
+
|
|
133
|
+
.PHONY: test
|
|
113
134
|
test:
|
|
114
135
|
python -m pytest --doctest-modules --junitxml=junit/test-results.xml --cov=songbirdcli --cov-report=xml --cov-report=html tests/unit -v
|
|
115
136
|
|
|
137
|
+
.PHONY: test-env
|
|
116
138
|
test-env:
|
|
117
139
|
$(ENV_VARS) python -m pytest --doctest-modules --junitxml=junit/test-results.xml --cov=songbirdcli --cov-report=xml --cov-report=html tests/unit -v
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: songbirdcli
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: Songbird's cli.
|
|
5
5
|
Author: Christian Boin
|
|
6
|
+
Project-URL: Documentation, https://cboin1996.github.io/songbird/
|
|
6
7
|
Requires-Python: >=3.11
|
|
7
8
|
Description-Content-Type: text/markdown
|
|
8
9
|
License-File: LICENSE
|
|
@@ -47,10 +48,10 @@ Requires-Dist: pyparsing==3.1.2
|
|
|
47
48
|
Requires-Dist: pyquery==2.0.0
|
|
48
49
|
Requires-Dist: python-dotenv==1.0.1
|
|
49
50
|
Requires-Dist: requests==2.31.0
|
|
50
|
-
Requires-Dist: requests-htmlc==0.0.
|
|
51
|
+
Requires-Dist: requests-htmlc==0.0.7
|
|
51
52
|
Requires-Dist: requests-oauthlib==2.0.0
|
|
52
53
|
Requires-Dist: rsa==4.9
|
|
53
|
-
Requires-Dist: songbirdcore==0.0.
|
|
54
|
+
Requires-Dist: songbirdcore==0.0.9
|
|
54
55
|
Requires-Dist: soupsieve==2.5
|
|
55
56
|
Requires-Dist: toml==0.10.2
|
|
56
57
|
Requires-Dist: typing_extensions==4.11.0
|
|
@@ -65,6 +66,10 @@ Requires-Dist: click; extra == "dev"
|
|
|
65
66
|
Requires-Dist: isort; extra == "dev"
|
|
66
67
|
Requires-Dist: pytest; extra == "dev"
|
|
67
68
|
Requires-Dist: pytest-cov; extra == "dev"
|
|
69
|
+
Requires-Dist: mkdocs; extra == "dev"
|
|
70
|
+
Requires-Dist: mkdocs-material; extra == "dev"
|
|
71
|
+
Requires-Dist: mike; extra == "dev"
|
|
72
|
+
Requires-Dist: mkdocstrings-python; extra == "dev"
|
|
68
73
|
Provides-Extra: package
|
|
69
74
|
Requires-Dist: build; extra == "package"
|
|
70
75
|
Requires-Dist: twine; extra == "package"
|
|
@@ -213,6 +218,8 @@ pip install songbirdcli
|
|
|
213
218
|
See [tests](./tests/unit/test_cli.py) for an example
|
|
214
219
|
of configuring and running songbirdcli as a package.
|
|
215
220
|
|
|
221
|
+
For API documentation, view [here](https://cboin1996.github.io/songbird/)
|
|
222
|
+
|
|
216
223
|
## Development
|
|
217
224
|
|
|
218
225
|
To run the application locally, you can use a vscode debugger.
|
|
@@ -142,6 +142,8 @@ pip install songbirdcli
|
|
|
142
142
|
See [tests](./tests/unit/test_cli.py) for an example
|
|
143
143
|
of configuring and running songbirdcli as a package.
|
|
144
144
|
|
|
145
|
+
For API documentation, view [here](https://cboin1996.github.io/songbird/)
|
|
146
|
+
|
|
145
147
|
## Development
|
|
146
148
|
|
|
147
149
|
To run the application locally, you can use a vscode debugger.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# songbirdcli 🐦 Music Downloading Client Featuring mp3 or m4a Tagging
|
|
2
|
+
|
|
3
|
+
## Getting Started
|
|
4
|
+
|
|
5
|
+
Hello, and welcome to `songbirdcli`.
|
|
6
|
+
|
|
7
|
+
Get started by installing the `songbirdcli` package
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install songbirdcli
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
See [the github repository](https://github.com/cboin1996/songbird)
|
|
14
|
+
for detailed installation instructions!
|
|
15
|
+
|
|
16
|
+
## API Documentation
|
|
17
|
+
|
|
18
|
+
To view our API documentation, click [here](https://cboin1996.github.io/songbird/)
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
site_name: songbirdcli
|
|
2
|
+
site_description: Music Downloading Client Featuring mp3 or m4a Tagging
|
|
3
|
+
strict: true
|
|
4
|
+
site_url: https://cboin1996.github.io/songbird
|
|
5
|
+
site_dir: public
|
|
6
|
+
|
|
7
|
+
repo_name: cboin1996/songbird
|
|
8
|
+
repo_url: https://github.com/cboin1996/songbird
|
|
9
|
+
edit_uri: ""
|
|
10
|
+
|
|
11
|
+
theme:
|
|
12
|
+
name: material
|
|
13
|
+
features:
|
|
14
|
+
- content.tabs.link
|
|
15
|
+
- content.code.annotate
|
|
16
|
+
- content.code.copy
|
|
17
|
+
- announce.dismiss
|
|
18
|
+
- navigation.tabs
|
|
19
|
+
- navigation.instant
|
|
20
|
+
- navigation.instant.prefetch
|
|
21
|
+
- navigation.instant.preview
|
|
22
|
+
- navigation.instant.progress
|
|
23
|
+
- navigation.path
|
|
24
|
+
- navigation.top
|
|
25
|
+
- navigation.tracking
|
|
26
|
+
- search.suggest
|
|
27
|
+
- toc.follow
|
|
28
|
+
palette:
|
|
29
|
+
# Palette toggle for dark mode
|
|
30
|
+
- scheme: slate
|
|
31
|
+
primary: blue
|
|
32
|
+
toggle:
|
|
33
|
+
icon: material/weather-night
|
|
34
|
+
name: Switch to dark mode
|
|
35
|
+
# Palette toggle for light mode
|
|
36
|
+
- scheme: default
|
|
37
|
+
primary: blue
|
|
38
|
+
toggle:
|
|
39
|
+
icon: material/weather-sunny
|
|
40
|
+
name: Switch to light mode
|
|
41
|
+
|
|
42
|
+
# https://www.mkdocs.org/user-guide/configuration/#validation
|
|
43
|
+
validation:
|
|
44
|
+
omitted_files: warn
|
|
45
|
+
absolute_links: warn
|
|
46
|
+
unrecognized_links: warn
|
|
47
|
+
|
|
48
|
+
nav:
|
|
49
|
+
- Get Started:
|
|
50
|
+
- Welcome to songbirdcli: index.md
|
|
51
|
+
- API Documentation:
|
|
52
|
+
- songbirdcli:
|
|
53
|
+
- cli: songbirdcli/cli.md
|
|
54
|
+
- helpers: songbirdcli/helpers.md
|
|
55
|
+
- settings: songbirdcli/settings.md
|
|
56
|
+
|
|
57
|
+
extra:
|
|
58
|
+
version:
|
|
59
|
+
provider: mike
|
|
60
|
+
|
|
61
|
+
plugins:
|
|
62
|
+
- search
|
|
63
|
+
- mkdocstrings:
|
|
64
|
+
enabled: !ENV [ENABLE_MKDOCSTRINGS, true]
|
|
65
|
+
default_handler: python
|
|
66
|
+
handlers:
|
|
67
|
+
python:
|
|
68
|
+
options:
|
|
69
|
+
docstring_style: google
|
|
70
|
+
show_root_heading: true
|
|
71
|
+
show_root_full_path: true
|
|
72
|
+
show_root_toc_entry: true
|
|
73
|
+
docstring_section_style: list
|
|
74
|
+
show_source: true
|
|
75
|
+
show_bases: true
|
|
76
|
+
merge_init_into_class: true
|
|
77
|
+
show_symbol_type_heading: true
|
|
78
|
+
show_symbol_type_toc: true
|
|
@@ -7,12 +7,15 @@ name = "songbirdcli"
|
|
|
7
7
|
authors = [
|
|
8
8
|
{name = "Christian Boin"},
|
|
9
9
|
]
|
|
10
|
-
version = "0.2.
|
|
10
|
+
version = "0.2.2"
|
|
11
11
|
description = "Songbird's cli."
|
|
12
12
|
readme = "README.md"
|
|
13
13
|
requires-python = ">=3.11"
|
|
14
14
|
dynamic = ["dependencies"]
|
|
15
15
|
|
|
16
|
+
[project.urls]
|
|
17
|
+
Documentation = "https://cboin1996.github.io/songbird/"
|
|
18
|
+
|
|
16
19
|
[tool.setuptools.dynamic]
|
|
17
20
|
dependencies = {file = ["songbirdcli/requirements.txt"]}
|
|
18
21
|
|
|
@@ -20,11 +23,18 @@ dependencies = {file = ["songbirdcli/requirements.txt"]}
|
|
|
20
23
|
# these dependencies are required for development,
|
|
21
24
|
# not for running the package.
|
|
22
25
|
dev = [
|
|
26
|
+
# lint
|
|
23
27
|
"black",
|
|
24
28
|
"click",
|
|
25
29
|
"isort",
|
|
30
|
+
# test
|
|
26
31
|
"pytest",
|
|
27
32
|
"pytest-cov",
|
|
33
|
+
# docs
|
|
34
|
+
"mkdocs",
|
|
35
|
+
"mkdocs-material",
|
|
36
|
+
"mike",
|
|
37
|
+
"mkdocstrings-python"
|
|
28
38
|
]
|
|
29
39
|
package = [
|
|
30
40
|
"build",
|
|
@@ -14,10 +14,23 @@ from songbirdcore import youtube
|
|
|
14
14
|
from songbirdcore import gdrive
|
|
15
15
|
from songbirdcore import common
|
|
16
16
|
|
|
17
|
+
"""Entrypoint for songbirdcli. Run cli.py as a script to run songbirdcli.
|
|
18
|
+
See the README.md for configuration details.
|
|
19
|
+
"""
|
|
20
|
+
|
|
17
21
|
logger = logging.getLogger(__name__)
|
|
18
22
|
|
|
19
23
|
|
|
20
|
-
def validate_essentials(config: settings.SongbirdCliConfig):
|
|
24
|
+
def validate_essentials(config: settings.SongbirdCliConfig) -> bool:
|
|
25
|
+
"""perform startup validation of the configuration,
|
|
26
|
+
ensuring pre-conditions are met
|
|
27
|
+
|
|
28
|
+
Args:
|
|
29
|
+
config (settings.SongbirdCliConfig): the songbirdcli pydantic model
|
|
30
|
+
|
|
31
|
+
Returns:
|
|
32
|
+
bool: True if success, False otherwise
|
|
33
|
+
"""
|
|
21
34
|
success = True
|
|
22
35
|
if config.gdrive_enabled:
|
|
23
36
|
if not os.path.exists(config.get_gdrive_folder_path()):
|
|
@@ -105,7 +118,7 @@ def run_download_process(
|
|
|
105
118
|
"""Download a song from youtube.
|
|
106
119
|
|
|
107
120
|
Args:
|
|
108
|
-
|
|
121
|
+
file_path_no_format (str): the absolute path of where to save the file (excluding file format)
|
|
109
122
|
youtube_home_url (str): the url to youtube's home page
|
|
110
123
|
youtube_search_url (str): the search url for youtube
|
|
111
124
|
youtube_query_payload (str): the query payload for youtube's search api
|
|
@@ -203,6 +216,7 @@ def run_for_song(
|
|
|
203
216
|
|
|
204
217
|
if song_properties is None:
|
|
205
218
|
return
|
|
219
|
+
|
|
206
220
|
file_path_no_format = os.path.join(config.get_local_folder_path(), song_name)
|
|
207
221
|
file_path = file_path_no_format + "." + file_format
|
|
208
222
|
downloaded_file_path = None
|
|
@@ -219,7 +233,8 @@ def run_for_song(
|
|
|
219
233
|
# run the youtube downloader
|
|
220
234
|
if config.youtube_dl_enabled:
|
|
221
235
|
payload = config.youtube_searchform_payload
|
|
222
|
-
if song_properties
|
|
236
|
+
# if song_properties is False, user selected no properties
|
|
237
|
+
if song_properties != False:
|
|
223
238
|
payload[config.youtube_search_tag] = (
|
|
224
239
|
f"{song_properties.artistName} {song_properties.trackName}"
|
|
225
240
|
)
|
|
@@ -240,16 +255,18 @@ def run_for_song(
|
|
|
240
255
|
|
|
241
256
|
if downloaded_file_path is None:
|
|
242
257
|
return
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
tag_successful =
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
258
|
+
|
|
259
|
+
if song_properties != False:
|
|
260
|
+
# tag file if user specified song properties
|
|
261
|
+
tag_successful = False
|
|
262
|
+
if file_format == "mp3":
|
|
263
|
+
tag_successful = itunes.mp3ID3Tagger(downloaded_file_path, song_properties)
|
|
264
|
+
elif file_format == "m4a":
|
|
265
|
+
tag_successful = itunes.m4a_tagger(downloaded_file_path, song_properties)
|
|
266
|
+
else:
|
|
267
|
+
logger.warning(
|
|
268
|
+
"You've specified a file format that is has no tagger supported yet. Saving file without tags."
|
|
269
|
+
)
|
|
253
270
|
|
|
254
271
|
# provide user with choices for where to save their file to.
|
|
255
272
|
save_prompt_base = "Would you like to save your file to"
|
|
@@ -330,6 +347,12 @@ def run_for_song(
|
|
|
330
347
|
|
|
331
348
|
|
|
332
349
|
def run(config: settings.SongbirdCliConfig):
|
|
350
|
+
"""main entrypoint for songbirdcli. Expects the songbirdcli config object.
|
|
351
|
+
|
|
352
|
+
Args:
|
|
353
|
+
config (settings.SongbirdCliConfig): songbirdcli settings pydantic model
|
|
354
|
+
|
|
355
|
+
"""
|
|
333
356
|
try:
|
|
334
357
|
common.set_logger_config_globally(log_level=config.log_level)
|
|
335
358
|
common.name_plate(entries=[f"--cli {config.version}"])
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
helpers.py module for helping with parsing inputs
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
-
from typing import Optional, List
|
|
5
|
+
from typing import Optional, List, Union, Any
|
|
6
6
|
from songbirdcore import common, itunes
|
|
7
7
|
from songbirdcore.models import modes, itunes_api
|
|
8
8
|
import logging
|
|
@@ -14,6 +14,7 @@ def launch_album_mode(artist_album_string=""):
|
|
|
14
14
|
"""
|
|
15
15
|
Args:
|
|
16
16
|
artist_album_string (str): the album/artist to search for.
|
|
17
|
+
|
|
17
18
|
Returns: the list of song properties gathered from the search.
|
|
18
19
|
|
|
19
20
|
"""
|
|
@@ -47,7 +48,19 @@ def launch_album_mode(artist_album_string=""):
|
|
|
47
48
|
# entity is usually song for searching songs
|
|
48
49
|
def parse_itunes_search_api(
|
|
49
50
|
search_variable: str, mode: modes.Modes, limit: int = 20, lookup: bool = False
|
|
50
|
-
) -> itunes_api.ItunesApiSongModel:
|
|
51
|
+
) -> Optional[Union[bool, itunes_api.ItunesApiSongModel]]:
|
|
52
|
+
"""perform a query of the items api, allowing user to select
|
|
53
|
+
an item from the returned list of options
|
|
54
|
+
|
|
55
|
+
Args:
|
|
56
|
+
search_variable (str): the value for the query
|
|
57
|
+
mode (modes.Modes): the mode to run
|
|
58
|
+
limit (int, optional): number of results. Defaults to 20.
|
|
59
|
+
lookup (bool, optional): whether to enable 'lookup' mode in itunes api. Defaults to False.
|
|
60
|
+
|
|
61
|
+
Returns:
|
|
62
|
+
Optional[Union[itunes_api.ItunesApiSongModel]]: returns the selected song properties, a bool=False if use continues without selection, or None if the user quits or an error occurred.
|
|
63
|
+
"""
|
|
51
64
|
parsed_results_list = itunes.query_api(search_variable, limit, mode, lookup=lookup)
|
|
52
65
|
|
|
53
66
|
# Present results to user
|
|
@@ -67,7 +80,7 @@ def parse_itunes_search_api(
|
|
|
67
80
|
return
|
|
68
81
|
if len(user_selection) == 0:
|
|
69
82
|
logger.info("Continuing without properties.")
|
|
70
|
-
return
|
|
83
|
+
return False
|
|
71
84
|
|
|
72
85
|
print(f"Selected item: ")
|
|
73
86
|
for k, v in user_selection[0].model_dump().items():
|
|
@@ -76,7 +89,16 @@ def parse_itunes_search_api(
|
|
|
76
89
|
return user_selection[0]
|
|
77
90
|
|
|
78
91
|
|
|
79
|
-
def remove_songs_selected(song_properties_list):
|
|
92
|
+
def remove_songs_selected(song_properties_list) -> Optional[List]:
|
|
93
|
+
"""Given a list of songs properties, allow the user to remove
|
|
94
|
+
via stdio
|
|
95
|
+
|
|
96
|
+
Args:
|
|
97
|
+
song_properties_list (Any): the list of song properties
|
|
98
|
+
|
|
99
|
+
Returns:
|
|
100
|
+
Optional[List]: the properties list after selection
|
|
101
|
+
"""
|
|
80
102
|
common.pretty_list_of_basemodel_printer(song_properties_list)
|
|
81
103
|
input_string = "Enter song id's (1 4 5 etc.) you dont want from this album"
|
|
82
104
|
user_input = select_items_from_list(
|
|
@@ -97,7 +119,9 @@ def remove_songs_selected(song_properties_list):
|
|
|
97
119
|
return user_input
|
|
98
120
|
|
|
99
121
|
|
|
100
|
-
def get_input(
|
|
122
|
+
def get_input(
|
|
123
|
+
prompt: str, out_type=None, quit_str="q", choices: Optional[List] = None
|
|
124
|
+
) -> Optional[Any]:
|
|
101
125
|
"""Given a prompt, get input from stdio and perform basic type validation
|
|
102
126
|
|
|
103
127
|
Args:
|
|
@@ -107,7 +131,7 @@ def get_input(prompt: str, out_type=None, quit_str="q", choices: Optional[List]
|
|
|
107
131
|
choices (Optional[List], optional): valid character options to parse as input. Defaults to None.
|
|
108
132
|
|
|
109
133
|
Returns:
|
|
110
|
-
|
|
134
|
+
Optional[Any]: the typed user input, or None if quit or invalid type received.
|
|
111
135
|
"""
|
|
112
136
|
while True:
|
|
113
137
|
built_prompt = prompt
|
|
@@ -159,6 +183,8 @@ def get_input_list(prompt: str, sep: str, out_type=int, quit_str="q") -> List[in
|
|
|
159
183
|
|
|
160
184
|
str_list = inp.split(sep)
|
|
161
185
|
typed_list = []
|
|
186
|
+
# by default pass type check
|
|
187
|
+
type_check_passed = True
|
|
162
188
|
for item in str_list:
|
|
163
189
|
type_check_passed = True
|
|
164
190
|
try:
|
|
@@ -199,7 +225,9 @@ def select_items_from_list(
|
|
|
199
225
|
opposite (bool): return everything BUT the user selection
|
|
200
226
|
no_selection_value (any): value to indicate no selection wanted from the user
|
|
201
227
|
return_value (bool): if true, return the value, otherwise return the indicies of selections
|
|
202
|
-
|
|
228
|
+
|
|
229
|
+
Returns:
|
|
230
|
+
Optiona[List]: None if user quits, [] if user selects nothing, otherwise a list of the users selections are returned.
|
|
203
231
|
"""
|
|
204
232
|
tries = 0
|
|
205
233
|
low = 0
|
|
@@ -39,10 +39,10 @@ pyparsing==3.1.2
|
|
|
39
39
|
pyquery==2.0.0
|
|
40
40
|
python-dotenv==1.0.1
|
|
41
41
|
requests==2.31.0
|
|
42
|
-
requests-htmlc==0.0.
|
|
42
|
+
requests-htmlc==0.0.7
|
|
43
43
|
requests-oauthlib==2.0.0
|
|
44
44
|
rsa==4.9
|
|
45
|
-
songbirdcore==0.0.
|
|
45
|
+
songbirdcore==0.0.9
|
|
46
46
|
soupsieve==2.5
|
|
47
47
|
toml==0.10.2
|
|
48
48
|
typing_extensions==4.11.0
|
|
@@ -64,7 +64,7 @@ class SongbirdCliConfig(BaseSettings):
|
|
|
64
64
|
def get_local_folder_path(self):
|
|
65
65
|
return os.path.join(self.get_data_path(), self.local_song_store_str)
|
|
66
66
|
|
|
67
|
-
def get_itunes_folder_path(self):
|
|
67
|
+
def get_itunes_folder_path(self) -> str:
|
|
68
68
|
"""If you run the app locally, configure the itunes path as an absolute path. Otherwise, the program will
|
|
69
69
|
use the local container storage and assume to be running in a docker container.
|
|
70
70
|
|
|
@@ -75,7 +75,7 @@ class SongbirdCliConfig(BaseSettings):
|
|
|
75
75
|
return self.itunes_folder_path
|
|
76
76
|
return os.path.join(self.get_data_path(), self.itunes_folder_path)
|
|
77
77
|
|
|
78
|
-
def get_itunes_lib_path(self):
|
|
78
|
+
def get_itunes_lib_path(self) -> str:
|
|
79
79
|
"""If you run the app locally, configure the itunes path as an absolute path. Otherwise, the program will
|
|
80
80
|
use the local container storage and assume to be running in a docker container.
|
|
81
81
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
version = "0.2.2"
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: songbirdcli
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: Songbird's cli.
|
|
5
5
|
Author: Christian Boin
|
|
6
|
+
Project-URL: Documentation, https://cboin1996.github.io/songbird/
|
|
6
7
|
Requires-Python: >=3.11
|
|
7
8
|
Description-Content-Type: text/markdown
|
|
8
9
|
License-File: LICENSE
|
|
@@ -47,10 +48,10 @@ Requires-Dist: pyparsing==3.1.2
|
|
|
47
48
|
Requires-Dist: pyquery==2.0.0
|
|
48
49
|
Requires-Dist: python-dotenv==1.0.1
|
|
49
50
|
Requires-Dist: requests==2.31.0
|
|
50
|
-
Requires-Dist: requests-htmlc==0.0.
|
|
51
|
+
Requires-Dist: requests-htmlc==0.0.7
|
|
51
52
|
Requires-Dist: requests-oauthlib==2.0.0
|
|
52
53
|
Requires-Dist: rsa==4.9
|
|
53
|
-
Requires-Dist: songbirdcore==0.0.
|
|
54
|
+
Requires-Dist: songbirdcore==0.0.9
|
|
54
55
|
Requires-Dist: soupsieve==2.5
|
|
55
56
|
Requires-Dist: toml==0.10.2
|
|
56
57
|
Requires-Dist: typing_extensions==4.11.0
|
|
@@ -65,6 +66,10 @@ Requires-Dist: click; extra == "dev"
|
|
|
65
66
|
Requires-Dist: isort; extra == "dev"
|
|
66
67
|
Requires-Dist: pytest; extra == "dev"
|
|
67
68
|
Requires-Dist: pytest-cov; extra == "dev"
|
|
69
|
+
Requires-Dist: mkdocs; extra == "dev"
|
|
70
|
+
Requires-Dist: mkdocs-material; extra == "dev"
|
|
71
|
+
Requires-Dist: mike; extra == "dev"
|
|
72
|
+
Requires-Dist: mkdocstrings-python; extra == "dev"
|
|
68
73
|
Provides-Extra: package
|
|
69
74
|
Requires-Dist: build; extra == "package"
|
|
70
75
|
Requires-Dist: twine; extra == "package"
|
|
@@ -213,6 +218,8 @@ pip install songbirdcli
|
|
|
213
218
|
See [tests](./tests/unit/test_cli.py) for an example
|
|
214
219
|
of configuring and running songbirdcli as a package.
|
|
215
220
|
|
|
221
|
+
For API documentation, view [here](https://cboin1996.github.io/songbird/)
|
|
222
|
+
|
|
216
223
|
## Development
|
|
217
224
|
|
|
218
225
|
To run the application locally, you can use a vscode debugger.
|
|
@@ -4,11 +4,18 @@ Dockerfile
|
|
|
4
4
|
LICENSE
|
|
5
5
|
Makefile
|
|
6
6
|
README.md
|
|
7
|
+
markdownlint.yaml
|
|
8
|
+
mkdocs.yml
|
|
7
9
|
pyproject.toml
|
|
8
10
|
.github/workflows/docker.yml
|
|
11
|
+
.github/workflows/pages.yaml
|
|
9
12
|
.github/workflows/pypi-publish.yaml
|
|
10
13
|
.github/workflows/style.yml
|
|
11
14
|
.github/workflows/tests.yaml
|
|
15
|
+
docs/index.md
|
|
16
|
+
docs/songbirdcli/cli.md
|
|
17
|
+
docs/songbirdcli/helpers.md
|
|
18
|
+
docs/songbirdcli/settings.md
|
|
12
19
|
songbirdcli/cli.py
|
|
13
20
|
songbirdcli/helpers.py
|
|
14
21
|
songbirdcli/requirements.txt
|
|
@@ -39,10 +39,10 @@ pyparsing==3.1.2
|
|
|
39
39
|
pyquery==2.0.0
|
|
40
40
|
python-dotenv==1.0.1
|
|
41
41
|
requests==2.31.0
|
|
42
|
-
requests-htmlc==0.0.
|
|
42
|
+
requests-htmlc==0.0.7
|
|
43
43
|
requests-oauthlib==2.0.0
|
|
44
44
|
rsa==4.9
|
|
45
|
-
songbirdcore==0.0.
|
|
45
|
+
songbirdcore==0.0.9
|
|
46
46
|
soupsieve==2.5
|
|
47
47
|
toml==0.10.2
|
|
48
48
|
typing_extensions==4.11.0
|
|
@@ -58,6 +58,10 @@ click
|
|
|
58
58
|
isort
|
|
59
59
|
pytest
|
|
60
60
|
pytest-cov
|
|
61
|
+
mkdocs
|
|
62
|
+
mkdocs-material
|
|
63
|
+
mike
|
|
64
|
+
mkdocstrings-python
|
|
61
65
|
|
|
62
66
|
[package]
|
|
63
67
|
build
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
from songbirdcli import cli
|
|
2
|
+
from songbirdcli import settings
|
|
3
|
+
from songbirdcli import version
|
|
4
|
+
from io import StringIO
|
|
5
|
+
import os, sys, shutil
|
|
6
|
+
import pytest
|
|
7
|
+
|
|
8
|
+
cli_inputs = [
|
|
9
|
+
[
|
|
10
|
+
"jolene", # user enters jolene
|
|
11
|
+
"0", # user selects first song
|
|
12
|
+
"", # user opts to search youtube
|
|
13
|
+
"0", # user selects first song
|
|
14
|
+
"i", # save to local itunes folder
|
|
15
|
+
"q", # user quits
|
|
16
|
+
],
|
|
17
|
+
[
|
|
18
|
+
"jolene", # user enters jolene
|
|
19
|
+
"0", # user selects first song
|
|
20
|
+
"https://www.youtube.com/watch?v=Ixrje2rXLMA", # user opts to direct download
|
|
21
|
+
"l", # save locally
|
|
22
|
+
"q", # user quits
|
|
23
|
+
],
|
|
24
|
+
[
|
|
25
|
+
"billy joel", # user enters billy joel
|
|
26
|
+
"-1", # user selects continue without properties
|
|
27
|
+
"", # user opts to search youtube
|
|
28
|
+
"0", # user selects first song
|
|
29
|
+
"l", # user selects save locally
|
|
30
|
+
"q", # user quits
|
|
31
|
+
],
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
@pytest.fixture
|
|
36
|
+
def create_test_folder():
|
|
37
|
+
tests_data_folder = os.path.join(sys.path[0], "tests-output")
|
|
38
|
+
if not os.path.exists(tests_data_folder):
|
|
39
|
+
os.mkdir(tests_data_folder)
|
|
40
|
+
yield tests_data_folder
|
|
41
|
+
# test cleanup
|
|
42
|
+
shutil.rmtree(tests_data_folder)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
@pytest.fixture
|
|
46
|
+
def load_m4a_config(create_test_folder, monkeypatch, request):
|
|
47
|
+
# below are parametrized vectorized inputs that
|
|
48
|
+
# a user would enter if downloading a song
|
|
49
|
+
inputs = iter(request.param)
|
|
50
|
+
monkeypatch.setattr("builtins.input", lambda _: next(inputs))
|
|
51
|
+
# create tests-output folder
|
|
52
|
+
tests_data_folder = create_test_folder
|
|
53
|
+
config = settings.SongbirdCliConfig(
|
|
54
|
+
version=version.version,
|
|
55
|
+
root_path=tests_data_folder,
|
|
56
|
+
gdrive_enabled=False,
|
|
57
|
+
itunes_enabled=True,
|
|
58
|
+
file_format="m4a",
|
|
59
|
+
# we set these paths explicitly so that test
|
|
60
|
+
# directories are used
|
|
61
|
+
# in real world scenario, these values
|
|
62
|
+
# could be set to the actual itunes folders
|
|
63
|
+
# as long as run_local is true.
|
|
64
|
+
itunes_lib_path=os.path.join(tests_data_folder, "mock-itunes-lib"),
|
|
65
|
+
itunes_folder_path=os.path.join(tests_data_folder, "mock-itunes-auto-folder"),
|
|
66
|
+
run_local=True,
|
|
67
|
+
)
|
|
68
|
+
return config
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
@pytest.fixture
|
|
72
|
+
def load_mp3_config(create_test_folder, monkeypatch, request):
|
|
73
|
+
# below are parametrized vectorized inputs that
|
|
74
|
+
# a user would enter if downloading a song
|
|
75
|
+
inputs = iter(request.param)
|
|
76
|
+
monkeypatch.setattr("builtins.input", lambda _: next(inputs))
|
|
77
|
+
# create tests-output folder
|
|
78
|
+
tests_data_folder = create_test_folder
|
|
79
|
+
config = settings.SongbirdCliConfig(
|
|
80
|
+
version=version.version,
|
|
81
|
+
root_path=tests_data_folder,
|
|
82
|
+
gdrive_enabled=False,
|
|
83
|
+
itunes_enabled=True,
|
|
84
|
+
file_format="mp3",
|
|
85
|
+
# we set these paths explicitly so that test
|
|
86
|
+
# directories are used
|
|
87
|
+
# in real world scenario, these values
|
|
88
|
+
# could be set to the actual itunes folders
|
|
89
|
+
# as long as run_local is true.
|
|
90
|
+
itunes_lib_path=os.path.join(tests_data_folder, "mock-itunes-lib"),
|
|
91
|
+
itunes_folder_path=os.path.join(tests_data_folder, "mock-itunes-auto-folder"),
|
|
92
|
+
run_local=True,
|
|
93
|
+
)
|
|
94
|
+
return config
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
@pytest.mark.parametrize("load_mp3_config", cli_inputs, indirect=True)
|
|
98
|
+
def test_cli_mp3(load_mp3_config):
|
|
99
|
+
# invoke the main function of the cli
|
|
100
|
+
cli.run(config=load_mp3_config)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
@pytest.mark.parametrize("load_m4a_config", cli_inputs, indirect=True)
|
|
104
|
+
def test_cli_m4a(load_m4a_config):
|
|
105
|
+
# invoke the main function of the cli
|
|
106
|
+
cli.run(config=load_m4a_config)
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
version = "0.2.0"
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
from songbirdcli import cli
|
|
2
|
-
from songbirdcli import settings
|
|
3
|
-
from songbirdcli import version
|
|
4
|
-
from io import StringIO
|
|
5
|
-
import os, sys, shutil
|
|
6
|
-
import pytest
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
@pytest.fixture()
|
|
10
|
-
def load_config(monkeypatch, request):
|
|
11
|
-
# below are parametrized vectorized inputs that
|
|
12
|
-
# a user would enter if downloading a song
|
|
13
|
-
inputs = iter(request.param)
|
|
14
|
-
monkeypatch.setattr("builtins.input", lambda _: next(inputs))
|
|
15
|
-
# create tests-output folder
|
|
16
|
-
tests_data_folder = os.path.join(sys.path[0], "tests-output")
|
|
17
|
-
if not os.path.exists(tests_data_folder):
|
|
18
|
-
os.mkdir(tests_data_folder)
|
|
19
|
-
config = settings.SongbirdCliConfig(
|
|
20
|
-
version=version.version,
|
|
21
|
-
root_path=tests_data_folder,
|
|
22
|
-
gdrive_enabled=False,
|
|
23
|
-
itunes_enabled=True,
|
|
24
|
-
# we set these paths explicitly so that test
|
|
25
|
-
# directories are used
|
|
26
|
-
# in real world scenario, these values
|
|
27
|
-
# could be set to the actual itunes folders
|
|
28
|
-
# as long as run_local is true.
|
|
29
|
-
itunes_lib_path=os.path.join(tests_data_folder, "mock-itunes-lib"),
|
|
30
|
-
itunes_folder_path=os.path.join(tests_data_folder, "mock-itunes-auto-folder"),
|
|
31
|
-
run_local=True,
|
|
32
|
-
)
|
|
33
|
-
# yield setup to test
|
|
34
|
-
yield config
|
|
35
|
-
|
|
36
|
-
# test cleanup
|
|
37
|
-
shutil.rmtree(tests_data_folder)
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
@pytest.mark.parametrize(
|
|
41
|
-
"load_config",
|
|
42
|
-
[
|
|
43
|
-
[
|
|
44
|
-
"jolene", # user enters jolene
|
|
45
|
-
"0", # user selects first song
|
|
46
|
-
"", # user opts to search youtube
|
|
47
|
-
"0", # user selects first song
|
|
48
|
-
"i", # save to local itunes folder
|
|
49
|
-
"q", # user quits
|
|
50
|
-
],
|
|
51
|
-
[
|
|
52
|
-
"jolene", # user enters jolene
|
|
53
|
-
"0", # user selects first song
|
|
54
|
-
"https://www.youtube.com/watch?v=Ixrje2rXLMA", # user opts to direct download
|
|
55
|
-
"l", # save locally
|
|
56
|
-
"q", # user quits
|
|
57
|
-
],
|
|
58
|
-
],
|
|
59
|
-
indirect=True,
|
|
60
|
-
)
|
|
61
|
-
def test_cli_default(load_config):
|
|
62
|
-
# invoke the make function of the cli
|
|
63
|
-
cli.run(config=load_config)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|