results = downloader.download_lesson_range( start_lesson=min(lesson_range), end_lesson=max(lesson_range), base_url_template=base_url )
downloader = AssimilAudioDownloader(output_dir=args.output) Assimil German With Ease Audio Download
return jsonify( 'success': True, 'downloaded': len([r for r in results if r['success']]), 'files': results ) @app.route('/api/download-zip', methods=['POST']) def download_as_zip(): """Download multiple lessons as ZIP archive""" data = request.json lesson_numbers = data.get('lessons', []) results = downloader
def download_audio(self, url: str, filename: str, progress_callback=None) -> bool: """Download single audio file with progress tracking""" try: response = self.session.get(url, stream=True) response.raise_for_status() total_size = int(response.headers.get('content-length', 0)) filepath = self.output_dir / filename downloaded = 0 with open(filepath, 'wb') as f: for chunk in response.iter_content(chunk_size=8192): if chunk: f.write(chunk) downloaded += len(chunk) if progress_callback and total_size: progress = (downloaded / total_size) * 100 progress_callback(filename, progress) return True except Exception as e: print(f"Error downloading filename: e") return False 'files': results ) @app.route('/api/download-zip'
if args.all: print("Downloading all 113 lessons...") results = downloader.download_lesson_range(1, 113, "https://cdn.assimil.com/german/lesson_{}.mp3") elif args.start and args.end: results = downloader.download_lesson_range(args.start, args.end, "https://cdn.assimil.com/german/lesson_{}.mp3") else: parser.print_help() sys.exit(1)