Improve search algorithm
- multithreading replaced with asynchrony - minor fixes in the code
This commit is contained in:
parent
89a1196978
commit
d28b01fde0
5 changed files with 132 additions and 1175 deletions
238
LoaderSpot.py
238
LoaderSpot.py
|
|
@ -1,129 +1,153 @@
|
|||
import re
|
||||
import requests
|
||||
from concurrent.futures import ThreadPoolExecutor
|
||||
import aiohttp
|
||||
import asyncio
|
||||
from tqdm import tqdm
|
||||
|
||||
|
||||
def check_url(url, platform_name):
|
||||
async def check_url(session, url, platform_name):
|
||||
try:
|
||||
response = requests.get(url)
|
||||
if response.status_code == 200:
|
||||
if platform_name:
|
||||
return response.url, platform_name
|
||||
else:
|
||||
return response.url
|
||||
else:
|
||||
print(f"\nInvalid link: {url}")
|
||||
response.close()
|
||||
except requests.exceptions.RequestException:
|
||||
async with session.get(url) as response:
|
||||
if response.status == 200:
|
||||
if platform_name:
|
||||
return response.url, platform_name
|
||||
else:
|
||||
return response.url
|
||||
except aiohttp.ClientError:
|
||||
pass
|
||||
return None
|
||||
|
||||
|
||||
version_spoti = ""
|
||||
while not re.match(r"^\d+\.\d+\.\d+\.\d+\.g[0-9a-f]{8}$", version_spoti):
|
||||
version_spoti = input("Spotify version, for example 1.1.68.632.g2b11de83: ")
|
||||
async def main(version_spoti=""):
|
||||
if not version_spoti:
|
||||
while not re.match(r"^\d+\.\d+\.\d+\.\d+\.g[0-9a-f]{8}$", version_spoti):
|
||||
version_spoti = input("Spotify version, for example 1.1.68.632.g2b11de83: ")
|
||||
|
||||
start_number = ""
|
||||
while not start_number.isdigit() or not 0 <= int(start_number) <= 20000:
|
||||
start_number = input("Start search from: ")
|
||||
start_number = ""
|
||||
while not start_number.isdigit() or not 0 <= int(start_number) <= 20000:
|
||||
start_number = input("Start search from: ")
|
||||
|
||||
before_enter = ""
|
||||
while not before_enter.isdigit() or not 1 <= int(before_enter) <= 20000:
|
||||
before_enter = input("End search at: ")
|
||||
before_enter = ""
|
||||
while not before_enter.isdigit() or not 1 <= int(before_enter) <= 20000:
|
||||
before_enter = input("End search at: ")
|
||||
|
||||
max_workers_req = ""
|
||||
while True:
|
||||
max_workers_req = input("Number of threads: ")
|
||||
try:
|
||||
max_workers = int(max_workers_req)
|
||||
if 1 <= max_workers <= 150:
|
||||
break
|
||||
numbers = int(start_number)
|
||||
find_url = []
|
||||
|
||||
win32 = "https://upgrade.scdn.co/upgrade/client/win32-x86/spotify_installer-{version_spoti}-{numbers}.exe"
|
||||
win_arm64 = "https://upgrade.scdn.co/upgrade/client/win32-arm64/spotify_installer-{version_spoti}-{numbers}.exe"
|
||||
osx = "https://upgrade.scdn.co/upgrade/client/osx-x86_64/spotify-autoupdate-{version_spoti}-{numbers}.tbz"
|
||||
osx_arm64 = "https://upgrade.scdn.co/upgrade/client/osx-arm64/spotify-autoupdate-{version_spoti}-{numbers}.tbz"
|
||||
|
||||
print("\nSelect the link type for the search:")
|
||||
print("[1] WIN32")
|
||||
print("[2] WIN-ARM64")
|
||||
print("[3] OSX")
|
||||
print("[4] OSX-ARM64")
|
||||
print("[5] All platforms")
|
||||
|
||||
choices = []
|
||||
while not choices:
|
||||
choice = input("Enter the number(s): ")
|
||||
choice_list = choice.split(",")
|
||||
for c in choice_list:
|
||||
c = c.strip()
|
||||
if c == "1":
|
||||
choices.append("1")
|
||||
elif c == "2":
|
||||
choices.append("2")
|
||||
elif c == "3":
|
||||
choices.append("3")
|
||||
elif c == "4":
|
||||
choices.append("4")
|
||||
elif c == "5":
|
||||
choices = ["1", "2", "3", "4"]
|
||||
break
|
||||
else:
|
||||
print("Value should be in the range from 1 to 5")
|
||||
|
||||
print("\nSearching...\n")
|
||||
|
||||
async with aiohttp.ClientSession() as session:
|
||||
tasks = []
|
||||
|
||||
if "5" in choices:
|
||||
url_templates = [win32, win_arm64, osx, osx_arm64]
|
||||
platform_names = ["WIN32", "WIN-ARM64", "OSX", "OSX-ARM64"]
|
||||
for url_template, platform_name in zip(url_templates, platform_names):
|
||||
numbers = int(start_number)
|
||||
while numbers <= int(before_enter):
|
||||
url = url_template.format(
|
||||
version_spoti=version_spoti, numbers=numbers
|
||||
)
|
||||
tasks.append(check_url(session, url, platform_name))
|
||||
numbers += 1
|
||||
else:
|
||||
print("Value should be in the range from 1 to 150")
|
||||
except ValueError:
|
||||
print("Invalid value, please enter an integer")
|
||||
for choice in choices:
|
||||
if choice == "1":
|
||||
url_template = win32
|
||||
platform_name = "WIN32"
|
||||
elif choice == "2":
|
||||
url_template = win_arm64
|
||||
platform_name = "WIN-ARM64"
|
||||
elif choice == "3":
|
||||
url_template = osx
|
||||
platform_name = "OSX"
|
||||
elif choice == "4":
|
||||
url_template = osx_arm64
|
||||
platform_name = "OSX-ARM64"
|
||||
numbers = int(start_number)
|
||||
while numbers <= int(before_enter):
|
||||
url = url_template.format(version_spoti=version_spoti, numbers=numbers)
|
||||
tasks.append(check_url(session, url, platform_name))
|
||||
numbers += 1
|
||||
|
||||
numbers = int(start_number)
|
||||
find_url = []
|
||||
results = []
|
||||
|
||||
win32 = "https://upgrade.scdn.co/upgrade/client/win32-x86/spotify_installer-{version_spoti}-{numbers}.exe"
|
||||
win_arm64 = "https://upgrade.scdn.co/upgrade/client/win32-arm64/spotify_installer-{version_spoti}-{numbers}.exe"
|
||||
osx = "https://upgrade.scdn.co/upgrade/client/osx-x86_64/spotify-autoupdate-{version_spoti}-{numbers}.tbz"
|
||||
osx_arm64 = "https://upgrade.scdn.co/upgrade/client/osx-arm64/spotify-autoupdate-{version_spoti}-{numbers}.tbz"
|
||||
with tqdm(total=len(tasks)) as pbar:
|
||||
for task in asyncio.as_completed(tasks):
|
||||
result = await task
|
||||
if result is not None:
|
||||
find_url.append(result)
|
||||
pbar.update(1)
|
||||
|
||||
print("Select the link type for the search:")
|
||||
print("[1] WIN32")
|
||||
print("[2] WIN-ARM64")
|
||||
print("[3] OSX")
|
||||
print("[4] OSX-ARM64")
|
||||
print("[5] ALL")
|
||||
print("\nSearch completed:\n")
|
||||
if find_url:
|
||||
platform_urls = {}
|
||||
for item in find_url:
|
||||
if isinstance(item, tuple):
|
||||
url, platform_name = item
|
||||
if platform_name not in platform_urls:
|
||||
platform_urls[platform_name] = []
|
||||
platform_urls[platform_name].append(url)
|
||||
else:
|
||||
if "Unknown" not in platform_urls:
|
||||
platform_urls["Unknown"] = []
|
||||
platform_urls["Unknown"].append(item)
|
||||
|
||||
choice = None
|
||||
while choice not in ["1", "2", "3", "4", "5"]:
|
||||
choice = input("Enter the number: ")
|
||||
for platform_name, urls in platform_urls.items():
|
||||
print(f"{platform_name}:")
|
||||
for url in urls:
|
||||
print(url)
|
||||
print()
|
||||
else:
|
||||
print("Nothing found, consider increasing the search range\n")
|
||||
|
||||
choice = input("Choose an option:\n"
|
||||
"[1] Perform the search with a new version\n"
|
||||
"[2] Perform the search again with the same version\n"
|
||||
"[3] Exit\n"
|
||||
"Enter the number: ")
|
||||
|
||||
if choice == "1":
|
||||
url_template = win32
|
||||
platform_name = "WIN32"
|
||||
print("\n")
|
||||
await main()
|
||||
elif choice == "2":
|
||||
url_template = win_arm64
|
||||
platform_name = "WIN-ARM64"
|
||||
print("\n")
|
||||
print(f"Search version: {version_spoti}")
|
||||
await main(version_spoti)
|
||||
elif choice == "3":
|
||||
url_template = osx
|
||||
platform_name = "OSX"
|
||||
elif choice == "4":
|
||||
url_template = osx_arm64
|
||||
platform_name = "OSX-ARM64"
|
||||
elif choice == "5":
|
||||
url_templates = [win32, win_arm64, osx, osx_arm64]
|
||||
platform_names = ["WIN32", "WIN-ARM64", "OSX", "OSX-ARM64"]
|
||||
return
|
||||
else:
|
||||
print("Value should be in the range from 1 to 5")
|
||||
print("Invalid choice. Exiting the code.")
|
||||
|
||||
print("Searching...")
|
||||
|
||||
with ThreadPoolExecutor(max_workers=max_workers) as executor:
|
||||
tasks = []
|
||||
|
||||
if choice == "5":
|
||||
for url_template, platform_name in zip(url_templates, platform_names):
|
||||
numbers = int(start_number)
|
||||
while numbers <= int(before_enter):
|
||||
url = url_template.format(version_spoti=version_spoti, numbers=numbers)
|
||||
tasks.append(executor.submit(check_url, url, platform_name))
|
||||
numbers += 1
|
||||
else:
|
||||
while numbers <= int(before_enter):
|
||||
url = url_template.format(version_spoti=version_spoti, numbers=numbers)
|
||||
tasks.append(executor.submit(check_url, url, platform_name))
|
||||
numbers += 1
|
||||
|
||||
for task in tasks:
|
||||
result = task.result()
|
||||
if result is not None:
|
||||
find_url.append(result)
|
||||
|
||||
print("\nSearch completed.\n")
|
||||
if find_url:
|
||||
platform_urls = {}
|
||||
for item in find_url:
|
||||
if isinstance(item, tuple):
|
||||
url, platform_name = item
|
||||
if platform_name not in platform_urls:
|
||||
platform_urls[platform_name] = []
|
||||
platform_urls[platform_name].append(url)
|
||||
else:
|
||||
if "Unknown" not in platform_urls:
|
||||
platform_urls["Unknown"] = []
|
||||
platform_urls["Unknown"].append(item)
|
||||
|
||||
for platform_name, urls in platform_urls.items():
|
||||
print(f"{platform_name}:")
|
||||
for url in urls:
|
||||
print(url)
|
||||
print()
|
||||
else:
|
||||
print("Nothing found, consider increasing the search range.")
|
||||
|
||||
print("\n")
|
||||
input("Press Enter to exit")
|
||||
asyncio.run(main())
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<a href="https://docs.google.com/spreadsheets/d/1wztO1L4zvNykBRw7X4jxP8pvo11oQjT0O5DvZ_-S4Ok/edit#gid=0"><img src="https://img.shields.io/badge/Excel%20table--brightgreen.svg?style=flat&logo=microsoftexcel&label=Excel table"></a>
|
||||
</p>
|
||||
<h1 align="center">LoaderSpot</h1>
|
||||
<h2 align="center">A tool for downloading the full Spotify Desktop client.</h2>
|
||||
<h2 align="center">Tool for finding full Spotify installers.</h2>
|
||||
<p align="center">
|
||||
<h3 align="center">I also created an updatable document, with all the links I found. You can see it <a href="https://docs.google.com/spreadsheets/d/1wztO1L4zvNykBRw7X4jxP8pvo11oQjT0O5DvZ_-S4Ok/edit#gid=0">here</a></h3>
|
||||
</p>
|
||||
|
|
|
|||
|
|
@ -1,45 +0,0 @@
|
|||
do { $version_spoti = Read-Host -Prompt "Enter the Spotify version, for example 1.1.68.632.g2b11de83" }
|
||||
while ($version_spoti -notmatch '^\d.\d.\d{1,2}.\d{1,5}.[a-z][0-9a-z][0-9a-z][0-9a-z][0-9a-z][0-9a-z][0-9a-z][0-9a-z][0-9a-z]$')
|
||||
|
||||
do { $before_enter = Read-Host -Prompt "Enter the number to stop at (e.g. 99)" }
|
||||
while ($before_enter -notmatch '^\d{1,4}$')
|
||||
|
||||
$numbers = 0
|
||||
|
||||
"Search..."
|
||||
While ($numbers -le $before_enter) {
|
||||
|
||||
$_URL = "https://upgrade.scdn.co/upgrade/client/win32-x86/spotify_installer-$version_spoti-$numbers.exe"
|
||||
|
||||
|
||||
try {
|
||||
$request = [System.Net.WebRequest]::Create($_URL)
|
||||
$response = $request.getResponse()
|
||||
|
||||
if ($response.StatusCode -eq "200") {
|
||||
$response.ResponseUri.OriginalString
|
||||
$find_url += [System.Environment]::NewLine + $response.ResponseUri.OriginalString
|
||||
$response.Close()
|
||||
}
|
||||
|
||||
}
|
||||
catch {
|
||||
$numbers
|
||||
}
|
||||
|
||||
$numbers++
|
||||
}
|
||||
|
||||
write-host "`n"
|
||||
"Search completed"
|
||||
write-host "`n"
|
||||
if ($find_url) {
|
||||
"Found links :"
|
||||
$find_url
|
||||
}
|
||||
if (!($find_url)) {
|
||||
"Nothing found, please increase your search range."
|
||||
}
|
||||
write-host "`n"
|
||||
pause
|
||||
exit
|
||||
|
|
@ -1,514 +0,0 @@
|
|||
|
||||
Add-Type -Name Window -Namespace Console -MemberDefinition '
|
||||
[DllImport("Kernel32.dll")]
|
||||
public static extern IntPtr GetConsoleWindow();
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern bool ShowWindow(IntPtr hWnd, Int32 nCmdShow);
|
||||
'
|
||||
function Hide-Console {
|
||||
$consolePtr = [Console.Window]::GetConsoleWindow()
|
||||
#0 hide
|
||||
[Console.Window]::ShowWindow($consolePtr, 0)
|
||||
}
|
||||
Hide-Console
|
||||
|
||||
function Show-Search_psf {
|
||||
|
||||
[void][reflection.assembly]::Load('System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a')
|
||||
[void][reflection.assembly]::Load('System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089')
|
||||
|
||||
try {
|
||||
[ProgressBarOverlay] | Out-Null
|
||||
}
|
||||
catch {
|
||||
if ($PSVersionTable.PSVersion.Major -ge 7) {
|
||||
$Assemblies = 'System.Windows.Forms', 'System.Drawing', 'System.Drawing.Primitives', 'System.ComponentModel.Primitives', 'System.Drawing.Common', 'System.Runtime'
|
||||
}
|
||||
else {
|
||||
$Assemblies = 'System.Windows.Forms', 'System.Drawing'
|
||||
|
||||
}
|
||||
Add-Type -ReferencedAssemblies $Assemblies -TypeDefinition @"
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
namespace SAPIENTypes
|
||||
{
|
||||
public class ProgressBarOverlay : System.Windows.Forms.ProgressBar
|
||||
{
|
||||
public ProgressBarOverlay() : base() { SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true); }
|
||||
protected override void WndProc(ref Message m)
|
||||
{
|
||||
base.WndProc(ref m);
|
||||
if (m.Msg == 0x000F)// WM_PAINT
|
||||
{
|
||||
if (Style != System.Windows.Forms.ProgressBarStyle.Marquee || !string.IsNullOrEmpty(this.Text))
|
||||
{
|
||||
using (Graphics g = this.CreateGraphics())
|
||||
{
|
||||
using (StringFormat stringFormat = new StringFormat(StringFormatFlags.NoWrap))
|
||||
{
|
||||
stringFormat.Alignment = StringAlignment.Center;
|
||||
stringFormat.LineAlignment = StringAlignment.Center;
|
||||
if (!string.IsNullOrEmpty(this.Text))
|
||||
g.DrawString(this.Text, this.Font, Brushes.Black, this.ClientRectangle, stringFormat);
|
||||
else
|
||||
{
|
||||
int percent = (int)(((double)Value / (double)Maximum) * 100);
|
||||
g.DrawString(percent.ToString() + "%", this.Font, Brushes.Black, this.ClientRectangle, stringFormat);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string TextOverlay
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.Text;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.Text = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"@ -IgnoreWarnings | Out-Null
|
||||
}
|
||||
|
||||
[System.Windows.Forms.Application]::EnableVisualStyles()
|
||||
$formFindingASpotifyClien = New-Object 'System.Windows.Forms.Form'
|
||||
$progressbar1 = New-Object 'SAPIENTypes.ProgressBarOverlay'
|
||||
$textbox1 = New-Object 'System.Windows.Forms.TextBox'
|
||||
$linklabelFoundLinks = New-Object 'System.Windows.Forms.LinkLabel'
|
||||
$groupbox2 = New-Object 'System.Windows.Forms.GroupBox'
|
||||
$labelEnterSpotifyVersion = New-Object 'System.Windows.Forms.Label'
|
||||
$maskedtextbox1 = New-Object 'System.Windows.Forms.MaskedTextBox'
|
||||
$labelForExample1182758g8b = New-Object 'System.Windows.Forms.Label'
|
||||
$groupbox1 = New-Object 'System.Windows.Forms.GroupBox'
|
||||
$labelMaximumNumberFromFou = New-Object 'System.Windows.Forms.Label'
|
||||
$labelEnterSearchRange = New-Object 'System.Windows.Forms.Label'
|
||||
$labelTo = New-Object 'System.Windows.Forms.Label'
|
||||
$maskedtextbox2 = New-Object 'System.Windows.Forms.MaskedTextBox'
|
||||
$labelFrom = New-Object 'System.Windows.Forms.Label'
|
||||
$maskedtextbox3 = New-Object 'System.Windows.Forms.MaskedTextBox'
|
||||
$buttonStartSearch = New-Object 'System.Windows.Forms.Button'
|
||||
$buttonExit = New-Object 'System.Windows.Forms.Button'
|
||||
$InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState'
|
||||
|
||||
function Update-ListBox {
|
||||
param
|
||||
(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[ValidateNotNull()]
|
||||
[System.Windows.Forms.ListBox]
|
||||
$ListBox,
|
||||
[Parameter(Mandatory = $true)]
|
||||
[ValidateNotNull()]
|
||||
$Items,
|
||||
[Parameter(Mandatory = $false)]
|
||||
[string]
|
||||
$DisplayMember,
|
||||
[Parameter(Mandatory = $false)]
|
||||
[string]$ValueMember,
|
||||
[switch]
|
||||
$Append
|
||||
)
|
||||
|
||||
if (-not $Append) {
|
||||
$listBox.Items.Clear()
|
||||
}
|
||||
|
||||
if ($Items -is [System.Windows.Forms.ListBox+ObjectCollection]) {
|
||||
$listBox.Items.AddRange($Items)
|
||||
}
|
||||
elseif ($Items -is [Array]) {
|
||||
$listBox.BeginUpdate()
|
||||
foreach ($obj in $Items) {
|
||||
$listBox.Items.Add($obj)
|
||||
}
|
||||
$listBox.EndUpdate()
|
||||
}
|
||||
else {
|
||||
$listBox.Items.Add($Items)
|
||||
}
|
||||
|
||||
if ($DisplayMember) {
|
||||
$listBox.DisplayMember = $DisplayMember
|
||||
}
|
||||
if ($ValueMember) {
|
||||
$ListBox.ValueMember = $ValueMember
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function Update-ComboBox {
|
||||
param
|
||||
(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[ValidateNotNull()]
|
||||
[System.Windows.Forms.ComboBox]
|
||||
$ComboBox,
|
||||
[Parameter(Mandatory = $true)]
|
||||
[ValidateNotNull()]
|
||||
$Items,
|
||||
[Parameter(Mandatory = $false)]
|
||||
[string]$DisplayMember,
|
||||
[Parameter(Mandatory = $false)]
|
||||
[string]$ValueMember,
|
||||
[switch]
|
||||
$Append
|
||||
)
|
||||
|
||||
if (-not $Append) {
|
||||
$ComboBox.Items.Clear()
|
||||
}
|
||||
|
||||
if ($Items -is [Object[]]) {
|
||||
$ComboBox.Items.AddRange($Items)
|
||||
}
|
||||
elseif ($Items -is [System.Collections.IEnumerable]) {
|
||||
$ComboBox.BeginUpdate()
|
||||
foreach ($obj in $Items) {
|
||||
$ComboBox.Items.Add($obj)
|
||||
}
|
||||
$ComboBox.EndUpdate()
|
||||
}
|
||||
else {
|
||||
$ComboBox.Items.Add($Items)
|
||||
}
|
||||
|
||||
if ($DisplayMember) {
|
||||
$ComboBox.DisplayMember = $DisplayMember
|
||||
}
|
||||
|
||||
if ($ValueMember) {
|
||||
$ComboBox.ValueMember = $ValueMember
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$buttonStartSearch_Click = {
|
||||
# Search button logic
|
||||
|
||||
if ($maskedtextbox2.Text -notmatch "\D" -and $maskedtextbox3.Text -notmatch "\D") {
|
||||
|
||||
$ErrorActionPreference = 'SilentlyContinue'
|
||||
$version_spoti = $maskedtextbox1.Text
|
||||
$numbers = [int]$maskedtextbox2.Text
|
||||
$before_enter = [int]$maskedtextbox3.Text
|
||||
|
||||
if ($before_enter -gt $numbers) {
|
||||
|
||||
if ($version_spoti -match '^\d.\d.\d{1,2}.\d{1,5}.[a-z][0-9a-z][0-9a-z][0-9a-z][0-9a-z][0-9a-z][0-9a-z][0-9a-z][0-9a-z]$') {
|
||||
$textbox1.AppendText([System.Environment]::NewLine + "")
|
||||
$textbox1.AppendText("Search...")
|
||||
|
||||
$numbers_bar = 0
|
||||
$progressbar1.Minimum = 0
|
||||
$progressbar1.Maximum = $before_enter - $numbers
|
||||
|
||||
While ($numbers -le $before_enter) {
|
||||
|
||||
$progressbar1.Value = $numbers_bar
|
||||
$numbers_bar++
|
||||
|
||||
|
||||
$_URL = "https://upgrade.scdn.co/upgrade/client/win32-x86/spotify_installer-$version_spoti-$numbers.exe"
|
||||
|
||||
|
||||
try {
|
||||
$request = [System.Net.WebRequest]::Create($_URL)
|
||||
$response = $request.getResponse()
|
||||
|
||||
if ($response.StatusCode -eq "200") {
|
||||
$response.ResponseUri.OriginalString
|
||||
$find_url += [System.Environment]::NewLine + $response.ResponseUri.OriginalString
|
||||
$response.Close()
|
||||
}
|
||||
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
$numbers++
|
||||
}
|
||||
$textbox1.AppendText([System.Environment]::NewLine + "")
|
||||
$textbox1.AppendText([System.Environment]::NewLine + "Search completed")
|
||||
$textbox1.AppendText([System.Environment]::NewLine + "")
|
||||
if ($find_url) {
|
||||
$textbox1.AppendText([System.Environment]::NewLine + "Found links:")
|
||||
$textbox1.AppendText([System.Environment]::NewLine + $find_url)
|
||||
$textbox1.AppendText([System.Environment]::NewLine + "`n")
|
||||
}
|
||||
if (!($find_url)) {
|
||||
$textbox1.AppendText([System.Environment]::NewLine + "The search returned no results, try increasing the range.")
|
||||
$textbox1.AppendText([System.Environment]::NewLine + "`n")
|
||||
}
|
||||
}
|
||||
else {
|
||||
$textbox1.AppendText([System.Environment]::NewLine + "")
|
||||
$textbox1.AppendText("Unsuccessfully")
|
||||
$textbox1.AppendText([System.Environment]::NewLine + "Spotify version entered incorrectly")
|
||||
$textbox1.AppendText([System.Environment]::NewLine + "`n")
|
||||
}
|
||||
}
|
||||
else {
|
||||
$textbox1.AppendText([System.Environment]::NewLine + "")
|
||||
$textbox1.AppendText("Unsuccessfully")
|
||||
$textbox1.AppendText([System.Environment]::NewLine + "Search range entered incorrectly")
|
||||
$textbox1.AppendText([System.Environment]::NewLine + "The start range cannot be greater than the end range.")
|
||||
$textbox1.AppendText([System.Environment]::NewLine + "`n")
|
||||
}
|
||||
}
|
||||
else {
|
||||
$textbox1.AppendText([System.Environment]::NewLine + "")
|
||||
$textbox1.AppendText("Unsuccessfully")
|
||||
$textbox1.AppendText([System.Environment]::NewLine + "Search range entered incorrectly")
|
||||
$textbox1.AppendText([System.Environment]::NewLine + "Enter only numbers")
|
||||
$textbox1.AppendText([System.Environment]::NewLine + "`n")
|
||||
}
|
||||
}
|
||||
|
||||
$buttonExit_Click = {
|
||||
# Exit button logic
|
||||
$formFindingASpotifyClien.hide()
|
||||
}
|
||||
$linklabelFoundLinks_LinkClicked = [System.Windows.Forms.LinkLabelLinkClickedEventHandler] {
|
||||
#Event Argument: $_ = [System.Windows.Forms.LinkLabelLinkClickedEventArgs]
|
||||
Start-Process "https://cutt.ly/8EH6NuH"
|
||||
}
|
||||
|
||||
$Form_StateCorrection_Load =
|
||||
{
|
||||
#Correct the initial state of the form to prevent the .Net maximized form issue
|
||||
$formFindingASpotifyClien.WindowState = $InitialFormWindowState
|
||||
}
|
||||
|
||||
$Form_Cleanup_FormClosed =
|
||||
{
|
||||
#Remove all event handlers from the controls
|
||||
try {
|
||||
$linklabelFoundLinks.remove_LinkClicked($linklabelFoundLinks_LinkClicked)
|
||||
$buttonStartSearch.remove_Click($buttonStartSearch_Click)
|
||||
$buttonExit.remove_Click($buttonExit_Click)
|
||||
$formFindingASpotifyClien.remove_Load($Form_StateCorrection_Load)
|
||||
$formFindingASpotifyClien.remove_FormClosed($Form_Cleanup_FormClosed)
|
||||
}
|
||||
catch { Out-Null <# Prevent PSScriptAnalyzer warning #> }
|
||||
}
|
||||
|
||||
$formFindingASpotifyClien.SuspendLayout()
|
||||
$groupbox2.SuspendLayout()
|
||||
$groupbox1.SuspendLayout()
|
||||
#
|
||||
# formFindingASpotifyClien
|
||||
#
|
||||
$formFindingASpotifyClien.Controls.Add($progressbar1)
|
||||
$formFindingASpotifyClien.Controls.Add($textbox1)
|
||||
$formFindingASpotifyClien.Controls.Add($linklabelFoundLinks)
|
||||
$formFindingASpotifyClien.Controls.Add($groupbox2)
|
||||
$formFindingASpotifyClien.Controls.Add($groupbox1)
|
||||
$formFindingASpotifyClien.Controls.Add($buttonStartSearch)
|
||||
$formFindingASpotifyClien.Controls.Add($buttonExit)
|
||||
$formFindingASpotifyClien.AutoScaleDimensions = New-Object System.Drawing.SizeF(6, 13)
|
||||
$formFindingASpotifyClien.AutoScaleMode = 'Font'
|
||||
$formFindingASpotifyClien.AutoSizeMode = 'GrowAndShrink'
|
||||
$formFindingASpotifyClien.ClientSize = New-Object System.Drawing.Size(444, 370)
|
||||
$formFindingASpotifyClien.MaximizeBox = $False
|
||||
$formFindingASpotifyClien.Name = 'formFindingASpotifyClien'
|
||||
$formFindingASpotifyClien.ShowIcon = $False
|
||||
$formFindingASpotifyClien.SizeGripStyle = 'Hide'
|
||||
$formFindingASpotifyClien.StartPosition = 'CenterScreen'
|
||||
$formFindingASpotifyClien.Text = 'Finding a Spotify Client'
|
||||
#
|
||||
# progressbar1
|
||||
#
|
||||
$progressbar1.Location = New-Object System.Drawing.Point(12, 307)
|
||||
$progressbar1.Name = 'progressbar1'
|
||||
$progressbar1.Size = New-Object System.Drawing.Size(420, 23)
|
||||
$progressbar1.TabIndex = 18
|
||||
#
|
||||
# textbox1
|
||||
#
|
||||
$textbox1.Font = [System.Drawing.Font]::new('Tahoma', '6.75')
|
||||
$textbox1.Location = New-Object System.Drawing.Point(13, 149)
|
||||
$textbox1.Multiline = $True
|
||||
$textbox1.Name = 'textbox1'
|
||||
$textbox1.ReadOnly = $True
|
||||
$textbox1.ScrollBars = 'Both'
|
||||
$textbox1.Size = New-Object System.Drawing.Size(419, 151)
|
||||
$textbox1.TabIndex = 17
|
||||
#
|
||||
# linklabelFoundLinks
|
||||
#
|
||||
$linklabelFoundLinks.LinkColor = [System.Drawing.SystemColors]::HotTrack
|
||||
$linklabelFoundLinks.Location = New-Object System.Drawing.Point(12, 341)
|
||||
$linklabelFoundLinks.Name = 'linklabelFoundLinks'
|
||||
$linklabelFoundLinks.Size = New-Object System.Drawing.Size(62, 17)
|
||||
$linklabelFoundLinks.TabIndex = 16
|
||||
$linklabelFoundLinks.TabStop = $True
|
||||
$linklabelFoundLinks.Text = 'Found links'
|
||||
$linklabelFoundLinks.VisitedLinkColor = [System.Drawing.Color]::SlateBlue
|
||||
$linklabelFoundLinks.add_LinkClicked($linklabelFoundLinks_LinkClicked)
|
||||
#
|
||||
# groupbox2
|
||||
#
|
||||
$groupbox2.Controls.Add($labelEnterSpotifyVersion)
|
||||
$groupbox2.Controls.Add($maskedtextbox1)
|
||||
$groupbox2.Controls.Add($labelForExample1182758g8b)
|
||||
$groupbox2.Location = New-Object System.Drawing.Point(228, 20)
|
||||
$groupbox2.Name = 'groupbox2'
|
||||
$groupbox2.Size = New-Object System.Drawing.Size(204, 122)
|
||||
$groupbox2.TabIndex = 13
|
||||
$groupbox2.TabStop = $False
|
||||
#
|
||||
# labelEnterSpotifyVersion
|
||||
#
|
||||
$labelEnterSpotifyVersion.AutoSize = $True
|
||||
$labelEnterSpotifyVersion.Font = [System.Drawing.Font]::new('Tahoma', '9', [System.Drawing.FontStyle]'Bold')
|
||||
$labelEnterSpotifyVersion.Location = New-Object System.Drawing.Point(30, 16)
|
||||
$labelEnterSpotifyVersion.Name = 'labelEnterSpotifyVersion'
|
||||
$labelEnterSpotifyVersion.Size = New-Object System.Drawing.Size(138, 14)
|
||||
$labelEnterSpotifyVersion.TabIndex = 3
|
||||
$labelEnterSpotifyVersion.Text = 'Enter Spotify Version'
|
||||
#
|
||||
# maskedtextbox1
|
||||
#
|
||||
$maskedtextbox1.Font = [System.Drawing.Font]::new('Tahoma', '8.25')
|
||||
$maskedtextbox1.Location = New-Object System.Drawing.Point(24, 87)
|
||||
$maskedtextbox1.Name = 'maskedtextbox1'
|
||||
$maskedtextbox1.Size = New-Object System.Drawing.Size(158, 21)
|
||||
$maskedtextbox1.TabIndex = 2
|
||||
$maskedtextbox1.TextAlign = 'Center'
|
||||
#
|
||||
# labelForExample1182758g8b
|
||||
#
|
||||
$labelForExample1182758g8b.AccessibleDescription = ''
|
||||
$labelForExample1182758g8b.AccessibleName = ''
|
||||
$labelForExample1182758g8b.AutoSize = $True
|
||||
$labelForExample1182758g8b.Font = [System.Drawing.Font]::new('Tahoma', '8.25')
|
||||
$labelForExample1182758g8b.Location = New-Object System.Drawing.Point(40, 48)
|
||||
$labelForExample1182758g8b.Name = 'labelForExample1182758g8b'
|
||||
$labelForExample1182758g8b.Size = New-Object System.Drawing.Size(118, 26)
|
||||
$labelForExample1182758g8b.TabIndex = 4
|
||||
$labelForExample1182758g8b.Text = 'For example:
|
||||
1.1.82.758.g8b7b66c7'
|
||||
#
|
||||
# groupbox1
|
||||
#
|
||||
$groupbox1.Controls.Add($labelMaximumNumberFromFou)
|
||||
$groupbox1.Controls.Add($labelEnterSearchRange)
|
||||
$groupbox1.Controls.Add($labelTo)
|
||||
$groupbox1.Controls.Add($maskedtextbox2)
|
||||
$groupbox1.Controls.Add($labelFrom)
|
||||
$groupbox1.Controls.Add($maskedtextbox3)
|
||||
$groupbox1.Location = New-Object System.Drawing.Point(12, 20)
|
||||
$groupbox1.Name = 'groupbox1'
|
||||
$groupbox1.Size = New-Object System.Drawing.Size(204, 122)
|
||||
$groupbox1.TabIndex = 12
|
||||
$groupbox1.TabStop = $False
|
||||
#
|
||||
# labelMaximumNumberFromFou
|
||||
#
|
||||
$labelMaximumNumberFromFou.AutoSize = $True
|
||||
$labelMaximumNumberFromFou.Font = [System.Drawing.Font]::new('Tahoma', '8.25')
|
||||
$labelMaximumNumberFromFou.Location = New-Object System.Drawing.Point(40, 48)
|
||||
$labelMaximumNumberFromFou.Name = 'labelMaximumNumberFromFou'
|
||||
$labelMaximumNumberFromFou.Size = New-Object System.Drawing.Size(118, 26)
|
||||
$labelMaximumNumberFromFou.TabIndex = 14
|
||||
$labelMaximumNumberFromFou.Text = 'Maximum number from
|
||||
found links was 490.'
|
||||
#
|
||||
# labelEnterSearchRange
|
||||
#
|
||||
$labelEnterSearchRange.AutoSize = $True
|
||||
$labelEnterSearchRange.Font = [System.Drawing.Font]::new('Tahoma', '9', [System.Drawing.FontStyle]'Bold')
|
||||
$labelEnterSearchRange.Location = New-Object System.Drawing.Point(40, 16)
|
||||
$labelEnterSearchRange.Name = 'labelEnterSearchRange'
|
||||
$labelEnterSearchRange.Size = New-Object System.Drawing.Size(122, 14)
|
||||
$labelEnterSearchRange.TabIndex = 6
|
||||
$labelEnterSearchRange.Text = 'Enter search range'
|
||||
#
|
||||
# labelTo
|
||||
#
|
||||
$labelTo.AutoSize = $True
|
||||
$labelTo.Font = [System.Drawing.Font]::new('Lucida Console', '8.25')
|
||||
$labelTo.Location = New-Object System.Drawing.Point(103, 92)
|
||||
$labelTo.Name = 'labelTo'
|
||||
$labelTo.Size = New-Object System.Drawing.Size(19, 11)
|
||||
$labelTo.TabIndex = 11
|
||||
$labelTo.Text = 'to'
|
||||
#
|
||||
# maskedtextbox2
|
||||
#
|
||||
$maskedtextbox2.Font = [System.Drawing.Font]::new('Tahoma', '8.25')
|
||||
$maskedtextbox2.Location = New-Object System.Drawing.Point(45, 87)
|
||||
$maskedtextbox2.Name = 'maskedtextbox2'
|
||||
$maskedtextbox2.Size = New-Object System.Drawing.Size(50, 21)
|
||||
$maskedtextbox2.TabIndex = 5
|
||||
$maskedtextbox2.Text = '0'
|
||||
$maskedtextbox2.TextAlign = 'Center'
|
||||
#
|
||||
# labelFrom
|
||||
#
|
||||
$labelFrom.AutoSize = $True
|
||||
$labelFrom.Font = [System.Drawing.Font]::new('Lucida Console', '8.25')
|
||||
$labelFrom.Location = New-Object System.Drawing.Point(6, 92)
|
||||
$labelFrom.Name = 'labelFrom'
|
||||
$labelFrom.Size = New-Object System.Drawing.Size(33, 11)
|
||||
$labelFrom.TabIndex = 10
|
||||
$labelFrom.Text = 'From'
|
||||
#
|
||||
# maskedtextbox3
|
||||
#
|
||||
$maskedtextbox3.Font = [System.Drawing.Font]::new('Tahoma', '8.25')
|
||||
$maskedtextbox3.Location = New-Object System.Drawing.Point(128, 87)
|
||||
$maskedtextbox3.Name = 'maskedtextbox3'
|
||||
$maskedtextbox3.Size = New-Object System.Drawing.Size(50, 21)
|
||||
$maskedtextbox3.TabIndex = 8
|
||||
$maskedtextbox3.Text = '100'
|
||||
$maskedtextbox3.TextAlign = 'Center'
|
||||
#
|
||||
# buttonStartSearch
|
||||
#
|
||||
$buttonStartSearch.Location = New-Object System.Drawing.Point(333, 336)
|
||||
$buttonStartSearch.Name = 'buttonStartSearch'
|
||||
$buttonStartSearch.Size = New-Object System.Drawing.Size(99, 23)
|
||||
$buttonStartSearch.TabIndex = 1
|
||||
$buttonStartSearch.Text = 'Start Search'
|
||||
$buttonStartSearch.UseVisualStyleBackColor = $True
|
||||
$buttonStartSearch.add_Click($buttonStartSearch_Click)
|
||||
#
|
||||
# buttonExit
|
||||
#
|
||||
$buttonExit.Location = New-Object System.Drawing.Point(252, 336)
|
||||
$buttonExit.Name = 'buttonExit'
|
||||
$buttonExit.Size = New-Object System.Drawing.Size(75, 23)
|
||||
$buttonExit.TabIndex = 0
|
||||
$buttonExit.TabStop = $False
|
||||
$buttonExit.Text = 'Exit'
|
||||
$buttonExit.UseVisualStyleBackColor = $True
|
||||
$buttonExit.add_Click($buttonExit_Click)
|
||||
$groupbox1.ResumeLayout()
|
||||
$groupbox2.ResumeLayout()
|
||||
$formFindingASpotifyClien.ResumeLayout()
|
||||
|
||||
#Save the initial state of the form
|
||||
$InitialFormWindowState = $formFindingASpotifyClien.WindowState
|
||||
#Init the OnLoad event to correct the initial state of the form
|
||||
$formFindingASpotifyClien.add_Load($Form_StateCorrection_Load)
|
||||
#Clean up the control events
|
||||
$formFindingASpotifyClien.add_FormClosed($Form_Cleanup_FormClosed)
|
||||
#Show the Form
|
||||
return $formFindingASpotifyClien.ShowDialog()
|
||||
|
||||
} #End Function
|
||||
|
||||
#Call the form
|
||||
Show-Search_psf | Out-Null
|
||||
|
|
@ -1,508 +0,0 @@
|
|||
|
||||
Add-Type -Name Window -Namespace Console -MemberDefinition '
|
||||
[DllImport("Kernel32.dll")]
|
||||
public static extern IntPtr GetConsoleWindow();
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern bool ShowWindow(IntPtr hWnd, Int32 nCmdShow);
|
||||
'
|
||||
function Hide-Console {
|
||||
$consolePtr = [Console.Window]::GetConsoleWindow()
|
||||
#0 hide
|
||||
[Console.Window]::ShowWindow($consolePtr, 0)
|
||||
}
|
||||
Hide-Console
|
||||
|
||||
function Show-Search_psf {
|
||||
|
||||
[void][reflection.assembly]::Load('System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a')
|
||||
[void][reflection.assembly]::Load('System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089')
|
||||
|
||||
try {
|
||||
[ProgressBarOverlay] | Out-Null
|
||||
}
|
||||
catch {
|
||||
if ($PSVersionTable.PSVersion.Major -ge 7) {
|
||||
$Assemblies = 'System.Windows.Forms', 'System.Drawing', 'System.Drawing.Primitives', 'System.ComponentModel.Primitives', 'System.Drawing.Common', 'System.Runtime'
|
||||
}
|
||||
else {
|
||||
$Assemblies = 'System.Windows.Forms', 'System.Drawing'
|
||||
|
||||
}
|
||||
Add-Type -ReferencedAssemblies $Assemblies -TypeDefinition @"
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
namespace SAPIENTypes
|
||||
{
|
||||
public class ProgressBarOverlay : System.Windows.Forms.ProgressBar
|
||||
{
|
||||
public ProgressBarOverlay() : base() { SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true); }
|
||||
protected override void WndProc(ref Message m)
|
||||
{
|
||||
base.WndProc(ref m);
|
||||
if (m.Msg == 0x000F)// WM_PAINT
|
||||
{
|
||||
if (Style != System.Windows.Forms.ProgressBarStyle.Marquee || !string.IsNullOrEmpty(this.Text))
|
||||
{
|
||||
using (Graphics g = this.CreateGraphics())
|
||||
{
|
||||
using (StringFormat stringFormat = new StringFormat(StringFormatFlags.NoWrap))
|
||||
{
|
||||
stringFormat.Alignment = StringAlignment.Center;
|
||||
stringFormat.LineAlignment = StringAlignment.Center;
|
||||
if (!string.IsNullOrEmpty(this.Text))
|
||||
g.DrawString(this.Text, this.Font, Brushes.Black, this.ClientRectangle, stringFormat);
|
||||
else
|
||||
{
|
||||
int percent = (int)(((double)Value / (double)Maximum) * 100);
|
||||
g.DrawString(percent.ToString() + "%", this.Font, Brushes.Black, this.ClientRectangle, stringFormat);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string TextOverlay
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.Text;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.Text = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"@ -IgnoreWarnings | Out-Null
|
||||
}
|
||||
|
||||
[System.Windows.Forms.Application]::EnableVisualStyles()
|
||||
$formПоискКлиентаSpotify = New-Object 'System.Windows.Forms.Form'
|
||||
$progressbar1 = New-Object 'SAPIENTypes.ProgressBarOverlay'
|
||||
$textbox1 = New-Object 'System.Windows.Forms.TextBox'
|
||||
$linklabelНайденныеСсылки = New-Object 'System.Windows.Forms.LinkLabel'
|
||||
$groupbox2 = New-Object 'System.Windows.Forms.GroupBox'
|
||||
$labelВведитеВерсиюSpotify = New-Object 'System.Windows.Forms.Label'
|
||||
$maskedtextbox1 = New-Object 'System.Windows.Forms.MaskedTextBox'
|
||||
$labelНапример1182758g8b7b = New-Object 'System.Windows.Forms.Label'
|
||||
$groupbox1 = New-Object 'System.Windows.Forms.GroupBox'
|
||||
$labelМаксимальныйНомерИзН = New-Object 'System.Windows.Forms.Label'
|
||||
$labelВведитеДиапозонПоиск = New-Object 'System.Windows.Forms.Label'
|
||||
$labelДо = New-Object 'System.Windows.Forms.Label'
|
||||
$maskedtextbox2 = New-Object 'System.Windows.Forms.MaskedTextBox'
|
||||
$labelОт = New-Object 'System.Windows.Forms.Label'
|
||||
$maskedtextbox3 = New-Object 'System.Windows.Forms.MaskedTextBox'
|
||||
$buttonНачатьПоиск = New-Object 'System.Windows.Forms.Button'
|
||||
$buttonВыйти = New-Object 'System.Windows.Forms.Button'
|
||||
$InitialFormWindowState = New-Object 'System.Windows.Forms.FormWindowState'
|
||||
|
||||
function Update-ListBox {
|
||||
param
|
||||
(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[ValidateNotNull()]
|
||||
[System.Windows.Forms.ListBox]
|
||||
$ListBox,
|
||||
[Parameter(Mandatory = $true)]
|
||||
[ValidateNotNull()]
|
||||
$Items,
|
||||
[Parameter(Mandatory = $false)]
|
||||
[string]
|
||||
$DisplayMember,
|
||||
[Parameter(Mandatory = $false)]
|
||||
[string]$ValueMember,
|
||||
[switch]
|
||||
$Append
|
||||
)
|
||||
|
||||
if (-not $Append) {
|
||||
$listBox.Items.Clear()
|
||||
}
|
||||
|
||||
if ($Items -is [System.Windows.Forms.ListBox+ObjectCollection]) {
|
||||
$listBox.Items.AddRange($Items)
|
||||
}
|
||||
elseif ($Items -is [Array]) {
|
||||
$listBox.BeginUpdate()
|
||||
foreach ($obj in $Items) {
|
||||
$listBox.Items.Add($obj)
|
||||
}
|
||||
$listBox.EndUpdate()
|
||||
}
|
||||
else {
|
||||
$listBox.Items.Add($Items)
|
||||
}
|
||||
|
||||
if ($DisplayMember) {
|
||||
$listBox.DisplayMember = $DisplayMember
|
||||
}
|
||||
if ($ValueMember) {
|
||||
$ListBox.ValueMember = $ValueMember
|
||||
}
|
||||
}
|
||||
|
||||
function Update-ComboBox {
|
||||
param
|
||||
(
|
||||
[Parameter(Mandatory = $true)]
|
||||
[ValidateNotNull()]
|
||||
[System.Windows.Forms.ComboBox]
|
||||
$ComboBox,
|
||||
[Parameter(Mandatory = $true)]
|
||||
[ValidateNotNull()]
|
||||
$Items,
|
||||
[Parameter(Mandatory = $false)]
|
||||
[string]$DisplayMember,
|
||||
[Parameter(Mandatory = $false)]
|
||||
[string]$ValueMember,
|
||||
[switch]
|
||||
$Append
|
||||
)
|
||||
|
||||
if (-not $Append) {
|
||||
$ComboBox.Items.Clear()
|
||||
}
|
||||
|
||||
if ($Items -is [Object[]]) {
|
||||
$ComboBox.Items.AddRange($Items)
|
||||
}
|
||||
elseif ($Items -is [System.Collections.IEnumerable]) {
|
||||
$ComboBox.BeginUpdate()
|
||||
foreach ($obj in $Items) {
|
||||
$ComboBox.Items.Add($obj)
|
||||
}
|
||||
$ComboBox.EndUpdate()
|
||||
}
|
||||
else {
|
||||
$ComboBox.Items.Add($Items)
|
||||
}
|
||||
|
||||
if ($DisplayMember) {
|
||||
$ComboBox.DisplayMember = $DisplayMember
|
||||
}
|
||||
|
||||
if ($ValueMember) {
|
||||
$ComboBox.ValueMember = $ValueMember
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$buttonНачатьПоиск_Click = {
|
||||
# Логика кнопки поиск
|
||||
|
||||
if ($maskedtextbox2.Text -notmatch "\D" -and $maskedtextbox3.Text -notmatch "\D") {
|
||||
|
||||
$ErrorActionPreference = 'SilentlyContinue'
|
||||
$version_spoti = $maskedtextbox1.Text
|
||||
$numbers = [int]$maskedtextbox2.Text
|
||||
$before_enter = [int]$maskedtextbox3.Text
|
||||
|
||||
if ($before_enter -gt $numbers) {
|
||||
|
||||
if ($version_spoti -match '^\d.\d.\d{1,2}.\d{1,5}.[a-z][0-9a-z][0-9a-z][0-9a-z][0-9a-z][0-9a-z][0-9a-z][0-9a-z][0-9a-z]$') {
|
||||
$textbox1.AppendText([System.Environment]::NewLine + "")
|
||||
$textbox1.AppendText("Поиск...")
|
||||
|
||||
$numbers_bar = 0
|
||||
$progressbar1.Minimum = 0
|
||||
$progressbar1.Maximum = $before_enter - $numbers
|
||||
|
||||
While ($numbers -le $before_enter) {
|
||||
|
||||
$progressbar1.Value = $numbers_bar
|
||||
$numbers_bar++
|
||||
|
||||
|
||||
$_URL = "https://upgrade.scdn.co/upgrade/client/win32-x86/spotify_installer-$version_spoti-$numbers.exe"
|
||||
|
||||
|
||||
try {
|
||||
$request = [System.Net.WebRequest]::Create($_URL)
|
||||
$response = $request.getResponse()
|
||||
|
||||
if ($response.StatusCode -eq "200") {
|
||||
$response.ResponseUri.OriginalString
|
||||
$find_url += [System.Environment]::NewLine + $response.ResponseUri.OriginalString
|
||||
$response.Close()
|
||||
}
|
||||
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
$numbers++
|
||||
}
|
||||
$textbox1.AppendText([System.Environment]::NewLine + "")
|
||||
$textbox1.AppendText([System.Environment]::NewLine + "Поиск завершен")
|
||||
$textbox1.AppendText([System.Environment]::NewLine + "")
|
||||
if ($find_url) {
|
||||
$textbox1.AppendText([System.Environment]::NewLine + "Найденные ссылки :")
|
||||
$textbox1.AppendText([System.Environment]::NewLine + $find_url)
|
||||
$textbox1.AppendText([System.Environment]::NewLine + "`n")
|
||||
}
|
||||
if (!($find_url)) {
|
||||
$textbox1.AppendText([System.Environment]::NewLine + "Поиск не дал результатов, попробуйте увеличить диапазон.")
|
||||
$textbox1.AppendText([System.Environment]::NewLine + "`n")
|
||||
}
|
||||
}
|
||||
else {
|
||||
$textbox1.AppendText([System.Environment]::NewLine + "")
|
||||
$textbox1.AppendText("Неудачно")
|
||||
$textbox1.AppendText([System.Environment]::NewLine + "Не корректно введена версия Spotify")
|
||||
$textbox1.AppendText([System.Environment]::NewLine + "`n")
|
||||
}
|
||||
}
|
||||
else {
|
||||
$textbox1.AppendText([System.Environment]::NewLine + "")
|
||||
$textbox1.AppendText("Неудачно")
|
||||
$textbox1.AppendText([System.Environment]::NewLine + "Не корректно введен диапазон поиска")
|
||||
$textbox1.AppendText([System.Environment]::NewLine + "Начальный диапазон не может быть больше конечного диапазона")
|
||||
$textbox1.AppendText([System.Environment]::NewLine + "`n")
|
||||
}
|
||||
}
|
||||
else {
|
||||
$textbox1.AppendText([System.Environment]::NewLine + "")
|
||||
$textbox1.AppendText("Неудачно")
|
||||
$textbox1.AppendText([System.Environment]::NewLine + "Не корректно введен диапазон поиска")
|
||||
$textbox1.AppendText([System.Environment]::NewLine + "Вводите только цифры")
|
||||
$textbox1.AppendText([System.Environment]::NewLine + "`n")
|
||||
}
|
||||
}
|
||||
$buttonВыйти_Click = {
|
||||
# Логика кнопки выйти
|
||||
$formПоискКлиентаSpotify.hide()
|
||||
}
|
||||
$linklabelНайденныеСсылки_LinkClicked = [System.Windows.Forms.LinkLabelLinkClickedEventHandler] {
|
||||
Start-Process "https://cutt.ly/8EH6NuH"
|
||||
}
|
||||
|
||||
$Form_StateCorrection_Load =
|
||||
{
|
||||
$formПоискКлиентаSpotify.WindowState = $InitialFormWindowState
|
||||
}
|
||||
|
||||
$Form_Cleanup_FormClosed =
|
||||
{
|
||||
try {
|
||||
$linklabelНайденныеСсылки.remove_LinkClicked($linklabelНайденныеСсылки_LinkClicked)
|
||||
$buttonНачатьПоиск.remove_Click($buttonНачатьПоиск_Click)
|
||||
$buttonВыйти.remove_Click($buttonВыйти_Click)
|
||||
$formПоискКлиентаSpotify.remove_Load($Form_StateCorrection_Load)
|
||||
$formПоискКлиентаSpotify.remove_FormClosed($Form_Cleanup_FormClosed)
|
||||
}
|
||||
catch { Out-Null <# Prevent PSScriptAnalyzer warning #> }
|
||||
}
|
||||
$formПоискКлиентаSpotify.SuspendLayout()
|
||||
$groupbox1.SuspendLayout()
|
||||
$groupbox2.SuspendLayout()
|
||||
#
|
||||
# formПоискКлиентаSpotify
|
||||
#
|
||||
$formПоискКлиентаSpotify.Controls.Add($progressbar1)
|
||||
$formПоискКлиентаSpotify.Controls.Add($textbox1)
|
||||
$formПоискКлиентаSpotify.Controls.Add($linklabelНайденныеСсылки)
|
||||
$formПоискКлиентаSpotify.Controls.Add($groupbox2)
|
||||
$formПоискКлиентаSpotify.Controls.Add($groupbox1)
|
||||
$formПоискКлиентаSpotify.Controls.Add($buttonНачатьПоиск)
|
||||
$formПоискКлиентаSpotify.Controls.Add($buttonВыйти)
|
||||
$formПоискКлиентаSpotify.AutoScaleDimensions = New-Object System.Drawing.SizeF(6, 13)
|
||||
$formПоискКлиентаSpotify.AutoScaleMode = 'Font'
|
||||
$formПоискКлиентаSpotify.AutoSizeMode = 'GrowAndShrink'
|
||||
$formПоискКлиентаSpotify.ClientSize = New-Object System.Drawing.Size(444, 370)
|
||||
$formПоискКлиентаSpotify.MaximizeBox = $False
|
||||
$formПоискКлиентаSpotify.Name = 'formПоискКлиентаSpotify'
|
||||
$formПоискКлиентаSpotify.ShowIcon = $False
|
||||
$formПоискКлиентаSpotify.SizeGripStyle = 'Hide'
|
||||
$formПоискКлиентаSpotify.StartPosition = 'CenterScreen'
|
||||
$formПоискКлиентаSpotify.Text = 'Поиск клиента Spotify'
|
||||
#
|
||||
# progressbar1
|
||||
#
|
||||
$progressbar1.Location = New-Object System.Drawing.Point(12, 307)
|
||||
$progressbar1.Name = 'progressbar1'
|
||||
$progressbar1.Size = New-Object System.Drawing.Size(420, 23)
|
||||
$progressbar1.TabIndex = 18
|
||||
#
|
||||
# textbox1
|
||||
#
|
||||
$textbox1.Font = [System.Drawing.Font]::new('Tahoma', '6.75')
|
||||
$textbox1.Location = New-Object System.Drawing.Point(13, 149)
|
||||
$textbox1.Multiline = $True
|
||||
$textbox1.Name = 'textbox1'
|
||||
$textbox1.ReadOnly = $True
|
||||
$textbox1.ScrollBars = 'Both'
|
||||
$textbox1.Size = New-Object System.Drawing.Size(419, 151)
|
||||
$textbox1.TabIndex = 17
|
||||
#
|
||||
# linklabelНайденныеСсылки
|
||||
#
|
||||
$linklabelНайденныеСсылки.LinkColor = [System.Drawing.SystemColors]::HotTrack
|
||||
$linklabelНайденныеСсылки.Location = New-Object System.Drawing.Point(12, 341)
|
||||
$linklabelНайденныеСсылки.Name = 'linklabelНайденныеСсылки'
|
||||
$linklabelНайденныеСсылки.Size = New-Object System.Drawing.Size(107, 17)
|
||||
$linklabelНайденныеСсылки.TabIndex = 16
|
||||
$linklabelНайденныеСсылки.TabStop = $True
|
||||
$linklabelНайденныеСсылки.Text = 'Найденные ссылки'
|
||||
$linklabelНайденныеСсылки.VisitedLinkColor = [System.Drawing.Color]::SlateBlue
|
||||
$linklabelНайденныеСсылки.add_LinkClicked($linklabelНайденныеСсылки_LinkClicked)
|
||||
#
|
||||
# groupbox2
|
||||
#
|
||||
$groupbox2.Controls.Add($labelВведитеВерсиюSpotify)
|
||||
$groupbox2.Controls.Add($maskedtextbox1)
|
||||
$groupbox2.Controls.Add($labelНапример1182758g8b7b)
|
||||
$groupbox2.Location = New-Object System.Drawing.Point(228, 20)
|
||||
$groupbox2.Name = 'groupbox2'
|
||||
$groupbox2.Size = New-Object System.Drawing.Size(204, 122)
|
||||
$groupbox2.TabIndex = 13
|
||||
$groupbox2.TabStop = $False
|
||||
#
|
||||
# labelВведитеВерсиюSpotify
|
||||
#
|
||||
$labelВведитеВерсиюSpotify.AutoSize = $True
|
||||
$labelВведитеВерсиюSpotify.Font = [System.Drawing.Font]::new('Tahoma', '9', [System.Drawing.FontStyle]'Bold')
|
||||
$labelВведитеВерсиюSpotify.Location = New-Object System.Drawing.Point(30, 16)
|
||||
$labelВведитеВерсиюSpotify.Name = 'labelВведитеВерсиюSpotify'
|
||||
$labelВведитеВерсиюSpotify.Size = New-Object System.Drawing.Size(158, 14)
|
||||
$labelВведитеВерсиюSpotify.TabIndex = 3
|
||||
$labelВведитеВерсиюSpotify.Text = 'Введите версию Spotify'
|
||||
#
|
||||
# maskedtextbox1
|
||||
#
|
||||
$maskedtextbox1.Font = [System.Drawing.Font]::new('Tahoma', '8.25')
|
||||
$maskedtextbox1.Location = New-Object System.Drawing.Point(30, 87)
|
||||
$maskedtextbox1.Name = 'maskedtextbox1'
|
||||
$maskedtextbox1.Size = New-Object System.Drawing.Size(158, 21)
|
||||
$maskedtextbox1.TabIndex = 2
|
||||
$maskedtextbox1.TextAlign = 'Center'
|
||||
#
|
||||
# labelНапример1182758g8b7b
|
||||
#
|
||||
$labelНапример1182758g8b7b.AccessibleDescription = ''
|
||||
$labelНапример1182758g8b7b.AccessibleName = ''
|
||||
$labelНапример1182758g8b7b.AutoSize = $True
|
||||
$labelНапример1182758g8b7b.Font = [System.Drawing.Font]::new('Tahoma', '8.25')
|
||||
$labelНапример1182758g8b7b.Location = New-Object System.Drawing.Point(51, 48)
|
||||
$labelНапример1182758g8b7b.Name = 'labelНапример1182758g8b7b'
|
||||
$labelНапример1182758g8b7b.Size = New-Object System.Drawing.Size(118, 26)
|
||||
$labelНапример1182758g8b7b.TabIndex = 4
|
||||
$labelНапример1182758g8b7b.Text = 'Например:
|
||||
1.1.82.758.g8b7b66c7'
|
||||
#
|
||||
# groupbox1
|
||||
#
|
||||
$groupbox1.Controls.Add($labelМаксимальныйНомерИзН)
|
||||
$groupbox1.Controls.Add($labelВведитеДиапозонПоиск)
|
||||
$groupbox1.Controls.Add($labelДо)
|
||||
$groupbox1.Controls.Add($maskedtextbox2)
|
||||
$groupbox1.Controls.Add($labelОт)
|
||||
$groupbox1.Controls.Add($maskedtextbox3)
|
||||
$groupbox1.Location = New-Object System.Drawing.Point(12, 20)
|
||||
$groupbox1.Name = 'groupbox1'
|
||||
$groupbox1.Size = New-Object System.Drawing.Size(204, 122)
|
||||
$groupbox1.TabIndex = 12
|
||||
$groupbox1.TabStop = $False
|
||||
#
|
||||
# labelМаксимальныйНомерИзН
|
||||
#
|
||||
$labelМаксимальныйНомерИзН.AutoSize = $True
|
||||
$labelМаксимальныйНомерИзН.Font = [System.Drawing.Font]::new('Tahoma', '8.25')
|
||||
$labelМаксимальныйНомерИзН.Location = New-Object System.Drawing.Point(27, 48)
|
||||
$labelМаксимальныйНомерИзН.Name = 'labelМаксимальныйНомерИзН'
|
||||
$labelМаксимальныйНомерИзН.Size = New-Object System.Drawing.Size(151, 26)
|
||||
$labelМаксимальныйНомерИзН.TabIndex = 14
|
||||
$labelМаксимальныйНомерИзН.Text = 'Максимальный номер из
|
||||
найденных ссылок был 490.
|
||||
'
|
||||
#
|
||||
# labelВведитеДиапозонПоиск
|
||||
#
|
||||
$labelВведитеДиапозонПоиск.AutoSize = $True
|
||||
$labelВведитеДиапозонПоиск.Font = [System.Drawing.Font]::new('Tahoma', '9', [System.Drawing.FontStyle]'Bold')
|
||||
$labelВведитеДиапозонПоиск.Location = New-Object System.Drawing.Point(15, 16)
|
||||
$labelВведитеДиапозонПоиск.Name = 'labelВведитеДиапозонПоиск'
|
||||
$labelВведитеДиапозонПоиск.Size = New-Object System.Drawing.Size(171, 14)
|
||||
$labelВведитеДиапозонПоиск.TabIndex = 6
|
||||
$labelВведитеДиапозонПоиск.Text = 'Введите диапазон поиска'
|
||||
#
|
||||
# labelДо
|
||||
#
|
||||
$labelДо.AutoSize = $True
|
||||
$labelДо.Font = [System.Drawing.Font]::new('Lucida Console', '8.25')
|
||||
$labelДо.Location = New-Object System.Drawing.Point(103, 92)
|
||||
$labelДо.Name = 'labelДо'
|
||||
$labelДо.Size = New-Object System.Drawing.Size(19, 11)
|
||||
$labelДо.TabIndex = 11
|
||||
$labelДо.Text = 'До'
|
||||
#
|
||||
# maskedtextbox2
|
||||
#
|
||||
$maskedtextbox2.Font = [System.Drawing.Font]::new('Tahoma', '8.25')
|
||||
$maskedtextbox2.Location = New-Object System.Drawing.Point(40, 87)
|
||||
$maskedtextbox2.Name = 'maskedtextbox2'
|
||||
$maskedtextbox2.Size = New-Object System.Drawing.Size(50, 21)
|
||||
$maskedtextbox2.TabIndex = 5
|
||||
$maskedtextbox2.Text = '0'
|
||||
$maskedtextbox2.TextAlign = 'Center'
|
||||
#
|
||||
# labelОт
|
||||
#
|
||||
$labelОт.AutoSize = $True
|
||||
$labelОт.Font = [System.Drawing.Font]::new('Lucida Console', '8.25')
|
||||
$labelОт.Location = New-Object System.Drawing.Point(15, 92)
|
||||
$labelОт.Name = 'labelОт'
|
||||
$labelОт.Size = New-Object System.Drawing.Size(19, 11)
|
||||
$labelОт.TabIndex = 10
|
||||
$labelОт.Text = 'От'
|
||||
#
|
||||
# maskedtextbox3
|
||||
#
|
||||
$maskedtextbox3.Font = [System.Drawing.Font]::new('Tahoma', '8.25')
|
||||
$maskedtextbox3.Location = New-Object System.Drawing.Point(128, 87)
|
||||
$maskedtextbox3.Name = 'maskedtextbox3'
|
||||
$maskedtextbox3.Size = New-Object System.Drawing.Size(50, 21)
|
||||
$maskedtextbox3.TabIndex = 8
|
||||
$maskedtextbox3.Text = '100'
|
||||
$maskedtextbox3.TextAlign = 'Center'
|
||||
#
|
||||
# buttonНачатьПоиск
|
||||
#
|
||||
$buttonНачатьПоиск.Location = New-Object System.Drawing.Point(333, 336)
|
||||
$buttonНачатьПоиск.Name = 'buttonНачатьПоиск'
|
||||
$buttonНачатьПоиск.Size = New-Object System.Drawing.Size(99, 23)
|
||||
$buttonНачатьПоиск.TabIndex = 1
|
||||
$buttonНачатьПоиск.Text = 'Начать поиск'
|
||||
$buttonНачатьПоиск.UseVisualStyleBackColor = $True
|
||||
$buttonНачатьПоиск.add_Click($buttonНачатьПоиск_Click)
|
||||
#
|
||||
# buttonВыйти
|
||||
#
|
||||
$buttonВыйти.Location = New-Object System.Drawing.Point(252, 336)
|
||||
$buttonВыйти.Name = 'buttonВыйти'
|
||||
$buttonВыйти.Size = New-Object System.Drawing.Size(75, 23)
|
||||
$buttonВыйти.TabIndex = 0
|
||||
$buttonВыйти.TabStop = $False
|
||||
$buttonВыйти.Text = 'Выйти'
|
||||
$buttonВыйти.UseVisualStyleBackColor = $True
|
||||
$buttonВыйти.add_Click($buttonВыйти_Click)
|
||||
$groupbox2.ResumeLayout()
|
||||
$groupbox1.ResumeLayout()
|
||||
$formПоискКлиентаSpotify.ResumeLayout()
|
||||
|
||||
#Save the initial state of the form
|
||||
$InitialFormWindowState = $formПоискКлиентаSpotify.WindowState
|
||||
#Init the OnLoad event to correct the initial state of the form
|
||||
$formПоискКлиентаSpotify.add_Load($Form_StateCorrection_Load)
|
||||
#Clean up the control events
|
||||
$formПоискКлиентаSpotify.add_FormClosed($Form_Cleanup_FormClosed)
|
||||
#Show the Form
|
||||
return $formПоискКлиентаSpotify.ShowDialog()
|
||||
|
||||
}
|
||||
|
||||
#Call the form
|
||||
Show-Search_psf | Out-Null
|
||||
Loading…
Reference in a new issue