First part of list (209/925) and add music script

This commit is contained in:
Halhadus 2024-10-06 23:54:03 +00:00
parent ffbe866bc6
commit c343902c45
2 changed files with 246 additions and 0 deletions

37
addmusic.py Normal file
View file

@ -0,0 +1,37 @@
import os
formatted_lines = []
if os.path.exists('musiclist.txt'):
with open('musiclist.txt', 'r') as file:
lines = file.readlines()
for line in lines:
formatted_lines.append(line.split(' --- ')[0])
while True:
first_part = input('Enter the artist and song title: ')
if first_part == '':
print('You must enter an artist and song title')
continue
if first_part in formatted_lines:
print('This song is already in the list')
continue
provider = input('Enter the provider: ')
if provider == '':
print('You must enter a provider')
continue
url = input('Enter the source URL: ')
if url == '':
print('You must enter a source URL')
continue
if (provider == 'YT') and (url.split('?v=')[0] == 'https://www.youtube.com/watch'):
urlid = url.split('?v=')[1]
with open('musiclist.txt', 'a') as file:
file.write(f'{first_part} --- {urlid} --- {provider}\n')
elif (provider == 'YTM') and (url.split('?v=')[0] == 'https://music.youtube.com/watch'):
urlid = url.split('?v=')[1]
with open('musiclist.txt', 'a') as file:
file.write(f'{first_part} --- {urlid} --- {provider}\n')
else:
print('Invalid source URL')
continue