Added --no-slugify option

Option added to maintain track, artist, and album names as they are. (Retain spaces, capitalization, etc)
master
Anthony Forsberg 2017-05-08 21:31:56 -04:00
parent c881c1d00d
commit 4413ad3ab2
5 changed files with 19 additions and 9 deletions

View File

@ -58,6 +58,7 @@ Details
[--embed-lyrics]
[--group]
[--embed-art]
[--no-slugify]
bandcamp-dl (-h | --help)
bandcamp-dl (--version)
@ -80,6 +81,7 @@ Options
-e --embed-lyrics Embed track lyrics (If available)
-g --group Use album/track Label as iTunes grouping
-r --embed-art Embed album art (If available)
-n --no-slugify Disable slugification of track, album, and artist names.
Filename Template
-----------------

View File

@ -10,6 +10,7 @@ Usage:
[--embed-lyrics]
[--group]
[--embed-art]
[--no-slugify]
bandcamp-dl (-h | --help)
bandcamp-dl (--version)
@ -28,6 +29,7 @@ Options:
-e --embed-lyrics Embed track lyrics (If available)
-g --group Use album/track Label as iTunes grouping
-r --embed-art Embed album art (If available)
-n --no-slugify Disable slugification of track, album, and artist names.
"""
"""
Coded by:
@ -95,7 +97,7 @@ def main():
else:
bandcamp_downloader = BandcampDownloader(url, arguments['--template'], basedir, arguments['--overwrite'],
arguments['--embed-lyrics'], arguments['--group'],
arguments['--embed-art'])
arguments['--embed-art'], arguments['--no-slugify'])
bandcamp_downloader.start(album)

View File

@ -10,7 +10,7 @@ from bandcamp_dl.bandcampjson import BandcampJSON
class Bandcamp:
def __init__(self):
self.headers = {'User-Agent': 'bandcamp-dl/0.0.8-1 (https://github.com/iheanyi/bandcamp-dl)'}
self.headers = {'User-Agent': 'bandcamp-dl/0.0.8-02 (https://github.com/iheanyi/bandcamp-dl)'}
def parse(self, url: str, art: bool=True) -> dict or None:
"""Requests the page, cherry picks album info

View File

@ -16,7 +16,7 @@ if not sys.version_info[:2] == (3, 6):
class BandcampDownloader:
def __init__(self, urls=None, template=None, directory=None, overwrite=False, lyrics=None, grouping=None,
embed_art=None, debug=False):
embed_art=None, no_slugify=False):
"""Initialize variables we will need throughout the Class
:param urls: list of urls
@ -24,7 +24,7 @@ class BandcampDownloader:
:param directory: download location
:param overwrite: if True overwrite existing files
"""
self.headers = {'User-Agent': 'bandcamp-dl/0.0.8-1 (https://github.com/iheanyi/bandcamp-dl)'}
self.headers = {'User-Agent': 'bandcamp-dl/0.0.8-02 (https://github.com/iheanyi/bandcamp-dl)'}
self.session = requests.Session()
if type(urls) is str:
@ -37,7 +37,7 @@ class BandcampDownloader:
self.lyrics = lyrics
self.grouping = grouping
self.embed_art = embed_art
self.debug = debug
self.no_slugify = no_slugify
def start(self, album: dict):
"""Start album download process
@ -62,15 +62,21 @@ class BandcampDownloader:
:return: filepath
"""
path = self.template
path = path.replace("%{artist}", slugify(track['artist']))
path = path.replace("%{album}", slugify(track['album']))
if self.no_slugify:
path = path.replace("%{artist}", track['artist'])
path = path.replace("%{album}", track['album'])
path = path.replace("%{title}", track['title'])
else:
path = path.replace("%{artist}", slugify(track['artist']))
path = path.replace("%{album}", slugify(track['album']))
path = path.replace("%{title}", slugify(track['title']))
if track['track'] == "None":
path = path.replace("%{track}", "Single")
else:
path = path.replace("%{track}", str(track['track']).zfill(2))
path = path.replace("%{title}", slugify(track['title']))
path = u"{0}/{1}.{2}".format(self.directory, path, "mp3")
return path

View File

@ -10,7 +10,7 @@ here = path.abspath(path.dirname(__file__))
setup(
name='bandcamp-downloader',
version='0.0.8-1',
version='0.0.8-02',
description='bandcamp-dl downloads albums and tracks from Bandcamp for you',
long_description=open('README.rst').read(),
url='https://github.com/iheanyi/bandcamp-dl',