mirror of
https://github.com/cooperhammond/irs.git
synced 2025-01-24 06:50:58 +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
|
-l LOCATION, --location LOCATION
|
||||||
Specify a directory to place files in.
|
Specify a directory to place files in.
|
||||||
-o, --organize Organize downloaded files.
|
-o, --organize Organize downloaded files.
|
||||||
|
-c, --config Display path to config file.
|
||||||
```
|
```
|
||||||
So all of these are valid commands:
|
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("-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.")
|
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())
|
args = parser.parse_args(parse_default_flags())
|
||||||
|
|
||||||
|
if args.config:
|
||||||
|
import irs
|
||||||
|
print (os.path.dirname(irs.__file__) + "/config.py")
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
|
||||||
ripper_args = {
|
ripper_args = {
|
||||||
"post_processors": {
|
"post_processors": {
|
||||||
"custom_directory": args.location,
|
"custom_directory": args.location,
|
||||||
|
|
|
@ -6,7 +6,6 @@ CONFIG = dict(
|
||||||
# To add a flag or argument, add an element to the index:
|
# To add a flag or argument, add an element to the index:
|
||||||
# default_flags = ['-o', '-l', '~/Music']
|
# default_flags = ['-o', '-l', '~/Music']
|
||||||
|
|
||||||
|
|
||||||
SPOTIFY_CLIENT_ID = '',
|
SPOTIFY_CLIENT_ID = '',
|
||||||
SPOTIFY_CLIENT_SECRET = '',
|
SPOTIFY_CLIENT_SECRET = '',
|
||||||
# You can either specify Spotify keys here, or in environment variables.
|
# You can either specify Spotify keys here, or in environment variables.
|
||||||
|
|
12
irs/utils.py
12
irs/utils.py
|
@ -292,6 +292,14 @@ def check_sources(ripper, key, default=None, environment=False, where=None):
|
||||||
|
|
||||||
if tmp_args.get(key):
|
if tmp_args.get(key):
|
||||||
return 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):
|
elif CONFIG.get(key):
|
||||||
return CONFIG.get(key)
|
return CONFIG.get(key)
|
||||||
elif os.environ.get(key) and environment == True:
|
elif os.environ.get(key) and environment == True:
|
||||||
|
@ -327,3 +335,7 @@ def parse_organize(ripper):
|
||||||
return check_sources(ripper, "organize", False, where="post_processors")
|
return check_sources(ripper, "organize", False, where="post_processors")
|
||||||
else:
|
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