Skip to content

Commit

Permalink
pyproject.toml fixes, version handling, logging
Browse files Browse the repository at this point in the history
Unicode-Slugify added to pyproject.toml

Version is no longer written to a file that sticks around in the code and thus must be acquired elsewhere.

Log level now correctly set, potential issue: If debug is set to true via config rather than args, thus the config has to be loaded before debugging enables, so debugging config itself will not fire.
  • Loading branch information
Evolution0 committed Jul 3, 2024
1 parent 7c8394a commit 523eafc
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
9 changes: 7 additions & 2 deletions bandcamp_dl/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@
import os
import sys

from bandcamp_dl import __version__
from bandcamp_dl.bandcamp import Bandcamp
from bandcamp_dl.bandcampdownloader import BandcampDownloader
from bandcamp_dl import config

import importlib.metadata
__version__ = importlib.metadata.version("bandcamp-downloader")


def main():
parser = argparse.ArgumentParser()
Expand Down Expand Up @@ -71,7 +73,10 @@ def main():
sys.stdout.write(f"{os.path.basename(sys.argv[0])} {__version__}\n")
return

logging.basicConfig(level=logging.NOTSET)
if arguments.debug:
logging.basicConfig(level=logging.DEBUG)
else:
logging.basicConfig()
logging_handle = "bandcamp-dl"
logger = logging.getLogger(logging_handle)

Expand Down
5 changes: 4 additions & 1 deletion bandcamp_dl/bandcamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
import bs4
import requests

from bandcamp_dl import __version__
import importlib.metadata
__version__ = importlib.metadata.version("bandcamp-downloader")

from bandcamp_dl.bandcampjson import BandcampJSON



class Bandcamp:
def __init__(self):
self.headers = {'User-Agent': f'bandcamp-dl/{__version__} '
Expand Down
3 changes: 2 additions & 1 deletion bandcamp_dl/bandcampdownloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
import requests
import slugify

from bandcamp_dl import __version__
import importlib.metadata
__version__ = importlib.metadata.version("bandcamp-downloader")


def print_clean(msg):
Expand Down
3 changes: 2 additions & 1 deletion bandcamp_dl/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
import logging
import os

from bandcamp_dl import __version__
import importlib.metadata
__version__ = importlib.metadata.version("bandcamp-downloader")

TEMPLATE = '%{artist}/%{album}/%{track} - %{title}'
OK_CHARS = '-_~'
Expand Down
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ dependencies = [
"beautifulsoup4 >= 4.13.0b2",
"demjson3 >= 3.0.6",
"mutagen >= 1.47.0",
"requests >= 2.32.3"
"requests >= 2.32.3",
"unicode-slugify >= 0.1.5"
]

[project.scripts]
Expand Down

0 comments on commit 523eafc

Please sign in to comment.