Resolved commits and added flag for config file location

This commit is contained in:
Kepoor Hampond 2017-03-15 19:58:27 -07:00
commit bd3b8da5e5
4 changed files with 24 additions and 2 deletions

View file

@ -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:
```

View file

@ -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,

View file

@ -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.

View file

@ -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