From 78f6be0592565907bdb2a29394467c2efb25b7da Mon Sep 17 00:00:00 2001 From: aleksl0l Date: Fri, 12 Apr 2019 22:04:40 +0300 Subject: [PATCH 1/3] Add custom_dir argument to `scrape_bandcamp_url` function --- soundscrape/soundscrape.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/soundscrape/soundscrape.py b/soundscrape/soundscrape.py index 33cf39b..9472be8 100755 --- a/soundscrape/soundscrape.py +++ b/soundscrape/soundscrape.py @@ -565,7 +565,7 @@ def process_bandcamp(vargs): # Largely borrowed from Ronier's bandcampscrape -def scrape_bandcamp_url(url, num_tracks=sys.maxsize, folders=False, custom_path=''): +def scrape_bandcamp_url(url, num_tracks=sys.maxsize, folders=False, custom_path='', custom_dir=''): """ Pull out artist and track info from a Bandcamp URL. @@ -587,10 +587,13 @@ def scrape_bandcamp_url(url, num_tracks=sys.maxsize, folders=False, custom_path= album_name = album_data["album_name"] if folders: - if album_name: - directory = artist + " - " + album_name + if custom_dir: + directory = custom_dir else: - directory = artist + if album_name: + directory = artist + " - " + album_name + else: + directory = artist directory = sanitize_filename(directory) directory = join(custom_path, directory) if not exists(directory): From 34e96534761186e5aaf99bac8f3aaa6952081e4b Mon Sep 17 00:00:00 2001 From: aleksl0l Date: Fri, 12 Apr 2019 22:04:59 +0300 Subject: [PATCH 2/3] Add pass arguments for scrape_bandcamp_url --- soundscrape/soundscrape.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/soundscrape/soundscrape.py b/soundscrape/soundscrape.py index 9472be8..86471c8 100755 --- a/soundscrape/soundscrape.py +++ b/soundscrape/soundscrape.py @@ -545,7 +545,13 @@ def process_bandcamp(vargs): else: bc_url = 'https://' + artist_url + '.bandcamp.com/music' - filenames = scrape_bandcamp_url(bc_url, num_tracks=vargs['num_tracks'], folders=vargs['folders'], custom_path=vargs['path']) + filenames = scrape_bandcamp_url( + bc_url, + num_tracks=vargs['num_tracks'], + folders=vargs['folders'], + custom_path=vargs['path'], + custom_dir=vargs['custom_dir'] + ) # check if we have lists inside a list, which indicates the # scraping has gone recursive, so we must format the output From 6ebfd9d8b88b25cb81e48bb3032befbb166128d3 Mon Sep 17 00:00:00 2001 From: aleksl0l Date: Sat, 13 Apr 2019 00:32:02 +0300 Subject: [PATCH 3/3] Get kwargs safety --- soundscrape/soundscrape.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/soundscrape/soundscrape.py b/soundscrape/soundscrape.py index 86471c8..628fc2b 100755 --- a/soundscrape/soundscrape.py +++ b/soundscrape/soundscrape.py @@ -547,10 +547,10 @@ def process_bandcamp(vargs): filenames = scrape_bandcamp_url( bc_url, - num_tracks=vargs['num_tracks'], - folders=vargs['folders'], - custom_path=vargs['path'], - custom_dir=vargs['custom_dir'] + num_tracks=vargs.get('num_tracks'), + folders=vargs.get('folders'), + custom_path=vargs.get('path'), + custom_dir=vargs.get('custom_dir') ) # check if we have lists inside a list, which indicates the