mirror of
https://github.com/cooperhammond/irs.git
synced 2024-12-22 17:35:28 +00:00
Resolved commits and added flag for config file location
This commit is contained in:
commit
bd3b8da5e5
|
@ -41,6 +41,7 @@ optional arguments:
|
|||
-l LOCATION, --location LOCATION
|
||||
Specify a directory to place files in.
|
||||
-o, --organize Organize downloaded files.
|
||||
-c, --config Display path to config file.
|
||||
```
|
||||
So all of these are valid commands:
|
||||
```
|
||||
|
|
10
irs/cli.py
10
irs/cli.py
|
@ -28,8 +28,18 @@ def main():
|
|||
parser.add_argument("-l", "--location", dest="location", help="Specify a directory to place files in.")
|
||||
parser.add_argument("-o", "--organize", dest="organize", action="store_true", help="Organize downloaded files.")
|
||||
|
||||
# Config
|
||||
parser.add_argument("-c", "--config", dest="config", action="store_true", help="Display path to config file.")
|
||||
|
||||
|
||||
args = parser.parse_args(parse_default_flags())
|
||||
|
||||
if args.config:
|
||||
import irs
|
||||
print (os.path.dirname(irs.__file__) + "/config.py")
|
||||
sys.exit()
|
||||
|
||||
|
||||
ripper_args = {
|
||||
"post_processors": {
|
||||
"custom_directory": args.location,
|
||||
|
|
|
@ -6,7 +6,6 @@ CONFIG = dict(
|
|||
# To add a flag or argument, add an element to the index:
|
||||
# default_flags = ['-o', '-l', '~/Music']
|
||||
|
||||
|
||||
SPOTIFY_CLIENT_ID = '',
|
||||
SPOTIFY_CLIENT_SECRET = '',
|
||||
# You can either specify Spotify keys here, or in environment variables.
|
||||
|
|
14
irs/utils.py
14
irs/utils.py
|
@ -292,6 +292,14 @@ def check_sources(ripper, key, default=None, environment=False, where=None):
|
|||
|
||||
if tmp_args.get(key):
|
||||
return tmp_args.get(key)
|
||||
#============
|
||||
# CONFIG FILE
|
||||
#============
|
||||
from .config import CONFIG
|
||||
|
||||
def check_sources(ripper, key, default=None, environment=False):
|
||||
if ripper.args.get(key):
|
||||
return ripper.args.get(key)
|
||||
elif CONFIG.get(key):
|
||||
return CONFIG.get(key)
|
||||
elif os.environ.get(key) and environment == True:
|
||||
|
@ -326,4 +334,8 @@ def parse_organize(ripper):
|
|||
if organize == None:
|
||||
return check_sources(ripper, "organize", False, where="post_processors")
|
||||
else:
|
||||
return True
|
||||
return True
|
||||
|
||||
def parse_search_terms(ripper):
|
||||
search_terms = check_sources(ripper, "additional_search_terms", "lyrics")
|
||||
return search_terms
|
||||
|
|
Loading…
Reference in a new issue