iheanyi / bandcamp-dl

Simple python script to download Bandcamp albums
The Unlicense
941 stars 104 forks source link

Config file support #201

Closed Evolution0 closed 1 year ago

Evolution0 commented 1 year ago

Would essentially only be used for setting the base-dir permanently as well as possibly creating a default template.

Not sure if it should override args on run or the other way around.

Likely stored in the user directory as a dotfile, not sure what the current scheme is for linux/unix and mac but I would assume something like ~/.config/bandcamp-dl/settings.json or ~/.config/bandcamp-dl.json would do for linux.

This is mostly a reminder for myself but if anyone has suggestions on configurable options, etc let me know here.

Evolution0 commented 1 year ago

Considered TOML for readability but didn't want to use a stdlib only available in Python 3.11 or introduce any new ones (tomlkit).

Evolution0 commented 1 year ago

Added in 9f22fbe4002e4bfe04b053d0ee6d65399c9f0ce5, still in the testing phase and docopt forced me to write a long series of if checks to allow args to override a users static config.

Looking to replace docopt at this point honestly, its been out of development 5 years now.

noelle-gray commented 1 year ago

Hi, I was recently in the same page as the confusion about the default --base-dir. Apologies, if I've missed something or misunderstand the code.

Steps to recreate: git clone the repo, virtualenv venv, and source venv/bin/activate. Then python setup.py install.

After this is done running bandcamp-dl for the first time seems to do something weird. Because it hasn't been run yet. After running bandcamp-dl to download something for the first time, you get this:

bandcamp-dl/venv/bin/bandcamp-dl", line 33, in <module>
    sys.exit(load_entry_point('bandcamp-downloader==0.0.15', 'console_scripts', 'bandcamp-dl')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/Apps/bandcamp-dl/venv/lib/python3.11/site-packages/bandcamp_downloader-0.0.15-py3.11.egg/bandcamp_dl/__main__.py", line 76, in main
  File "/home/user/Apps/bandcamp-dl/venv/lib/python3.11/site-packages/bandcamp_downloader-0.0.15-py3.11.egg/bandcamp_dl/utils/config.py", line 61, in init_config
UnboundLocalError: cannot access local variable 'first_run' where it is not associated with a value

After this, ~/.config/bandcamp-dl.json is created. However, it does so by creating it based on a dict from {__version__}.not.finished which obtains the variable "None" from config.py, in line 82, but before properly writing the config_path from def init_config(arguments). The result of this is that None is obtained as a string value, which then creates a folder named None from the config using os.path.expanduser('~')

After this, bandcamp-dl will continue to download URLs into the None folder. I've tested this by editing the bandcamp-dl.json

The notes about ## TODO in config.py seem to indicate this is still in progress as needing a fix, and I haven't been running the dev branch because its behind, so I think I'm using the most recent version? I can delete this entire post here as I'm just trying to provide some helpful feedback about problems encountered when trying to use this application associated with the bandcamp-dl.json config file and apologize if I've missed an important step here. The debug interface was not working properly, otherwise I'd post that in detail. The ## To Do indicates there are issues associated with this part of the code still, as mentioned, still in testing.

Evolution0 commented 1 year ago

I don't make use of the branches here in github, essentially if its not a tagged release or a release pushed to PyPI its considered dev.