mirror of
https://github.com/nathom/streamrip.git
synced 2025-05-14 23:24:52 -04:00
Update config files automatically; #46
This commit is contained in:
parent
c115eae15f
commit
b7659a39cf
2 changed files with 34 additions and 20 deletions
|
@ -114,6 +114,13 @@ class Config:
|
||||||
else:
|
else:
|
||||||
self.load()
|
self.load()
|
||||||
|
|
||||||
|
def update(self):
|
||||||
|
self.reset()
|
||||||
|
temp = copy.deepcopy(self.defaults)
|
||||||
|
temp['qobuz'] = self.file['qobuz']
|
||||||
|
temp['tidal'] = self.file['tidal']
|
||||||
|
self.dump(temp)
|
||||||
|
|
||||||
def save(self):
|
def save(self):
|
||||||
"""Save the config state to file."""
|
"""Save the config state to file."""
|
||||||
|
|
||||||
|
@ -181,7 +188,7 @@ class Config:
|
||||||
return self.qobuz_creds
|
return self.qobuz_creds
|
||||||
if source == "tidal":
|
if source == "tidal":
|
||||||
return self.tidal_creds
|
return self.tidal_creds
|
||||||
if source == "deezer":
|
if source == "deezer" or source == 'soundcloud':
|
||||||
return dict()
|
return dict()
|
||||||
|
|
||||||
raise InvalidSourceError(source)
|
raise InvalidSourceError(source)
|
||||||
|
|
|
@ -114,27 +114,34 @@ class MusicDL(list):
|
||||||
item = MEDIA_CLASS[media_type](client=client, id=item_id)
|
item = MEDIA_CLASS[media_type](client=client, id=item_id)
|
||||||
self.append(item)
|
self.append(item)
|
||||||
|
|
||||||
|
def _get_download_args(self) -> dict:
|
||||||
|
return {
|
||||||
|
"database": self.db,
|
||||||
|
"parent_folder": self.config.session["downloads"]["folder"],
|
||||||
|
"folder_format": self.config.session["path_format"]["folder"],
|
||||||
|
"track_format": self.config.session["path_format"]["track"],
|
||||||
|
"embed_cover": self.config.session["artwork"]["embed"],
|
||||||
|
"embed_cover_size": self.config.session["artwork"]["size"],
|
||||||
|
"keep_hires_cover": self.config.session["artwork"]["keep_hires_cover"],
|
||||||
|
"set_playlist_to_album": self.config.session["metadata"][
|
||||||
|
"set_playlist_to_album"
|
||||||
|
],
|
||||||
|
"stay_temp": self.config.session["conversion"]["enabled"],
|
||||||
|
"conversion": self.config.session["conversion"],
|
||||||
|
"concurrent_downloads": self.config.session["concurrent_downloads"],
|
||||||
|
"new_tracknumbers": self.config.session["metadata"][
|
||||||
|
"new_playlist_tracknumbers"
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
def download(self):
|
def download(self):
|
||||||
try:
|
try:
|
||||||
arguments = {
|
arguments = self._get_download_args()
|
||||||
"database": self.db,
|
except KeyError:
|
||||||
"parent_folder": self.config.session["downloads"]["folder"],
|
click.secho("Updating config file... Please run the command again.", fg='magenta')
|
||||||
"folder_format": self.config.session["path_format"]["folder"],
|
self.config.update()
|
||||||
"track_format": self.config.session["path_format"]["track"],
|
exit()
|
||||||
"embed_cover": self.config.session["artwork"]["embed"],
|
except Exception as err:
|
||||||
"embed_cover_size": self.config.session["artwork"]["size"],
|
|
||||||
"keep_hires_cover": self.config.session["artwork"]["keep_hires_cover"],
|
|
||||||
"set_playlist_to_album": self.config.session["metadata"][
|
|
||||||
"set_playlist_to_album"
|
|
||||||
],
|
|
||||||
"stay_temp": self.config.session["conversion"]["enabled"],
|
|
||||||
"conversion": self.config.session["conversion"],
|
|
||||||
"concurrent_downloads": self.config.session["concurrent_downloads"],
|
|
||||||
"new_tracknumbers": self.config.session["metadata"][
|
|
||||||
"new_playlist_tracknumbers"
|
|
||||||
],
|
|
||||||
}
|
|
||||||
except KeyError as err:
|
|
||||||
click.secho(
|
click.secho(
|
||||||
"There was a problem with your config file. This happens "
|
"There was a problem with your config file. This happens "
|
||||||
"sometimes after updates. Run ",
|
"sometimes after updates. Run ",
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue