@@ -40,6 +40,9 @@ chcp 65001 > $null
4040$LangConfigFile = " .\MainApp\Lang_Config.txt"
4141$Global :CurrentLang = " RU"
4242
43+ # Глобальная переменная для кэширования списка с GitHub:
44+ $Global :GitHubRawList = $null
45+
4346# Загрузка сохраненного языка или установка по умолчанию:
4447if (Test-Path $LangConfigFile ) {
4548 $SavedLang = (Get-Content $LangConfigFile - Raw).Trim().ToUpper()
@@ -98,7 +101,6 @@ $LangStrings = @{
98101 " Menu9" = " 9. Выход из аккаунта Apple ID"
99102 " Menu10" = " 10. Страница проекта на GitHub"
100103 " Menu11" = " 11. Сменить язык (Change Language)"
101- " MenuCancel" = " 0. Отмена (Возврат в главное меню)"
102104 " MenuTitle" = " Введите команду:"
103105 " MinIOS" = " Минимальная версия iOS:"
104106 " NoAppsFound" = " Приложения не найдены."
@@ -152,7 +154,6 @@ $LangStrings = @{
152154 " Menu9" = " 9. Log out of Apple ID account"
153155 " Menu10" = " 10. GitHub project page"
154156 " Menu11" = " 11. Change Language (Сменить язык)"
155- " MenuCancel" = " 0. Cancel (Return to main menu)"
156157 " MenuTitle" = " Enter a command:"
157158 " MinIOS" = " Minimum iOS version:"
158159 " NoAppsFound" = " No applications found."
@@ -168,7 +169,7 @@ function Get-Lang($Key) {
168169}
169170
170171# Версия скрипта:
171- Write-Host " IPA_Downloader 3.7 " - ForegroundColor Black - BackgroundColor Yellow
172+ Write-Host " IPA_Downloader 3.8 " - ForegroundColor Black - BackgroundColor Yellow
172173
173174# Функция разделителя:
174175function Separator {
@@ -243,9 +244,12 @@ function Get-IPA-Metadata {
243244 $Zip = [System.IO.Compression.ZipFile ]::OpenRead($IpaPath )
244245 $PlistEntry = $Zip.Entries | Where-Object { $_.FullName -match ' Payload/.*\.app/Info\.plist$' } | Select-Object - First 1
245246 if ($PlistEntry ) {
246- $Reader = New-Object System.IO.StreamReader($PlistEntry.Open (), [System.Text.Encoding ]::UTF8)
247- $Content = $Reader.ReadToEnd ()
248- $Reader.Close ()
247+ try {
248+ $Reader = New-Object System.IO.StreamReader($PlistEntry.Open (), [System.Text.Encoding ]::UTF8)
249+ $Content = $Reader.ReadToEnd ()
250+ } finally {
251+ if ($null -ne $Reader ) { $Reader.Dispose () }
252+ }
249253
250254 if ($Content -match ' <key>CFBundleName</key>\s*<string>([^<]+)</string>' ) {
251255 $Metadata.AppName = $Matches [1 ]
@@ -322,9 +326,36 @@ function Save-App-To-History {
322326 Write-Host ((Get-Lang " AddedToList" ) -f $AppNameOnly , $AppId )
323327}
324328
329+ # Функция поиска имени приложения по ID в списке GitHub:
330+ function Get-GitHub-AppName {
331+ param ([string ]$AppId )
332+
333+ if ($null -eq $Global :GitHubRawList ) {
334+ try {
335+ $Global :GitHubRawList = Invoke-RestMethod - Uri " https://raw.githubusercontent.com/kda2495/IPA_Downloader/refs/heads/main/Apps_ID_List.txt" - ErrorAction SilentlyContinue
336+ } catch {
337+ $Global :GitHubRawList = " "
338+ }
339+ }
340+
341+ if (! [string ]::IsNullOrWhiteSpace($Global :GitHubRawList )) {
342+ $Lines = $Global :GitHubRawList -split " `n " | Where-Object { $_.Trim () -ne " " }
343+ foreach ($Line in $Lines ) {
344+ $IdMatch = [System.Text.RegularExpressions.Regex ]::Match($Line , ' \b\d{6,}\b' ).Value
345+ if ($IdMatch -eq $AppId -and $Line -match ' ^(.+?):\s*\d' ) {
346+ return $Matches [1 ].Trim()
347+ }
348+ }
349+ }
350+ return $null
351+ }
352+
325353# Функция перемещения и автоматического переименования:
326354function Move-IPA-Files {
327- param ([string ]$AppId )
355+ param (
356+ [string ]$AppId ,
357+ [string ]$AppName
358+ )
328359 $IPAFiles = Get-ChildItem - Filter " *.ipa"
329360 if ($IPAFiles ) {
330361 foreach ($File in $IPAFiles ) {
@@ -335,7 +366,22 @@ function Move-IPA-Files {
335366
336367 $Meta = Get-IPA - Metadata - IpaPath $DestPath
337368 if ($Meta ) {
338- $NewName = " $ ( $Meta.AppName ) _$ ( $Meta.Version ) _iOS $ ( $Meta.MinIOS ) +.ipa"
369+ $FinalAppName = $Meta.AppName
370+
371+ # Проверяем GitHub список, если имя неизвестно или не было передано:
372+ if ([string ]::IsNullOrWhiteSpace($AppName ) -or $AppName -eq " Unknown" ) {
373+ $GitHubName = Get-GitHub - AppName - AppId $AppId
374+ if (! [string ]::IsNullOrWhiteSpace($GitHubName )) {
375+ $AppName = $GitHubName
376+ }
377+ }
378+
379+ # Применяем найденное имя, очищая его от недопустимых символов:
380+ if (! [string ]::IsNullOrWhiteSpace($AppName ) -and $AppName -ne " Unknown" ) {
381+ $FinalAppName = $AppName -replace ' [\\/:*?"<>|]' , ' '
382+ }
383+
384+ $NewName = " $ ( $FinalAppName ) _$ ( $Meta.Version ) _iOS $ ( $Meta.MinIOS ) +.ipa"
339385 $TargetFile = Join-Path (Get-Location ) " .\Apps\$NewName "
340386
341387 if (Test-Path $TargetFile ) {
@@ -397,24 +443,31 @@ function Parse-NumberSelection {
397443}
398444
399445# Функция загрузки ipa-файлов:
400- function IPA-Download ($AppId ) {
446+ function IPA-Download {
447+ param (
448+ [string ]$AppId ,
449+ [string ]$AppName
450+ )
401451 if (! (Test-NumericInput - InputValue $AppId )) { return }
402452 Separator
403453 .\MainApp\ipatool.exe download - i $AppId -- purchase
404- Move-IPA - Files - AppId $AppId
454+ Move-IPA - Files - AppId $AppId - AppName $AppName
405455}
406456
407457# Функция загрузки ipa-файлов с выбором версии:
408- function IPA-Download-With-Version ($AppId ) {
458+ function IPA-Download-With-Version {
459+ param (
460+ [string ]$AppId ,
461+ [string ]$AppName
462+ )
409463 if (! (Test-NumericInput - InputValue $AppId )) { return }
410464
411465 Separator
412466 $RawOutput = .\MainApp\ipatool.exe list- versions - i $AppId 2>&1
413467
414468 # Проверяем, не вернула ли утилита ошибку лицензии или любую другую ошибку:
415469 if ($RawOutput -match " Error:" ) {
416- # Выводим ошибку тем цветом, который ты выберешь для системных ошибок скрипта:
417- Write-Host $RawOutput - ForegroundColor DarkRed
470+ Write-Host $RawOutput - ForegroundColor DarkRed
418471 return
419472 }
420473
@@ -471,14 +524,13 @@ function IPA-Download-With-Version($AppId) {
471524 return
472525 }
473526 .\MainApp\ipatool.exe download - i $AppId -- external- version- id $FinalId
474- Move-IPA - Files - AppId $AppId
527+ Move-IPA - Files - AppId $AppId - AppName $AppName
475528}
476529
477530# Функция получения списка выбранных приложений (поддерживает диапазоны и перечисления):
478531function Get-Apps-From-List {
479532 $List_Menu = @"
480- $ ( Get-Lang ' ListMenuTitle' )
481- $ ( Get-Lang ' MenuCancel' )
533+ $ ( Get-Lang ' ListMenuTitle' ) $ ( Get-Lang ' CancelStep' )
482534$ ( Get-Lang ' ListMenu1' )
483535$ ( Get-Lang ' ListMenu2' ) `n
484536"@
@@ -491,8 +543,10 @@ $(Get-Lang 'ListMenu2')`n
491543 switch ($ListChoice ) {
492544 " 1" {
493545 try {
494- $AppsIdList = Invoke-WebRequest " https://raw.githubusercontent.com/kda2495/IPA_Downloader/refs/heads/main/Apps_ID_List.txt" - UseBasicParsing - ErrorAction Stop | Select-Object - Expand Content
495- $Lines = $AppsIdList -split " `n " | Where-Object { $_.Trim () -ne " " }
546+ if ($null -eq $Global :GitHubRawList ) {
547+ $Global :GitHubRawList = Invoke-RestMethod - Uri " https://raw.githubusercontent.com/kda2495/IPA_Downloader/refs/heads/main/Apps_ID_List.txt" - ErrorAction Stop
548+ }
549+ $Lines = $Global :GitHubRawList -split " `n " | Where-Object { $_.Trim () -ne " " }
496550 } catch {
497551 Write-Host (Get-Lang " ErrorListLoadError" ) - ForegroundColor DarkRed
498552 return $null
@@ -554,7 +608,7 @@ $(Get-Lang 'ListMenu2')`n
554608 return $null
555609 }
556610
557- # Используем новую универсальную функцию:
611+ # Используем универсальную функцию:
558612 $SelectedIndices = Parse- NumberSelection - Selection $Selection - MaxCount $Lines.Count
559613
560614 if ($null -eq $SelectedIndices ) {
@@ -667,7 +721,7 @@ $(Get-Lang 'Menu11')`n
667721 $Selection = Read-Host " $ ( Get-Lang ' AskAppNum' ) (1-$ ( $FoundApps.Count ) ) $ ( Get-Lang ' CancelStep' ) `n "
668722 if ($Selection -eq ' 0' ) { continue }
669723
670- # Парсим как номера таблицы (поддержка 1, 3, 5-7) :
724+ # Парсим как номера таблицы:
671725 $Indices = Parse- NumberSelection - Selection $Selection - MaxCount $FoundApps.Count
672726 if ($null -eq $Indices ) {
673727 Separator
@@ -678,13 +732,13 @@ $(Get-Lang 'Menu11')`n
678732 $App = $FoundApps [$Idx - 1 ]
679733 Separator
680734 Write-Host " $ ( Get-Lang ' SelectedApp' ) $ ( $App.name ) "
681- IPA- Download $App.id
735+ IPA- Download - AppId $App.id - AppName $App .name
682736 }
683737 } else {
684738 # Если ничего не найдено, запрашиваем ввод ID:
685739 $AppId = Read-Host " $ ( Get-Lang ' AskIdDownload' ) $ ( Get-Lang ' CancelStep' ) `n "
686740 if ($AppId -eq ' 0' ) { continue }
687- IPA- Download $AppId
741+ IPA- Download - AppId $AppId
688742 }
689743 }
690744
@@ -693,15 +747,15 @@ $(Get-Lang 'Menu11')`n
693747 Separator
694748 $AppId = Read-Host " $ ( Get-Lang ' AskIdDownload' ) $ ( Get-Lang ' CancelStep' ) `n "
695749 if ($AppId -eq ' 0' ) { continue }
696- IPA- Download $AppId
750+ IPA- Download - AppId $AppId
697751 }
698752
699753 # 3. Ввод ID приложения и загрузка (с выбором версии):
700754 " 3" {
701755 Separator
702756 $AppId = Read-Host " $ ( Get-Lang ' AskIdSearch' ) $ ( Get-Lang ' CancelStep' ) `n "
703757 if ($AppId -eq ' 0' ) { continue }
704- IPA- Download- With- Version $AppId
758+ IPA- Download- With- Version - AppId $AppId
705759 }
706760
707761 # 4. Вывод списка ID приложений и загрузка последней версии:
@@ -712,7 +766,7 @@ $(Get-Lang 'Menu11')`n
712766 foreach ($App in $SelectedApps ) {
713767 Separator
714768 Write-Host " $ ( Get-Lang ' SelectedApp' ) $ ( $App.Name ) "
715- IPA- Download $App.Id
769+ IPA- Download - AppId $App.Id - AppName $App .Name
716770 }
717771 }
718772 }
@@ -725,7 +779,7 @@ $(Get-Lang 'Menu11')`n
725779 foreach ($App in $SelectedApps ) {
726780 Separator
727781 Write-Host " $ ( Get-Lang ' SelectedApp' ) $ ( $App.Name ) "
728- IPA- Download- With- Version $App.Id
782+ IPA- Download- With- Version - AppId $App.Id - AppName $App .Name
729783 }
730784 }
731785 }
@@ -752,8 +806,7 @@ $(Get-Lang 'Menu11')`n
752806 " 8" {
753807 Separator
754808 $Clear_Menu = @"
755- $ ( Get-Lang ' ClearMenuTitle' )
756- $ ( Get-Lang ' MenuCancel' )
809+ $ ( Get-Lang ' ClearMenuTitle' ) $ ( Get-Lang ' CancelStep' )
757810$ ( Get-Lang ' ClearMenu1' )
758811$ ( Get-Lang ' ClearMenu2' ) `n
759812"@
0 commit comments