-
Notifications
You must be signed in to change notification settings - Fork 3
/
newOST.ps1
33 lines (28 loc) · 1.23 KB
/
newOST.ps1
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
29
30
31
32
33
try {
Clear-Host
Write-Host "
+-------------------------------------------------------------------------+
| ___ _____ _____ ____ _ _____ _ ____ _ ____ _____ |
| |_ _|_ _|_ _| | _ \ / \|_ _|/ \ | __ ) / \ / ___|| ____| |
| | | | | | | | | | |/ _ \ | | / _ \ | _ \ / _ \ \___ \| _| |
| | | | | | | | |_| / ___ \| |/ ___ \| |_) / ___ \ ___) | |___ |
| |___| |_| |_| |____/_/ \_\_/_/ \_\____/_/ \_\____/|_____| |
| Made with ♥ By Emad Adel |
+-------------------------------------------------------------------------+
"
# Read existing JSON file
$jsonFilePath = "./Assets/Database/OST.json"
$existingData = Get-Content $jsonFilePath -Raw -ErrorAction Stop | ConvertFrom-Json
# Prompt for input
$newOST = Read-Host "Enter the URL/ Example: www.eprojects.orgfree.com/ezio_family.mp3"
# Store input
$track = $newOST
# Add new object to existing array
$existingData.Tracks += $track
# Write updated JSON to file
$existingData | ConvertTo-Json | Out-File $jsonFilePath -ErrorAction Stop
Write-Host "Added Successfully" -ForegroundColor Green
}
catch {
Write-Host "An error occurred: $_"
}