-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.py
28 lines (20 loc) · 876 Bytes
/
script.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import subprocess
def run_commands_from_file(file_path):
try:
with open(file_path, 'r') as file:
links = file.readlines()
links = [link.strip() for link in links if link.strip()]
for link in links:
print(f"Running command for link: {link}")
command = ['spotify_to_ytmusic', 'create', link]
subprocess.run(command, check=True)
print(f"Finished processing {link}")
except FileNotFoundError:
print(f"Error: The file {file_path} does not exist.")
except subprocess.CalledProcessError as e:
print(f"Error: Command '{e.cmd}' failed with exit code {e.returncode}")
except Exception as e:
print(f"An unexpected error occurred: {e}")
if __name__ == "__main__":
links_file = 'links.txt'
run_commands_from_file(links_file)