@@ -173,6 +173,10 @@ function Get-ID {
173
173
else { $queryID = $query.results [0 ].id }
174
174
175
175
if ($queryID ) {
176
+ if ($queryID.Count -gt 1 ) {
177
+ Write-Host " More than 1 ID returned. Selecting the first option"
178
+ $queryID = $queryID [0 ]
179
+ }
176
180
Write-Host " ID successfully retrieved! ID: " - NoNewline
177
181
Write-Host $queryID @progressColors
178
182
if (' TMDbID' -in $SkipProperties ) {
@@ -210,10 +214,12 @@ function Get-Metadata {
210
214
}
211
215
else { $obj = @ {} }
212
216
213
- # Pull general info including IMDb ID
217
+ # Pull general info to collect other props
218
+ $genQuery = Invoke-RestMethod - Uri " https://api.themoviedb.org/3/movie/$ ( $id ) ?api_key=$ ( $APIKey ) " - Method GET
219
+
220
+ # Pull IMDb ID
214
221
if (' IMDbID' -notin $SkipProperties ) {
215
222
Write-Host " Requesting IMDB ID..."
216
- $genQuery = Invoke-RestMethod - Uri " https://api.themoviedb.org/3/movie/$ ( $id ) ?api_key=$ ( $APIKey ) " - Method GET
217
223
if ($imdbID = $genQuery | Select-Object - ExpandProperty imdb_id) {
218
224
Write-Host " IMDb ID successfully retrieved! ID: " - NoNewline
219
225
Write-Host $imdbID @progressColors
@@ -224,7 +230,7 @@ function Get-Metadata {
224
230
Write-Warning " Failed to retrieve IMDb ID. Property will be skipped"
225
231
}
226
232
}
227
- else { Write-Host " Skipping IMDb ID..." @warnColors }
233
+ else { Write-Host " Skipping IMDb ID..." @warnColors }
228
234
229
235
Write-Host " ---------------------------------------------" @dividerColor
230
236
@@ -366,6 +372,16 @@ function New-XMLTagFile {
366
372
# Main Script Logic #
367
373
# ########################################################
368
374
375
+ if (! $APIKey ) {
376
+ $params = @ {
377
+ CategoryActivity = ' MKV Tag Generator'
378
+ Category = ' InvalidArgument'
379
+ Message = " MatroskaTagGenerator: An API key is required"
380
+ ErrorId = 77
381
+ }
382
+ Write-Error " MatroskaTagGenerator: An API key is required" - ErrorAction Stop
383
+ }
384
+
369
385
if ($Path.EndsWith (' .xml' )) {
370
386
$outXML = $Path
371
387
}
0 commit comments