Compare commits
2 Commits
ad08e9156f
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 1d1426f6ae | |||
| c15a183d1d |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1 +1,2 @@
|
||||
audio
|
||||
audio
|
||||
.venv
|
||||
52
downloader.py
Normal file
52
downloader.py
Normal file
@@ -0,0 +1,52 @@
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
url = "https://soundcloud.com/"
|
||||
path = "musicbya/sets/13th-dec-crash-out"
|
||||
|
||||
command_link = url + path
|
||||
|
||||
dl_path = "/Users/azeem/repos/sc-audio-downloader/audio/13-DEC-CO-SC"
|
||||
|
||||
# run command scdl -l command_link --path dl_path in command line, log output constantly into python terminal
|
||||
|
||||
def run_scdl_with_output():
|
||||
"""Run scdl command and stream output to terminal"""
|
||||
command = ["scdl", "-l", command_link, "--path", dl_path, "--flac", "--name-format", "%(playlist_index)s - %(title)s.%(ext)s"]
|
||||
|
||||
print(f"Running command: {' '.join(command)}")
|
||||
print("-" * 50)
|
||||
|
||||
try:
|
||||
# Use subprocess.Popen to get real-time output
|
||||
process = subprocess.Popen(
|
||||
command,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT,
|
||||
universal_newlines=True,
|
||||
bufsize=1
|
||||
)
|
||||
|
||||
# Stream output line by line
|
||||
for line in process.stdout:
|
||||
print(line.rstrip())
|
||||
sys.stdout.flush() # Ensure immediate output
|
||||
|
||||
# Wait for process to complete and get return code
|
||||
return_code = process.wait()
|
||||
|
||||
if return_code == 0:
|
||||
print("\n" + "=" * 50)
|
||||
print("Download completed successfully!")
|
||||
else:
|
||||
print(f"\n" + "=" * 50)
|
||||
print(f"Command failed with return code: {return_code}")
|
||||
|
||||
except FileNotFoundError:
|
||||
print("Error: scdl command not found. Make sure it's installed and in your PATH.")
|
||||
print("You can install it with: pip install scdl")
|
||||
except Exception as e:
|
||||
print(f"An error occurred: {e}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
run_scdl_with_output()
|
||||
Reference in New Issue
Block a user