diff --git a/.github/ISSUE_TEMPLATE/installer-new-translation.yml b/.github/ISSUE_TEMPLATE/installer-new-translation.yml index bb48a75..5955293 100644 --- a/.github/ISSUE_TEMPLATE/installer-new-translation.yml +++ b/.github/ISSUE_TEMPLATE/installer-new-translation.yml @@ -40,7 +40,6 @@ body: Download3 = "Error again" Download4 = "Check your network settings and run the installation again" Download5 = "Downloading Spotify" - Download6 = "Curl error" StopScript = "Script is stopped" MsSpoti = "The Microsoft Store version of Spotify has been detected which is not supported" MsSpoti2 = "Uninstall Spotify Microsoft Store edition [Y/N]" @@ -67,11 +66,6 @@ body: UpdBlock = "Spotify updates blocked" UpdUnblock = "Spotify updates are not blocked" UpdSelect = "Want to block Spotify updates? [Y/N]" - CacheOn = "Audio cache cleaning is enabled ({0})" - CacheOff = "Audio cache cleaning is not enabled" - CacheSelect = "Do you want to install automatic audio cache cleaning for Spotify? [Y/N]" - CacheDays = "A cache that has not been used for more than the number of days specified by you will be deleted" - CacheDays2 = "Enter the number of days from 1 to 100" ModSpoti = "Patching Spotify..." Error = "Error" FileLocBroken = "Location of Spotify files is broken, uninstall Spotify client and run the script again" diff --git a/Install.ps1 b/Install.ps1 index 49b1c92..729d44b 100644 --- a/Install.ps1 +++ b/Install.ps1 @@ -15,14 +15,9 @@ param [Parameter(HelpMessage = 'Do not block Spotify automatic updates.')] [switch]$block_update_off, - [Parameter(HelpMessage = 'Enable clear cache.')] - [switch]$cache_on, - - [Parameter(HelpMessage = 'Specify the number of days. Default is 7 days.')] - [int16]$number_days = 7, - - [Parameter(HelpMessage = 'Do not enable cache clearing.')] - [switch]$cache_off, + [Parameter(HelpMessage = 'Change limit for clearing audio cache.')] + [Alias('cl')] + [int]$cache_limit, [Parameter(HelpMessage = 'Automatic uninstallation of Spotify MS if it was found.')] [switch]$confirm_uninstall_ms_spoti, @@ -233,7 +228,6 @@ $spotifyDirectory = Join-Path $env:APPDATA 'Spotify' $spotifyDirectory2 = Join-Path $env:LOCALAPPDATA 'Spotify' $spotifyExecutable = Join-Path $spotifyDirectory 'Spotify.exe' $exe_bak = Join-Path $spotifyDirectory 'Spotify.bak' -$cache_folder = Join-Path $env:APPDATA 'Spotify\cache' $spotifyUninstall = Join-Path $env:TEMP 'SpotifyUninstall.exe' $start_menu = Join-Path $env:APPDATA 'Microsoft\Windows\Start Menu\Programs\Spotify.lnk' @@ -363,59 +357,37 @@ function Unlock-Folder { } } -function downloadScripts($param1) { +function downloadSp() { $webClient = New-Object -TypeName System.Net.WebClient - if ($param1 -eq "Desktop") { - Import-Module BitsTransfer + Import-Module BitsTransfer - $links = "https://download.scdn.co/upgrade/client/win32-x86/spotify_installer-$onlineFull.exe" - } - if ($ru -and $param1 -eq "cache-spotify") { - $links2 = "https://raw.githubusercontent.com/amd64fox/SpotX/main/scripts/cache/cache_spotify_ru.ps1" - } - if (!($ru) -and $param1 -eq "cache-spotify" ) { - $links2 = "https://raw.githubusercontent.com/amd64fox/SpotX/main/scripts/cache/cache_spotify.ps1" - } + $web_Url = "https://download.scdn.co/upgrade/client/win32-x86/spotify_installer-$onlineFull.exe" + $local_Url = "$PWD\SpotifySetup.exe" + $web_name_file = "SpotifySetup.exe" + + try { if (curl.exe -V) { $curl_check = $true } } + catch { $curl_check = $false } - $web_Url_prev = $links, $links2, "https://raw.githubusercontent.com/amd64fox/SpotX/main/scripts/cache/hide_window.vbs", ` - "https://raw.githubusercontent.com/amd64fox/SpotX/main/scripts/cache/run_ps.bat" - - $local_Url_prev = "$PWD\SpotifySetup.exe", "$cache_folder\cache_spotify.ps1", "$cache_folder\hide_window.vbs", "$cache_folder\run_ps.bat" - $web_name_file_prev = "SpotifySetup.exe", "cache_spotify.ps1", "hide_window.vbs", "run_ps.bat" - - switch ( $param1 ) { - "Desktop" { $web_Url = $web_Url_prev[0]; $local_Url = $local_Url_prev[0]; $web_name_file = $web_name_file_prev[0] } - "cache-spotify" { $web_Url = $web_Url_prev[1]; $local_Url = $local_Url_prev[1]; $web_name_file = $web_name_file_prev[1] } - "hide_window" { $web_Url = $web_Url_prev[2]; $local_Url = $local_Url_prev[2]; $web_name_file = $web_name_file_prev[2] } - "run_ps" { $web_Url = $web_Url_prev[3]; $local_Url = $local_Url_prev[3]; $web_name_file = $web_name_file_prev[3] } - } - - if ($param1 -eq "Desktop") { - try { if (curl.exe -V) { $curl_check = $true } } - catch { $curl_check = $false } - } try { - if ($param1 -eq "Desktop" -and $curl_check) { + if ($curl_check) { $stcode = curl.exe -s -w "%{http_code}" -o /dev/null $web_Url --retry 2 --ssl-no-revoke - if ($stcode -ne "200") { throw ($lang).Download6 } + if ($stcode -ne "200") { + Write-Host "Curl error code: $stcode"; throw + } curl.exe $web_Url -o $local_Url --progress-bar --retry 3 --ssl-no-revoke return } - if ($param1 -eq "Desktop" -and !($curl_check ) -and $null -ne (Get-Module -Name BitsTransfer -ListAvailable)) { + if (!($curl_check ) -and $null -ne (Get-Module -Name BitsTransfer -ListAvailable)) { $ProgressPreference = 'Continue' Start-BitsTransfer -Source $web_Url -Destination $local_Url -DisplayName ($lang).Download5 -Description "$online " return } - if ($param1 -eq "Desktop" -and !($curl_check ) -and $null -eq (Get-Module -Name BitsTransfer -ListAvailable)) { + if (!($curl_check ) -and $null -eq (Get-Module -Name BitsTransfer -ListAvailable)) { $webClient.DownloadFile($web_Url, $local_Url) return } - if ($param1 -ne "Desktop") { - $ProgressPreference = 'SilentlyContinue' # Hiding Progress Bars - $webClient.DownloadFile($web_Url, $local_Url) - } } catch { @@ -427,24 +399,22 @@ function downloadScripts($param1) { Start-Sleep -Milliseconds 5000 try { - if ($param1 -eq "Desktop" -and $curl_check) { + if ($curl_check) { $stcode = curl.exe -s -w "%{http_code}" -o /dev/null $web_Url --retry 2 --ssl-no-revoke - if ($stcode -ne "200") { throw ($lang).Download6 } + if ($stcode -ne "200") { + Write-Host "Curl error code: $stcode"; throw + } curl.exe $web_Url -o $local_Url --progress-bar --retry 3 --ssl-no-revoke return } - if ($param1 -eq "Desktop" -and $null -ne (Get-Module -Name BitsTransfer -ListAvailable) -and !($curl_check )) { - Start-BitsTransfer -Source $web_Url -Destination $local_Url -DisplayName ($lang).Download5 -Description "$vernew " + if (!($curl_check ) -and $null -ne (Get-Module -Name BitsTransfer -ListAvailable) -and !($curl_check )) { + Start-BitsTransfer -Source $web_Url -Destination $local_Url -DisplayName ($lang).Download5 -Description "$online " return } - if ($param1 -eq "Desktop" -and $null -eq (Get-Module -Name BitsTransfer -ListAvailable) -and !($curl_check )) { + if (!($curl_check ) -and $null -eq (Get-Module -Name BitsTransfer -ListAvailable) -and !($curl_check )) { $webClient.DownloadFile($web_Url, $local_Url) return } - if ($param1 -ne "Desktop") { - $webClient.DownloadFile($web_Url, $local_Url) - } - } catch { @@ -466,7 +436,6 @@ function downloadScripts($param1) { function DesktopFolder { # If the default Dekstop folder does not exist, then try to find it through the registry. - $ErrorActionPreference = 'SilentlyContinue' if (Test-Path "$env:USERPROFILE\Desktop") { $desktop_folder = "$env:USERPROFILE\Desktop" @@ -745,11 +714,11 @@ if (-not $spotifyInstalled -or $upgrade_client) { Start-Sleep -Milliseconds 600 Unlock-Folder | Out-Null Start-Sleep -Milliseconds 200 - Get-ChildItem $spotifyDirectory -Exclude 'Users', 'prefs', 'cache' | Remove-Item -Recurse -Force + Get-ChildItem $spotifyDirectory -Exclude 'Users', 'prefs' | Remove-Item -Recurse -Force Start-Sleep -Milliseconds 200 # Client download - downloadScripts -param1 "Desktop" + downloadSp Write-Host "" Start-Sleep -Milliseconds 200 @@ -834,53 +803,6 @@ if ($ch -eq 'n') { $ch = $null -if ($cache_on) { - Write-Host (($lang).CacheOn -f $number_days)`n - $cache_install = $true -} -if ($cache_off) { - Write-Host ($lang).CacheOff`n - $ErrorActionPreference = 'SilentlyContinue' - $desktop_folder = DesktopFolder - if (Test-Path -LiteralPath $cache_folder) { - remove-item $cache_folder -Recurse -Force - remove-item $desktop_folder\Spotify.lnk -Recurse -Force - remove-item $start_menu -Recurse -Force - } -} -if (!($cache_on) -and !($cache_off)) { - - do { - $ch = Read-Host -Prompt ($lang).CacheSelect - Write-Host "" - if (!($ch -eq 'n' -or $ch -eq 'y')) { incorrectValue } - } - while ($ch -notmatch '^y$|^n$') - - if ($ch -eq 'y') { - $cache_install = $true - - do { - Write-Host ($lang).CacheDays - $ch = Read-Host -Prompt ($lang).CacheDays2 - Write-Host "" - if (!($ch -match "^[1-9][0-9]?$|^100$")) { incorrectValue } - } - while ($ch -notmatch '^[1-9][0-9]?$|^100$') - - if ($ch -match "^[1-9][0-9]?$|^100$") { $number_days = $ch } - } - if ($ch -eq 'n') { - $ErrorActionPreference = 'SilentlyContinue' - $desktop_folder = DesktopFolder - if (Test-Path -LiteralPath $cache_folder) { - remove-item $cache_folder -Recurse -Force - remove-item $desktop_folder\Spotify.lnk -Recurse -Force - remove-item $start_menu -Recurse -Force - } - } -} - $url = "https://raw.githubusercontent.com/amd64fox/SpotX/main/patches/patches.json" $retries = 0 @@ -1002,11 +924,11 @@ function Helper($paramname) { } "ForcedExp" { # Forced disable some exp (xpui.js) - $offline_patch = $offline -replace '(\d+\.\d+\.\d+)(.\d+)', '$1' $remEnable = $webjson.others.EnableExp.psobject.properties $remCustom = $webjson.others.CustomExp.psobject.properties - + + $remEnable.remove('WhatsNewFeed') if ($enhance_like_off) { $remEnable.remove('EnhanceLikedSongs') } if ($enhance_playlist_off) { $remEnable.remove('EnhancePlaylist') } # Old theme @@ -1024,6 +946,7 @@ function Helper($paramname) { } if (!$premium) { $remEnable.remove('RemoteDownloads') } + # Disable unimportant exp if ($exp_spotify) { $objects = @( @{ @@ -1044,6 +967,7 @@ function Helper($paramname) { } } + $Exp = ($webjson.others.EnableExp, $webjson.others.DisableExp, $webjson.others.CustomExp) foreach ($item in $Exp) { @@ -1076,14 +1000,12 @@ function Helper($paramname) { $custname = $webjson.others.CustomExp.$item.name $custvalue = $webjson.others.CustomExp.$item.value - # Создаем строку с нужным форматом + # Create a string with the desired format $objectString = "{name:'$custname',value:'$custvalue'}" - - # Выводим строку $objectString } - # Преобразуем строки объектов в одну текстовую строку + # Convert the strings of objects into a single text string if ([string]::IsNullOrEmpty($customNames)) { $customTextVariable = '[]' } else { $customTextVariable = "[" + ($customNames -join ',') + "]" } if ([string]::IsNullOrEmpty($enableNames)) { $enableTextVariable = '[]' } @@ -1149,6 +1071,7 @@ function Helper($paramname) { $json = $webjson.others } "VariousofXpui-js" { + $rem = $webjson.VariousJs.psobject.properties if ($urlform_goofy -and $idbox_goofy) { @@ -1158,6 +1081,27 @@ function Helper($paramname) { if (!($ru)) { $rem.remove('offrujs') } + if (!($premium) -or ($cache_limit)) { + if (!($premium)) { + $adds += $webjson.VariousJs.product_state.add + } + + if ($cache_limit) { + + if ($cache_limit -lt 500) { $cache_limit = 500 } + if ($cache_limit -gt 20000) { $cache_limit = 20000 } + + $adds2 = $webjson.VariousJs.product_state.add2 + if (!([string]::IsNullOrEmpty($adds))) { $adds2 = ',' + $adds2 } + $adds += $adds2 -f $cache_limit + + } + + $repl = $webjson.VariousJs.product_state.replace + $webjson.VariousJs.product_state.replace = $repl -f "{pairs:{$adds}}" + + } + $name = "patches.json.VariousJs." $n = "xpui.js" $contents = $webjson.VariousJs.psobject.properties.name @@ -1266,7 +1210,6 @@ function extract ($counts, $method, $name, $helper, $add, $patch) { Write-Host ($lang).ModSpoti`n - $tempDirectory = $PWD Pop-Location @@ -1540,65 +1483,7 @@ extract -counts 'exe' -helper 'PodcastAd' # Block updates if ($block_update) { extract -counts 'exe' -helper 'BlockUpdate' } -# Automatic cache clearing -if ($cache_install) { - Start-Sleep -Milliseconds 200 - New-Item -Path $env:APPDATA\Spotify\ -Name "cache" -ItemType "directory" | Out-Null - - # Download cache script - downloadScripts -param1 "cache-spotify" - downloadScripts -param1 "hide_window" - downloadScripts -param1 "run_ps" - - - # Create a desktop shortcut - if (!($no_shortcut)) { - $source2 = "$cache_folder\hide_window.vbs" - $target2 = "$desktop_folder\Spotify.lnk" - $WorkingDir2 = "$cache_folder" - $WshShell2 = New-Object -comObject WScript.Shell - $Shortcut2 = $WshShell2.CreateShortcut($target2) - $Shortcut2.WorkingDirectory = $WorkingDir2 - $Shortcut2.IconLocation = Join-Path $env:APPDATA 'Spotify\Spotify.exe' - $Shortcut2.TargetPath = $source2 - $Shortcut2.Save() - } - # Create shortcut in start menu - $source2 = "$cache_folder\hide_window.vbs" - $target2 = $start_menu - $WorkingDir2 = "$cache_folder" - $WshShell2 = New-Object -comObject WScript.Shell - $Shortcut2 = $WshShell2.CreateShortcut($target2) - $Shortcut2.WorkingDirectory = $WorkingDir2 - $Shortcut2.IconLocation = Join-Path $env:APPDATA 'Spotify\Spotify.exe' - $Shortcut2.TargetPath = $source2 - $Shortcut2.Save() - - if ($number_days -match "^[1-9][0-9]?$|^100$") { - $file_cache_spotify_ps1 = Get-Content $cache_folder\cache_spotify.ps1 -Raw - $new_file_cache_spotify_ps1 = $file_cache_spotify_ps1 -replace '7', $number_days - Set-Content -Path $cache_folder\cache_spotify.ps1 -Force -Value $new_file_cache_spotify_ps1 - $contentcache_spotify_ps1 = [System.IO.File]::ReadAllText("$cache_folder\cache_spotify.ps1") - $contentcache_spotify_ps1 = $contentcache_spotify_ps1.Trim() - [System.IO.File]::WriteAllText("$cache_folder\cache_spotify.ps1", $contentcache_spotify_ps1) - - $infile = "$cache_folder\cache_spotify.ps1" - $outfile = "$cache_folder\cache_spotify2.ps1" - - $sr = New-Object System.IO.StreamReader($infile) - $sw = New-Object System.IO.StreamWriter($outfile, $false, [System.Text.Encoding]::Default) - $sw.Write($sr.ReadToEnd()) - $sw.Close() - $sr.Close() - $sw.Dispose() - $sr.Dispose() - - Start-Sleep -Milliseconds 200 - Remove-item $infile -Recurse -Force - Rename-Item -path $outfile -NewName $infile - } -} - +# Start Spotify if ($start_spoti) { Start-Process -WorkingDirectory $spotifyDirectory -FilePath $spotifyExecutable } -Write-Host ($lang).InstallComplete`n -ForegroundColor Green +Write-Host ($lang).InstallComplete`n -ForegroundColor Green \ No newline at end of file diff --git a/LICENSE b/LICENSE index 04b3472..35c8826 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2021-2022 amd64fox +Copyright (c) 2021-2023 amd64fox Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 7f8d93f..eddf908 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,7 @@ or #### Usual installation only without ad blocking, for those who have a premium account, also contains: - New theme activated (new right and left sidebar, some cover change) + - Disabled only audio ads in podcasts - All [experimental features](https://github.com/amd64fox/SpotX/discussions/50) included

diff --git a/Uninstall.bat b/Uninstall.bat index f302a32..aa4af2f 100644 --- a/Uninstall.bat +++ b/Uninstall.bat @@ -26,25 +26,11 @@ if exist "%Appdata%\Spotify\blockthespot_log.txt" ( del /s /q "%Appdata%\Spotify\blockthespot_log.txt" > NUL 2>&1 ) -if exist "%Appdata%\Spotify\cache" ( - rd /s /q %Appdata%\Spotify\cache > NUL 2>&1 - -SET Esc_LinkDest=%Userprofile%\Desktop\Spotify.lnk -SET Esc_LinkTarget=%Appdata%\Spotify\Spotify.exe -SET Esc_WorkLinkTarget=%Appdata%\Spotify\ -SET cSctVBS=CreateShortcut.vbs -(( -echo Set oWS = WScript.CreateObject^("WScript.Shell"^) -echo sLinkFile = oWS.ExpandEnvironmentStrings^("!Esc_LinkDest!"^) -echo Set oLink = oWS.CreateShortcut^(sLinkFile^) -echo oLink.TargetPath = oWS.ExpandEnvironmentStrings^("!Esc_LinkTarget!"^) -echo oLink.WorkingDirectory = oWS.ExpandEnvironmentStrings^("!Esc_WorkLinkTarget!"^) -echo oLink.Save -)1>!cSctVBS! -cscript !cSctVBS! -DEL !cSctVBS! /f /q +if exist "%temp%\SpotX_Temp*" ( + for /d %%i in ("%temp%\SpotX_Temp*") do ( + rd /s/q "%%i" > NUL 2>&1 + ) ) -) echo Patch successfully removed pause diff --git a/patches/patches.json b/patches/patches.json index 5a749fe..582e338 100644 --- a/patches/patches.json +++ b/patches/patches.json @@ -1,13 +1,5 @@ { "free": { - "EsperantoAds": { - "version": { - "fr": "1.1.93", - "to": "" - }, - "match": "(this._product_state=(.))", - "replace": "$1,$2.putOverridesValues({pairs:{ads:'0',catalogue:'premium',product:'premium',name:'Spotify'}})" - }, "bilboard": { "version": { "fr": "1.1.70", @@ -940,6 +932,16 @@ } }, "VariousJs": { + "product_state": { + "version": { + "fr": "1.1.93", + "to": "" + }, + "match": "(this._product_state=(.))", + "replace": "$1,$2.putOverridesValues({0})", + "add": "ads:'0',catalogue:'premium',product:'premium',type:'premium',name:'Spotify'", + "add2": "'storage-size-config':'{0},90,500,3'" + }, "offrujs": { "version": { "fr": "1.1.92", diff --git a/scripts/Install_Auto.bat b/scripts/Install_Auto.bat index a1cca46..be285a1 100644 --- a/scripts/Install_Auto.bat +++ b/scripts/Install_Auto.bat @@ -1,6 +1,6 @@ @echo off -%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\powershell.exe -Command "&{[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12}; """"& { $((Invoke-WebRequest -UseBasicParsing 'https://raw.githubusercontent.com/amd64fox/SpotX/main/Install.ps1').Content)} -confirm_uninstall_ms_spoti -confirm_spoti_recomended_over -podcasts_off -cache_off -block_update_on -start_spoti -new_theme -adsections_off -lyrics_stat spotify """" | Invoke-Expression" +%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\powershell.exe -Command "&{[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12}; """"& { $((Invoke-WebRequest -UseBasicParsing 'https://raw.githubusercontent.com/amd64fox/SpotX/main/Install.ps1').Content)} -confirm_uninstall_ms_spoti -confirm_spoti_recomended_over -podcasts_off -block_update_on -start_spoti -new_theme -adsections_off -lyrics_stat spotify """" | Invoke-Expression" pause exit /b \ No newline at end of file diff --git a/scripts/cache/cache_spotify.ps1 b/scripts/cache/cache_spotify.ps1 deleted file mode 100644 index ac05b16..0000000 --- a/scripts/cache/cache_spotify.ps1 +++ /dev/null @@ -1,43 +0,0 @@ -<# -Name: Clear Spotify Cache. - -Description: The script clears outdated cache from the listened music in Spotify. -Fires every time you completely close the client (If the client was minimized to tray then the script will not work). - -For the APPDATA\Spotify\Data folder, the rule is that all cache files that are not used -by the customer more than the specified number of days will be deleted. - -#> - -$day = 7 # Number of days after which the cache is considered stale - -# Clear the \Data folder if it finds an outdated cache -try { - $SpotifyData = Join-Path -Path $env:LOCALAPPDATA -ChildPath "Spotify\Data" - If (!(Test-Path -Path $SpotifyData)) { - "$(Get-Date -Format "dd/MM/yyyy HH:mm:ss") Folder Local\Spotify\Data not found" | Out-File log.txt -append - exit - } - $check = Get-ChildItem $SpotifyData -File -Recurse | Where-Object lastaccesstime -lt (get-date).AddDays(-$day) - if ($check.Length -ge 1) { - - $count = $check - $sum = $count | Measure-Object -Property Length -sum - if ($sum.Sum -ge 1044344824) { - $gb = "{0:N2} Gb" -f (($check | Measure-Object Length -s).sum / 1Gb) - "$(Get-Date -Format "dd/MM/yyyy HH:mm:ss") Removed $gb obsolete cache" | Out-File log.txt -append - } - else { - $mb = "{0:N2} Mb" -f (($check | Measure-Object Length -s).sum / 1Mb) - "$(Get-Date -Format "dd/MM/yyyy HH:mm:ss") Removed $mb obsolete cache" | Out-File log.txt -append - } - Get-ChildItem $SpotifyData -File -Recurse | Where-Object lastaccesstime -lt (get-date).AddDays(-$day) | Remove-Item - } - if ($check.Length -lt 1) { - "$(Get-Date -Format "dd/MM/yyyy HH:mm:ss") Stale cache not found" | Out-File log.txt -append - } -} -catch { - "$(Get-Date -Format "dd/MM/yyyy HH:mm:ss") $error[0].Exception" | Out-File log.txt -append -} -exit diff --git a/scripts/cache/cache_spotify_ru.ps1 b/scripts/cache/cache_spotify_ru.ps1 deleted file mode 100644 index 4239c8e..0000000 --- a/scripts/cache/cache_spotify_ru.ps1 +++ /dev/null @@ -1,44 +0,0 @@ -<# -Имя: Очистка кеша Spotify. - -Описание: Скрипт очищает устаревший кеш от прослушанной музыки в Spotify. -Срабатывает каждый раз когда вы полностью закрываете клиент (Если клиент был свернут в трей то скрипт не сработает). - -Для папки APPDATA\Spotify\Data действует правило, все файлы кеша которые не использовались -клиентом больше указанного количества дней будут удалены. - -#> - -$day = 7 # Количество дней после которых кеш считается устаревшим - -# Очищаем папку \Data если был найден устаревший кеш - -try { - $SpotifyData = Join-Path -Path $env:LOCALAPPDATA -ChildPath "Spotify\Data" - If (!(Test-Path -Path $SpotifyData)) { - "$(Get-Date -Format "dd/MM/yyyy HH:mm:ss") Папка Local\Spotify\Data не найдена" | Out-File log.txt -append - exit - } - $check = Get-ChildItem $SpotifyData -File -Recurse | Where-Object lastaccesstime -lt (get-date).AddDays(-$day) - if ($check.Length -ge 1) { - - $count = $check - $sum = $count | Measure-Object -Property Length -sum - if ($sum.Sum -ge 1044344824) { - $gb = "{0:N2} Gb" -f (($check | Measure-Object Length -s).sum / 1Gb) - "$(Get-Date -Format "dd/MM/yyyy HH:mm:ss") Удалено $gb устаревшего кеша" | Out-File log.txt -append - } - else { - $mb = "{0:N2} Mb" -f (($check | Measure-Object Length -s).sum / 1Mb) - "$(Get-Date -Format "dd/MM/yyyy HH:mm:ss") Удалено $mb устаревшего кеша" | Out-File log.txt -append - } - Get-ChildItem $SpotifyData -File -Recurse | Where-Object lastaccesstime -lt (get-date).AddDays(-$day) | Remove-Item - } - if ($check.Length -lt 1) { - "$(Get-Date -Format "dd/MM/yyyy HH:mm:ss") Устаревшего кеша не найдено" | Out-File log.txt -append - } -} -catch { - "$(Get-Date -Format "dd/MM/yyyy HH:mm:ss") $error[0].Exception" | Out-File log.txt -append -} -exit diff --git a/scripts/cache/hide_window.vbs b/scripts/cache/hide_window.vbs deleted file mode 100644 index c27e91a..0000000 --- a/scripts/cache/hide_window.vbs +++ /dev/null @@ -1,3 +0,0 @@ -Set WshShell = CreateObject("WScript.Shell") -WshShell.Run chr(34) & "%Appdata%\Spotify\cache\run_ps.bat" & Chr(34), 0 -Set WshShell = Nothing \ No newline at end of file diff --git a/scripts/cache/run_ps.bat b/scripts/cache/run_ps.bat deleted file mode 100644 index e9dd421..0000000 --- a/scripts/cache/run_ps.bat +++ /dev/null @@ -1,3 +0,0 @@ -@echo off -start "" /wait "%Appdata%\Spotify\Spotify.exe" -powershell.exe -ExecutionPolicy Bypass -nologo -noninteractive -command "& '.\cache_spotify.ps1'" \ No newline at end of file diff --git a/scripts/installer-lang/en.ps1 b/scripts/installer-lang/en.ps1 index df5e448..6c9c030 100644 --- a/scripts/installer-lang/en.ps1 +++ b/scripts/installer-lang/en.ps1 @@ -10,7 +10,6 @@ Download3 = "Error again" Download4 = "Check your network settings and run the installation again" Download5 = "Downloading Spotify" - Download6 = "Curl error" StopScript = "Script is stopped" MsSpoti = "The Microsoft Store version of Spotify has been detected which is not supported" MsSpoti2 = "Uninstall Spotify Microsoft Store edition [Y/N]" @@ -37,11 +36,6 @@ UpdBlock = "Spotify updates blocked" UpdUnblock = "Spotify updates are not blocked" UpdSelect = "Want to block Spotify updates? [Y/N]" - CacheOn = "Audio cache cleaning is enabled ({0})" - CacheOff = "Audio cache cleaning is not enabled" - CacheSelect = "Do you want to install automatic audio cache cleaning for Spotify? [Y/N]" - CacheDays = "A cache that has not been used for more than the number of days specified by you will be deleted" - CacheDays2 = "Enter the number of days from 1 to 100" ModSpoti = "Patching Spotify..." Error = "Error" FileLocBroken = "Location of Spotify files is broken, uninstall Spotify client and run the script again" diff --git a/scripts/installer-lang/ru.ps1 b/scripts/installer-lang/ru.ps1 index 8f25949..ea684d3 100644 --- a/scripts/installer-lang/ru.ps1 +++ b/scripts/installer-lang/ru.ps1 @@ -10,7 +10,6 @@ Download3 = "Опять ошибка" Download4 = "Проверьте настройки вашей сети и снова запустите установку" Download5 = "Загрузка Spotify" - Download6 = "Curl error" StopScript = "Cкрипт остановлен" MsSpoti = "Обнаружена версия Spotify из Microsoft Store, которая не поддерживается" MsSpoti2 = "Хотите удалить Spotify Microsoft Store ? [Y/N]" @@ -37,11 +36,6 @@ UpdBlock = "Обновления Spotify заблокированы" UpdUnblock = "Обновления Spotify не заблокированы" UpdSelect = "Хотите заблокировать обновления Spotify ? [Y/N]" - CacheOn = "Очистка аудио-кеша включена ({0})" - CacheOff = "Очистка аудио-кеша не включена" - CacheSelect = "Хотите установить автоматическую очистку аудио-кеша Spotify ? [Y/N]" - CacheDays = "Кеш, который не использовался больше указанного вами количества дней, будет удален" - CacheDays2 = "Пожалуйста, введите количество дней от 1 до 100" ModSpoti = "Модифицирую Spotify..." Error = "Ошибка" FileLocBroken = "Расположение файлов Spotify нарушено, удалите клиент Spotify и снова запустите скрипт"