def __init__(self, site: Site): if site == Site.BEATJUNKIES: self.pool = Beatjunkies() elif site == Site.BPMSUPREME: self.pool = BPMSupreme() elif site == Site.DJCITY: self.pool = DJCity() elif site == Site.BANDCAMP: self.pool = Bandcamp() else: raise RuntimeError(f"Unsupported record pool: {site}!") self.pool.start_driver() logging.info(f"Initialized {self.pool} on {self.pool.system_name()}") logging.info(f"Download path: '{self.pool.download_path}'")
def main(): arguments = docopt(__doc__, version='bandcamp-dl 1.0') bandcamp = Bandcamp() if (arguments['--artist'] and arguments['--album']): url = Bandcamp.generate_album_url(arguments['--artist'], arguments['--album']) else: url = arguments['<url>'] album = bandcamp.parse(url) basedir = arguments['--base-dir'] or os.getcwd() if not album: print "The url {} is not a valid bandcamp page.".format(url) elif arguments['--full-album'] and not album['full']: print "Full album not available. Skipping..." else: bandcamp_downloader = BandcampDownloader(url, arguments['--template'], basedir, arguments['--overwrite']) bandcamp_downloader.start(album)
http://github.com/miniarray Iheanyi: Feel free to use this in any way you wish. I made this just for fun. Shout out to darkf for writing a helper function for parsing the JavaScript! """ from docopt import docopt from Bandcamp import Bandcamp from BandcampDownloader import BandcampDownloader import os if __name__ == '__main__': arguments = docopt(__doc__, version='bandcamp-dl 1.0') bandcamp = Bandcamp() if (arguments['--artist'] and arguments['--album']): url = Bandcamp.generate_album_url(arguments['--artist'], arguments['--album']) else: url = arguments['<url>'] album = bandcamp.parse(url) basedir = arguments['--base-dir'] or os.path.dirname(os.path.realpath(__file__)) if not album: print "The url {} is not a valid bandcamp page.".format(url) elif arguments['--full-album'] and not album['full']: print "Full album not availiable. Skipping.." else: bandcamp_downloader = BandcampDownloader(url, arguments['--template'], basedir, arguments['--overwrite'])
http://miniarray.com http://twitter.com/miniarray http://github.com/miniarray Iheanyi: Feel free to use this in any way you wish. I made this just for fun. Shout out to darkf for writing a helper function for parsing the JavaScript! """ from docopt import docopt from Bandcamp import Bandcamp from BandcampDownloader import BandcampDownloader import os if __name__ == '__main__': arguments = docopt(__doc__, version='bandcamp-dl 1.0') bandcamp = Bandcamp() if (arguments['--artist'] and arguments['--album']): url = Bandcamp.generate_album_url(arguments['--artist'], arguments['--album']) else: url = arguments['<url>'] album = bandcamp.parse(url) basedir = arguments['--base-dir'] or os.path.dirname( os.path.realpath(__file__)) if not album: print "The url {} is not a valid bandcamp page.".format(url) elif arguments['--full-album'] and not album['full']: print "Full album not availiable. Skipping.."
class RecordPoolDownloader: """Command line tool for recordpool web downloads.""" def __init__(self, site: Site): if site == Site.BEATJUNKIES: self.pool = Beatjunkies() elif site == Site.BPMSUPREME: self.pool = BPMSupreme() elif site == Site.DJCITY: self.pool = DJCity() elif site == Site.BANDCAMP: self.pool = Bandcamp() else: raise RuntimeError(f"Unsupported record pool: {site}!") self.pool.start_driver() logging.info(f"Initialized {self.pool} on {self.pool.system_name()}") logging.info(f"Download path: '{self.pool.download_path}'") def run_loop(self): print_bold("\nChoose mode:") print(" 0: Single page") print(">0: Multiple pages") try: number = int(input()) print() if number > 0: self.multi_page_loop(number) else: self.single_page_loop() except ValueError: self.single_page_loop() def single_page_loop(self): self.pool.update_current_page() while True: print_bold(f"--- Page: {self.pool.current_num} ---") try: number = int( input( "Give number of tracks to download from current page, 0 = all\n" ) ) number = max(0, number) except ValueError: number = 0 self.single_page_download(number) if not self.pool.next_page(): print_color("No more pages!", Color.red) break self.play_notification_sound() if not input("Continue?\n").lower() in ("y", "1"): break def multi_page_loop(self, pages=1): self.pool.update_current_page() last_page = self.pool.current_num + pages - 1 for _ in range(1, pages + 1): print_bold(f"--- Page: {self.pool.current_num} / {last_page} ---") self.single_page_download() if not self.pool.next_page(): print_color("No more pages!", Color.red) return print_bold("Continue for pages?") self.play_notification_sound() try: num = int(input()) if num > 0: self.multi_page_loop(num) except ValueError: return def single_page_download(self, number=0): tracks = self.pool.download_page(number) logging.info(f"Page {self.pool.current_num}: downloaded {tracks} files.") def play_notification_sound(self): """Play system notification sound without waiting for function call to finish.""" threading.Thread( target=self._play_notification, args=(self.pool.mac_os(),) ).start() @staticmethod def _play_notification(mac: bool): if mac: os.system("afplay /System/Library/Sounds/Glass.aiff") else: import winsound winsound.PlaySound("SystemExclamation", winsound.SND_ALIAS)