-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathupload-videos-complete.ps1
More file actions
171 lines (145 loc) Β· 6.72 KB
/
Copy pathupload-videos-complete.ps1
File metadata and controls
171 lines (145 loc) Β· 6.72 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
# Complete Video Upload Script for Azure Storage
# This script uploads your high-quality videos to Azure Blob Storage
param(
[string]$StorageAccountName = "azvpstpucyxfsmd2gjc",
[string]$ContainerName = "videos",
[string]$VideoFolder = "assets"
)
Write-Host "π¬ Sachin's Video Portfolio - Azure Upload Script" -ForegroundColor Cyan
Write-Host "===============================================" -ForegroundColor Cyan
# Check if Azure CLI is installed
if (!(Get-Command az -ErrorAction SilentlyContinue)) {
Write-Host "β Azure CLI not found. Please install: https://docs.microsoft.com/en-us/cli/azure/install-azure-cli" -ForegroundColor Red
exit 1
}
Write-Host "π¦ Storage Account: $StorageAccountName" -ForegroundColor Green
Write-Host "π Container: $ContainerName" -ForegroundColor Green
Write-Host "πΉ Video Folder: $VideoFolder" -ForegroundColor Green
# Check if video folder exists
if (!(Test-Path $VideoFolder)) {
Write-Host "β Video folder '$VideoFolder' not found." -ForegroundColor Red
Write-Host "Please create the folder and add your video files:" -ForegroundColor Yellow
Write-Host " β’ trading (1).mp4" -ForegroundColor White
Write-Host " β’ trading (2).mp4" -ForegroundColor White
Write-Host " β’ trading (3).mp4" -ForegroundColor White
Write-Host " β’ trading (4).mp4" -ForegroundColor White
Write-Host " β’ motion graphic (1).mp4" -ForegroundColor White
Write-Host " β’ motion graphic (2).mp4" -ForegroundColor White
Write-Host " β’ motion graphic (3).mp4" -ForegroundColor White
Write-Host " β’ educational.mp4" -ForegroundColor White
Write-Host " β’ educational (2).mp4" -ForegroundColor White
Write-Host " β’ sub vdo.mp4" -ForegroundColor White
exit 1
}
# Get list of video files
$videoFiles = Get-ChildItem -Path $VideoFolder -Filter "*.mp4" | Where-Object { $_.Length -gt 0 }
if ($videoFiles.Count -eq 0) {
Write-Host "β No video files found in '$VideoFolder' folder" -ForegroundColor Red
Write-Host "Please add your MP4 video files to the folder and try again." -ForegroundColor Yellow
exit 1
}
Write-Host "πΉ Found $($videoFiles.Count) video files to upload:" -ForegroundColor Yellow
$totalSizeMB = 0
foreach ($file in $videoFiles) {
$sizeMB = [math]::Round($file.Length / 1MB, 2)
$totalSizeMB += $sizeMB
Write-Host " β’ $($file.Name) ($sizeMB MB)" -ForegroundColor White
}
Write-Host "π Total size: $([math]::Round($totalSizeMB, 2)) MB" -ForegroundColor Cyan
# Confirm upload
$confirmation = Read-Host "`nπ€ Do you want to upload these videos to Azure Storage? (y/N)"
if ($confirmation -ne 'y' -and $confirmation -ne 'Y') {
Write-Host "β Upload cancelled by user." -ForegroundColor Yellow
exit 0
}
Write-Host "`nπ Starting upload process..." -ForegroundColor Green
# Login check
$loginCheck = az account show 2>$null
if (!$loginCheck) {
Write-Host "π Please login to Azure first..." -ForegroundColor Yellow
az login
}
# Upload each video file
$uploadedUrls = @{}
$successCount = 0
$failCount = 0
foreach ($file in $videoFiles) {
# Create clean blob name (replace spaces and special characters)
$blobName = $file.Name -replace " ", "-" -replace "\(|\)", "" -replace "tradind", "trading"
Write-Host "`nβ¬οΈ Uploading $($file.Name) as $blobName..." -ForegroundColor Yellow
Write-Host " Size: $([math]::Round($file.Length / 1MB, 2)) MB" -ForegroundColor Gray
try {
# Upload with progress
$uploadResult = az storage blob upload `
--account-name $StorageAccountName `
--container-name $ContainerName `
--name $blobName `
--file $file.FullName `
--overwrite `
--output json 2>&1
if ($LASTEXITCODE -eq 0) {
$url = "https://$StorageAccountName.blob.core.windows.net/$ContainerName/$blobName"
$uploadedUrls[$file.Name] = @{
'url' = $url
'blobName' = $blobName
}
Write-Host "β
SUCCESS: $url" -ForegroundColor Green
$successCount++
} else {
Write-Host "β FAILED: $uploadResult" -ForegroundColor Red
$failCount++
}
}
catch {
Write-Host "β ERROR: $($_.Exception.Message)" -ForegroundColor Red
$failCount++
}
}
# Generate results
Write-Host "`nπ Upload Summary:" -ForegroundColor Cyan
Write-Host "=================" -ForegroundColor Cyan
Write-Host "β
Successful uploads: $successCount" -ForegroundColor Green
if ($failCount -gt 0) {
Write-Host "β Failed uploads: $failCount" -ForegroundColor Red
}
if ($successCount -gt 0) {
Write-Host "`nπ Uploaded Video URLs:" -ForegroundColor Cyan
Write-Host "======================" -ForegroundColor Cyan
$jsContent = @"
// Azure Video URLs - Generated $(Get-Date)
const AZURE_VIDEO_URLS = {
"@
foreach ($mapping in $uploadedUrls.GetEnumerator()) {
Write-Host "β’ $($mapping.Key) -> $($mapping.Value.url)" -ForegroundColor White
$cleanKey = $mapping.Key -replace " ", "-" -replace "\(|\)", ""
$jsContent += "`n '$cleanKey': '$($mapping.Value.url)',"
}
$jsContent += "`n};"
# Save URL mapping to file
$jsContent | Out-File -FilePath "src/js/azure-video-urls.js" -Encoding UTF8
Write-Host "`nβ
Video URLs saved to: src/js/azure-video-urls.js" -ForegroundColor Green
# Update the Azure video manager
Write-Host "π Updating Azure Video Manager..." -ForegroundColor Yellow
Write-Host "`nπ Upload Complete!" -ForegroundColor Green
Write-Host "Next steps:" -ForegroundColor Yellow
Write-Host "1. Run 'azd deploy' to update your website" -ForegroundColor White
Write-Host "2. Your videos are now hosted on Azure with global CDN! π" -ForegroundColor White
Write-Host "3. Website URL: https://lively-sand-04980360f.1.azurestaticapps.net" -ForegroundColor Cyan
# Test a video URL
$firstVideo = $uploadedUrls.Values | Select-Object -First 1
if ($firstVideo) {
Write-Host "`nπ Testing video accessibility..." -ForegroundColor Yellow
try {
$response = Invoke-WebRequest -Uri $firstVideo.url -Method Head -TimeoutSec 10
if ($response.StatusCode -eq 200) {
Write-Host "β
Videos are accessible and ready!" -ForegroundColor Green
}
} catch {
Write-Host "β οΈ Videos uploaded but may take a moment to be accessible" -ForegroundColor Yellow
}
}
} else {
Write-Host "`nβ No videos were uploaded successfully." -ForegroundColor Red
Write-Host "Please check your Azure login and permissions." -ForegroundColor Yellow
}
Write-Host "`nπ Script completed." -ForegroundColor Cyan