forked from ninthwalker/saverr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Saverr.ps1
2050 lines (1754 loc) · 97.1 KB
/
Saverr.ps1
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
################################
# Name: Saverr #
# Desc: d/l media from Plex #
# Author: Ninthwalker #
# Date: 15JUL2019 #
# Version: 1.0.1 #
################################
###### NOTES FOR USER #######
# See Instruction online at: https://github.com/ninthwalker/saverr
# Execution policy may need to be set to run powershell scripts if not using the shortcut or compiled .exe from Github.
# ie: Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
# Enforce TLS for plex.tv site if wanting. Uses HTTPS/SSL by default to retrieve plex tokens. May/may not break functionality depending on network setup.
#[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 -bor [Net.SecurityProtocolType]::Tls11 -bor [Net.SecurityProtocolType]::Tls
# If you need to increase the maximum downloads, please set this registry setting below to value desired.
# Bitstransfers default limit is 200. see: https://docs.microsoft.com/en-us/windows/desktop/bits/group-policies
# Path: HKLM\Software\Policies\Microsoft\Windows\BITS
# Dword: MaxFilesPerJob
# Decimal Value: Dealers Choice
#############################
####### DO NOT MODIFY #######
#############################
### setup environment ###
if ($MyInvocation.MyCommand.CommandType -eq "ExternalScript") {
$ScriptPath = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition
}
else {
$ScriptPath = Split-Path -Parent -Path ([Environment]::GetCommandLineArgs()[0])
if (!$ScriptPath) {
$ScriptPath = "."
}
}
# Set-Location $PSScriptRoot. Changed to above so it works with an .exe as well.
Set-Location $ScriptPath
#import Bitstransfer if not
if (!(Get-Module BitsTransfer)) {
Import-Module BitsTransfer
}
# Set timeout value for how long to wait for download to start before giving up
$timeout = 30
# Get maximum BITS files value if set
$bitsRegistry = 'HKLM:\Software\Policies\Microsoft\Windows\BITS'
$key = Get-Item -LiteralPath $bitsRegistry -ErrorAction SilentlyContinue
if ($key) {
$limit = $key.GetValue("MaxFilesPerJob", 200)
}
# diff ways of d/l. invoke-restmethod seems to fail sometimes while webclient method does not.
# Set-Alias -Name plx -Value Invoke-RestMethod -Scope Script
# download function shortcut
function plx {
Param([Parameter(Mandatory=$true)]
[string]$url
)
# Will timeout after 20sec by default
[xml](New-Object System.Net.WebClient).DownloadString($url)
}
# check invalid char's function
Function Remove-InvalidChars {
Param([Parameter(Mandatory=$true)]
[string]$name
)
$strip = $name -replace('[][]','')
$invalidChars = [IO.Path]::GetInvalidFileNameChars() -join ''
$re = "[{0}]" -f [RegEx]::Escape($invalidChars)
return ($strip -replace $re)
}
# download path function
Function Get-SavePath($initialDirectory) {
[System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms")|Out-Null
$foldername = New-Object System.Windows.Forms.FolderBrowserDialog
$foldername.Description = "Select a folder to save downloads to"
$foldername.rootfolder = "MyComputer"
if($foldername.ShowDialog() -eq "OK")
{
$folder += $foldername.SelectedPath
}
else {
$folder = $false
}
return $folder
}
# logging function
function logIt {
if ($debug) {
$e = $_.Exception
$line = $_.InvocationInfo.ScriptLineNumber
$msg = $e.Message
$eMSG = "$(Get-Date): caught exception: $e at $line. $msg"
$eMSG | Out-File ".\saverrLog.txt" -Append
}
}
# display size function
function byteSize($num)
{
$suffix = "B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"
$index = 0
while ($num -gt 1kb)
{
$num = $num / 1kb
$index++
}
"{0:N1} {1}" -f $num, $suffix[$index]
}
# this ended up causing issues with gettoken and doesn't seem to be needed after all.
# ignore cert error since it may be accessing by ip and cert would show as invalid if that's the case
# [System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
# Import settings
if (Test-Path .\saverrSettings.xml) {
$script:settings = Import-Clixml .\saverrSettings.xml
if (($settings.name -eq $null) -or ($settings.server -eq $null) -or ($settings.userToken -eq $null) -or ($settings.serverToken -eq $null) -or ($settings.dlPath -eq $null)) {
$errorMsg = "Settings are not fully configured.`nPlease click the gear icon before searching."
}
else {
$errorMsg = ""
}
}
else {
$errorMsg = "Settings file not detected. Please configure settings before searching."
}
# enable/disable debug
$debug = $settings.logging
# Plex signin for token url
$plexSignInUrl = "https://plex.tv/users/sign_in.xml"
# Plex servers list URL
$plexServersUrl = "https://plex.tv/pms/servers"
# init the cancel/pauseLoop variables
$script:cancelLoop = $false
$script:pauseLoop = $false
### Load required libraries ###
Add-Type -AssemblyName System.Windows.Forms, PresentationFramework, PresentationCore, WindowsBase, System.Drawing
[System.Windows.Forms.Application]::EnableVisualStyles()
################ Images ##################
# load these images inside the script so external calls arents
$plexImg = @'
iVBORw0KGgoAAAANSUhEUgAAAEsAAABLCAYAAAA4TnrqAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAOwgAADsIBFShKgAAAABl0RVh0U29mdHdhcmUAcGFpbnQubmV0IDQuMC4xMkM
Ea+wAABSISURBVHhe7VsHeFTVtg7v6X2QaZk5Z2oaIYEgICAg0vQKol70ItJsiCItnRaqIgFFRFEIRRGlXJpA6AlSREgPxVAMTZAWBCH0kgR4JLPev87MJJPkpEECgef6vv87bZ+91/
r3WmuvfTJx+Vv+lkdbKMLlv6i7y3/HRrg8Nqu/y+N8jMI1HlWztfh/JkxIan+za2yw3rSlr7b+1v7CC7FB+g9iA/XjtwaK82KDxBVbA/QxWwP1PwHRWwOEJbg/PS5IPzw2QNdtaz/dM
1v66X0Tg7y0qSCUHkUi2bCkYH1jGD98a4C4GNgGEtKBG0AOiLECtDVITyBPAp9LsD2zxgaKt+MCxQs4P4TzTXg2OSFY3/OXAQYjhnjoSauW0s2jRkIwvCdQv3RrkHgeRt6CsblbQMz6
vnpa2MNAkzsbaORLBur3rIHeam6kzk2N1Ano+rSRerY00MC2Bhr3ioFmdjfQyl56+rm/RCITeAeemAWyD8QFCcNTgvV+HMb2sR8O4TzzS4DOPTZY6BkXKCSCoKxfAvQU3VtPC94xUEQ
HA3VqYqTGvkby8TCRu9lEZqOJTKbiYTYbydNiIn9vE7Woa6Q+bQw0o5uBlr2npw39JO/LjQsSMxKCxZmYlKbrw3TqKh2irFxyoNEQFyyEg6DtUB6zzgTpqW8bIz1f30j1fGzkyBFSXj
DRTfyM1PEpI42F58X0QfiCNOAUxl8Z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AAABJRU5ErkJggg==
'@
# Image logo function
function DecodeBase64Image {
param ([Parameter(Mandatory=$true)][String]$ImageBase64)
$ObjBitmapImage = New-Object System.Windows.Media.Imaging.BitmapImage #Provides a specialized BitmapSource that is optimized for loading images using Extensible Application Markup Language (XAML).
$ObjBitmapImage.BeginInit() #Signals the start of the BitmapImage initialization.
$ObjBitmapImage.StreamSource = [System.IO.MemoryStream][System.Convert]::FromBase64String($ImageBase64) #Creates a stream whose backing store is memory.
$ObjBitmapImage.EndInit() #Signals the end of the BitmapImage initialization.
$ObjBitmapImage.Freeze() #Makes the current object unmodifiable and sets its IsFrozen property to true.
$ObjBitmapImage
}
$plexImgDecoded = DecodeBase64Image -ImageBase64 $plexImg
$loadingImgDecoded = DecodeBase64Image -ImageBase64 $loadingImg
$settingsImgDecoded = DecodeBase64Image -ImageBase64 $settingsImg
$loading = [System.Drawing.Bitmap][System.Drawing.Image]::FromStream($loadingImgDecoded.StreamSource)
$logo = [System.Drawing.Bitmap][System.Drawing.Image]::FromStream($plexImgDecoded.StreamSource)
$gear = [System.Drawing.Bitmap][System.Drawing.Image]::FromStream($settingsImgDecoded.StreamSource)
# Icon
$iconBase64 = $iconImg
$iconBytes = [Convert]::FromBase64String($IconBase64)
$stream = New-Object IO.MemoryStream($iconBytes, 0, $iconBytes.Length)
$stream.Write($iconBytes, 0, $iconBytes.Length);
#################### FORMS ##############################
#Defaults
$label_mediaTitle_default_xy = New-Object System.Drawing.Point(140,255)
$label_mediaRating_default_xy = New-Object System.Drawing.Point(140,275)
$label_mediaScore_default_xy = New-Object System.Drawing.Point(215,275)
$label_mediaSummary_default_xy = New-Object System.Drawing.Point(140,295)
$label_mediaSummary_default_height = 110
# main form
$form = New-Object system.Windows.Forms.Form
$form.ClientSize = '550,500'
$form.text = "Saverr"
$form.BackColor = "#4a4a4a"
$form.TopMost = $false
$form.StartPosition = 'CenterScreen'
$form.Icon = [System.Drawing.Icon]::FromHandle((New-Object System.Drawing.Bitmap -Argument $stream).GetHIcon())
$form.FormBorderStyle = "FixedDialog"
$form.MaximizeBox = $false
$label_title = New-Object system.Windows.Forms.Label
$label_title.text = "Saverr"
$label_title.AutoSize = $true
$label_title.width = 30
$label_title.height = 20
$label_title.location = New-Object System.Drawing.Point(143,12)
$label_title.Font = 'Microsoft Sans Serif,15,style=Bold'
$label_title.ForeColor = "#f5a623"
$pictureBox_logo = New-Object system.Windows.Forms.PictureBox
$pictureBox_logo.width = 75
$pictureBox_logo.height = 75
$pictureBox_logo.location = New-Object System.Drawing.Point(15,15)
$pictureBox_logo.image = $logo
$pictureBox_logo.SizeMode = [System.Windows.Forms.PictureBoxSizeMode]::normal
$pictureBox_thumb = new-object Windows.Forms.PictureBox
$pictureBox_thumb.ImageLocation = ""
$pictureBox_thumb.Visible = $false
$pictureBox_thumb.Width = 113 #680
$pictureBox_thumb.Height = 166 #1000
$pictureBox_thumb.Anchor = [System.Windows.Forms.AnchorStyles]::Top
$pictureBox_thumb.Location = New-object System.Drawing.Size(15,250)
$pictureBox_thumb.image = $loading
$pictureBox_thumb.SizeMode = [System.Windows.Forms.PictureBoxSizeMode]::Zoom
$label_search = New-Object system.Windows.Forms.Label
$label_search.text = "Search Movie:"
$label_search.AutoSize = $true
$label_search.width = 30
$label_search.height = 15
$label_search.location = New-Object System.Drawing.Point(15,105)
$label_search.Font = 'Microsoft Sans Serif,8'
$label_search.ForeColor = "#f5a623"
$textBox_search = New-Object system.Windows.Forms.TextBox
$textBox_search.multiline = $false
$textBox_search.text = ""
$textBox_search.width = 300
$textBox_search.height = 20
$textBox_search.location = New-Object System.Drawing.Point(15,125)
$textBox_search.Font = 'Microsoft Sans Serif,10'
$button_search = New-Object system.Windows.Forms.Button
$button_search.BackColor = "#f5a623"
$button_search.text = "Search"
$button_search.width = 80
$button_search.height = 25
$button_search.location = New-Object System.Drawing.Point(345,124)
$button_search.Font = 'Microsoft Sans Serif,9,style=Bold'
$button_search.FlatStyle = "Flat"
$button_download = New-Object system.Windows.Forms.Button
$button_download.Enabled = $false
$button_download.BackColor = "#f5a623"
$button_download.text = "Download"
$button_download.width = 80
$button_download.height = 25
$button_download.location = New-Object System.Drawing.Point(345,174)
$button_download.Font = 'Microsoft Sans Serif,9,style=Bold'
$button_download.FlatStyle = "Flat"
$button_settings = New-Object system.Windows.Forms.Button
$button_settings.width = 30
$button_settings.height = 30
$button_settings.location = New-Object System.Drawing.Point(508,8)
$button_settings.image = $gear
$button_settings.FlatStyle = "Flat"
$button_settings.BackColor = "Transparent"
$button_settings.FlatAppearance.BorderSize = 0
$button_settings.FlatAppearance.MouseDownBackColor = "Transparent"
$button_settings.FlatAppearance.MouseOverBackColor = "#666666"
$groupBox_type = New-Object system.Windows.Forms.Groupbox
$groupBox_type.height = 40
$groupBox_type.width = 285
$groupBox_type.text = "Select Media Type"
$groupBox_type.location = New-Object System.Drawing.Point(140,46)
$RadioButton_movie = New-Object system.Windows.Forms.RadioButton
$RadioButton_movie.text = "Movies"
$RadioButton_movie.AutoSize = $true
$RadioButton_movie.Checked = $true
$RadioButton_movie.width = 80
$RadioButton_movie.height = 20
$RadioButton_movie.location = New-Object System.Drawing.Point(15,16)
$RadioButton_movie.Font = 'Microsoft Sans Serif,9'
$RadioButton_movie.ForeColor = "#ffffff"
$RadioButton_tv = New-Object system.Windows.Forms.RadioButton
$RadioButton_tv.text = "TV Shows"
$RadioButton_tv.AutoSize = $true
$RadioButton_tv.width = 80
$RadioButton_tv.height = 20
$RadioButton_tv.location = New-Object System.Drawing.Point(110,16)
$RadioButton_tv.Font = 'Microsoft Sans Serif,9'
$RadioButton_tv.ForeColor = "#ffffff"
$RadioButton_music = New-Object system.Windows.Forms.RadioButton
$RadioButton_music.text = "Artists"
$RadioButton_music.AutoSize = $true
$RadioButton_music.width = 80
$RadioButton_music.height = 20
$RadioButton_music.location = New-Object System.Drawing.Point(215,16)
$RadioButton_music.Font = 'Microsoft Sans Serif,9'
$RadioButton_music.ForeColor = "#ffffff"
$label_results = New-Object system.Windows.Forms.Label
$label_results.text = "Results:"
$label_results.AutoSize = $true
$label_results.width = 30
$label_results.height = 15
$label_results.location = New-Object System.Drawing.Point(15,155)
$label_results.Font = 'Microsoft Sans Serif,8'
$label_results.ForeColor = "#f5a623"
$comboBox_results = New-Object system.Windows.Forms.ComboBox
$comboBox_results.text = ""
$comboBox_results.width = 300
$comboBox_results.height = 20
$comboBox_results.location = New-Object System.Drawing.Point(15,175)
$comboBox_results.Font = 'Microsoft Sans Serif,10'
$label_seasons = New-Object system.Windows.Forms.Label
$label_seasons.text = ""
$label_seasons.AutoSize = $true
$label_seasons.width = 30
$label_seasons.height = 15
$label_seasons.location = New-Object System.Drawing.Point(15,225)
$label_seasons.Font = 'Microsoft Sans Serif,8'
$label_seasons.ForeColor = "#f5a623"
$comboBox_seasons = New-Object system.Windows.Forms.ComboBox
$comboBox_seasons.Visible = $false
$comboBox_seasons.text = ""
$comboBox_seasons.width = 130
$comboBox_seasons.height = 20
$comboBox_seasons.location = New-Object System.Drawing.Point(65,215)
$comboBox_seasons.Font = 'Microsoft Sans Serif,10'
$label_episodes = New-Object system.Windows.Forms.Label
$label_episodes.text = ""
$label_episodes.AutoSize = $true
$label_episodes.width = 30
$label_episodes.height = 15
$label_episodes.location = New-Object System.Drawing.Point(215,225)
$label_episodes.Font = 'Microsoft Sans Serif,8'
$label_episodes.ForeColor = "#f5a623"
$comboBox_episodes = New-Object system.Windows.Forms.ComboBox
$comboBox_episodes.Visible = $false
$comboBox_episodes.text = ""
$comboBox_episodes.width = 45
$comboBox_episodes.height = 20
$comboBox_episodes.location = New-Object System.Drawing.Point(265,215)
$comboBox_episodes.Font = 'Microsoft Sans Serif,10'
$label_mediaTitle = New-Object system.Windows.Forms.Label
$label_mediaTitle.text = ""
$label_mediaTitle.AutoSize = $false
$label_mediaTitle.AutoEllipsis = $true
$label_mediaTitle.width = 400
$label_mediaTitle.height = 20
$label_mediaTitle.location = $label_mediaTitle_default_xy
$label_mediaTitle.Font = 'Microsoft Sans Serif,10,style=Bold'
$label_mediaTitle.ForeColor = "#f5a623"
$label_mediaRating = New-Object system.Windows.Forms.Label
$label_mediaRating.text = ""
$label_mediaRating.AutoSize = $true
$label_mediaRating.width = 50
$label_mediaRating.height = 20
$label_mediaRating.location = $label_mediaRating_default_xy
$label_mediaRating.Font = 'Microsoft Sans Serif,9,style=Bold'
$label_mediaRating.ForeColor = "#ffffff"
$label_mediaScore = New-Object system.Windows.Forms.Label
$label_mediaScore.text = ""
$label_mediaScore.AutoSize = $true
$label_mediaScore.width = 50
$label_mediaScore.height = 20
$label_mediaScore.location = $label_mediaScore_default_xy
$label_mediaScore.Font = 'Microsoft Sans Serif,9,style=Bold'
$label_mediaScore.ForeColor = "#ffffff"
$label_mediaSummary = New-Object system.Windows.Forms.Label
$label_mediaSummary.text = $errorMsg
$label_mediaSummary.AutoSize = $false
$label_mediaSummary.AutoEllipsis = $true
$label_mediaSummary.width = 400
$label_mediaSummary.height = $label_mediaSummary_default_height
$label_mediaSummary.location = $label_mediaSummary_default_xy
$label_mediaSummary.Font = 'Microsoft Sans Serif,9'
$label_mediaSummary.ForeColor = "#ffffff"
$label_DLTitle = New-Object system.Windows.Forms.Label
$label_DLTitle.text = ""
$label_DLTitle.AutoSize = $false
$label_DLTitle.AutoEllipsis = $true
$label_DLTitle.width = 440
$label_DLTitle.height = 20
$label_DLTitle.location = New-Object System.Drawing.Point(15,430)
$label_DLTitle.Font = 'Microsoft Sans Serif,9'
$label_DLTitle.ForeColor = "#f5a623"
$label_DLProgress = New-Object system.Windows.Forms.Label
$label_DLProgress.text = ""
$label_DLProgress.AutoSize = $false
$label_DLProgress.AutoEllipsis = $true
$label_DLProgress.width = 410
$label_DLProgress.height = 20
$label_DLProgress.location = New-Object System.Drawing.Point(15,455)
$label_DLProgress.Font = 'Microsoft Sans Serif,9'
$label_DLProgress.ForeColor = "#f5a623"
$button_cancel = New-Object system.Windows.Forms.Button
$button_cancel.Visible = $false
$button_cancel.BackColor = "#f5a623"
$button_cancel.text = "Cancel"
$button_cancel.width = 80
$button_cancel.height = 25
$button_cancel.location = New-Object System.Drawing.Point(456,470)
$button_cancel.Font = 'Microsoft Sans Serif,9,style=Bold'
$button_cancel.FlatStyle = "Flat"
$checkBoxButton_pause = New-Object System.Windows.Forms.Checkbox
$checkBoxButton_pause.location = New-Object System.Drawing.Point(456,440)
$checkBoxButton_pause.Size = New-Object System.Drawing.Size(80,25)
$checkBoxButton_pause.Appearance = [System.Windows.Forms.Appearance]::Button
$checkBoxButton_pause.Visible = $false
$checkBoxButton_pause.Text = "Pause"
$checkBoxButton_pause.FlatStyle = "Flat"
$checkBoxButton_pause.BackColor = "#f5a623"
$checkBoxButton_pause.width = 80
$checkBoxButton_pause.height = 25
$checkBoxButton_pause.TextAlign = "MiddleCenter"
$checkBoxButton_pause.AllowDrop = $false
$checkBoxButton_pause.Font = 'Microsoft Sans Serif,9,style=Bold'
$checkBoxButton_pause.FlatAppearance.BorderColor = "#000000"
$progressBar = New-Object system.Windows.Forms.ProgressBar
$progressBar.Name = 'progressBar1'
$progressBar.BackColor = "#f5a623"
$progressBar.ForeColor = "#f5a623"
$progressBar.width = 430
$progressBar.height = 12
$progressBar.location = New-Object System.Drawing.Point(15,480)
$progressBar.Value = 0
$progressBar.Style = "Continuous" #"Blocks"
$progressBar.Visible = $false
$progressBar.Minimum = 0
$progressBar.Maximum = 110
# add tooltips
$toolTip = New-Object System.Windows.Forms.ToolTip
$toolTip.SetToolTip($label_search, "Searches by first Letter. Excluding 'The' and 'A'")
$form.controls.AddRange(@($groupbox_type,$label_title,$pictureBox_logo,$pictureBox_thumb,$label_search,$textBox_search,$progressBar,$button_search,$button_download,$button_settings,$label_mediaTitle,$label_mediaScore,$comboBox_results,$comboBox_seasons,$comboBox_episodes,$label_mediaRating,$label_mediaSummary,$label_results,$label_seasons,$label_episodes,$label_DLTitle,$label_DLProgress,$button_cancel,$checkBoxButton_pause))
$groupBox_type.controls.AddRange(@($RadioButton_movie,$RadioButton_tv,$RadioButton_music))
# settings form
$form2 = New-Object system.Windows.Forms.Form
$form2.ClientSize = '550,500'
$form2.text = "Saverr Settings"
$form2.BackColor = "#4a4a4a"
$form2.TopMost = $false
$form2.StartPosition = 'CenterScreen'
$form2.Icon = [System.Drawing.Icon]::FromHandle((New-Object System.Drawing.Bitmap -Argument $stream).GetHIcon())
$form2.FormBorderStyle = "FixedDialog"
$form2.MaximizeBox = $false
$form2.StartPosition = "CenterParent"
$label2_title = New-Object system.Windows.Forms.Label
$label2_title.text = "Settings"
$label2_title.AutoSize = $true
$label2_title.width = 30
$label2_title.height = 20
$label2_title.location = New-Object System.Drawing.Point(143,12)
$label2_title.Font = 'Microsoft Sans Serif,15,style=Bold'
$label2_title.ForeColor = "#f5a623"
$label2_notice = New-Object system.Windows.Forms.Label
$label2_notice.text = "Username/password is not saved.`nOnly used to retrieve Plex token"
$label2_notice.AutoSize = $true
$label2_notice.width = 70
$label2_notice.height = 20
$label2_notice.location = New-Object System.Drawing.Point(143,50)
$label2_notice.Font = 'Microsoft Sans Serif,8'
$label2_notice.ForeColor = "#ffffff"
$pictureBox2_logo = New-Object system.Windows.Forms.PictureBox
$pictureBox2_logo.width = 75
$pictureBox2_logo.height = 75
$pictureBox2_logo.location = New-Object System.Drawing.Point(15,15)
$pictureBox2_logo.image = [System.Drawing.Bitmap][System.Drawing.Image]::FromStream($plexImgDecoded.StreamSource)
$pictureBox2_logo.SizeMode = [System.Windows.Forms.PictureBoxSizeMode]::normal
$label2_username = New-Object system.Windows.Forms.Label
$label2_username.text = "Plex Username:"
$label2_username.AutoSize = $true
$label2_username.width = 30
$label2_username.height = 20
$label2_username.location = New-Object System.Drawing.Point(15,121)
$label2_username.Font = 'Microsoft Sans Serif,8'
$label2_username.ForeColor = "#ffffff"
$textBox2_username = New-Object system.Windows.Forms.TextBox
$textBox2_username.multiline = $false
$textBox2_username.width = 225
$textBox2_username.height = 20
$textBox2_username.location = New-Object System.Drawing.Point(110,110)
$textBox2_username.Font = 'Microsoft Sans Serif,10'
$label2_password = New-Object system.Windows.Forms.Label
$label2_password.text = "Plex Password:"
$label2_password.AutoSize = $true
$label2_password.width = 70
$label2_password.height = 20
$label2_password.location = New-Object System.Drawing.Point(15,166)
$label2_password.Font = 'Microsoft Sans Serif,8'
$label2_password.ForeColor = "#ffffff"
$textBox2_password = New-Object system.Windows.Forms.TextBox
$textBox2_password.PasswordChar = '*'
$textBox2_password.multiline = $false
$textBox2_password.width = 225
$textBox2_password.height = 20
$textBox2_password.location = New-Object System.Drawing.Point(110,155)
$textBox2_password.Font = 'Microsoft Sans Serif,10'
$button2_getToken = New-Object system.Windows.Forms.Button
$button2_getToken.BackColor = "#f5a623"
$button2_getToken.text = "Get Token"
$button2_getToken.width = 95
$button2_getToken.height = 25
$button2_getToken.location = New-Object System.Drawing.Point(350,154)
$button2_getToken.Font = 'Microsoft Sans Serif,9,style=Bold'
$button2_getToken.FlatStyle = "Flat"
$label2_tokenStatus = New-Object system.Windows.Forms.Label
$label2_tokenStatus.text = ""
$label2_tokenStatus.AutoSize = $true
$label2_tokenStatus.width = 70
$label2_tokenStatus.height = 20
$label2_tokenStatus.location = New-Object System.Drawing.Point(350,180)
$label2_tokenStatus.Font = 'Microsoft Sans Serif,8'
$label2_tokenStatus.ForeColor = "#ffff00"
$label2_server = New-Object system.Windows.Forms.Label
$label2_server.text = "Select Server:"
$label2_server.AutoSize = $true
$label2_server.width = 70
$label2_server.height = 20
$label2_server.location = New-Object System.Drawing.Point(15,211)
$label2_server.Font = 'Microsoft Sans Serif,8'
$label2_server.ForeColor = "#ffffff"
$comboBox2_servers = New-Object system.Windows.Forms.ComboBox
$comboBox2_servers.text = $settings.name
$comboBox2_servers.width = 225
$comboBox2_servers.height = 20
$comboBox2_servers.location = New-Object System.Drawing.Point(110,200)
$comboBox2_servers.Font = 'Microsoft Sans Serif,10'
$label2_dlPath = New-Object system.Windows.Forms.Label
$label2_dlPath.text = "Download Path:"
$label2_dlPath.AutoSize = $true
$label2_dlPath.width = 70
$label2_dlPath.height = 20
$label2_dlPath.location = New-Object System.Drawing.Point(15,256)
$label2_dlPath.Font = 'Microsoft Sans Serif,8'
$label2_dlPath.ForeColor = "#ffffff"
$textBox2_dlPath = New-Object system.Windows.Forms.TextBox
$textBox2_dlPath.text = $settings.dlPath
$textBox2_dlPath.ReadOnly = $true
$textBox2_dlPath.multiline = $false
$textBox2_dlPath.width = 225
$textBox2_dlPath.height = 20
$textBox2_dlPath.location = New-Object System.Drawing.Point(110,245)
$textBox2_dlPath.Font = 'Microsoft Sans Serif,10'
$textBox2_dlPath.Enabled = $false
$button2_dlPath = New-Object system.Windows.Forms.Button
$button2_dlPath.BackColor = "#f5a623"
$button2_dlPath.text = "Select Path"
$button2_dlPath.width = 95
$button2_dlPath.height = 25
$button2_dlPath.location = New-Object System.Drawing.Point(350,244)
$button2_dlPath.Font = 'Microsoft Sans Serif,9,style=Bold'
$button2_dlPath.FlatStyle = "Flat"
$label2_pathStatus = New-Object system.Windows.Forms.Label
$label2_pathStatus.text = ""
$label2_pathStatus.AutoSize = $true
$label2_pathStatus.width = 70
$label2_pathStatus.height = 20
$label2_pathStatus.location = New-Object System.Drawing.Point(350,270)
$label2_pathStatus.Font = 'Microsoft Sans Serif,8'
$label2_pathStatus.ForeColor = "#ffff00"
$label2_debug = New-Object system.Windows.Forms.Label
$label2_debug.text = "Debug Logging:"
$label2_debug.AutoSize = $true
$label2_debug.width = 70
$label2_debug.height = 20
$label2_debug.location = New-Object System.Drawing.Point(15,300)
$label2_debug.Font = 'Microsoft Sans Serif,8'
$label2_debug.ForeColor = "#ffffff"
$checkBox_debug = New-Object System.Windows.Forms.Checkbox
$checkBox_debug.location = New-Object System.Drawing.Point(110,296)
$checkBox_debug.Size = New-Object System.Drawing.Size(80,25)
$checkBox_debug.width = 80
$checkBox_debug.height = 25
$checkBox_debug.checked = $settings.logging
$button2_servers = New-Object system.Windows.Forms.Button
$button2_servers.BackColor = "#f5a623"
$button2_servers.text = "List Servers"
$button2_servers.width = 95
$button2_servers.height = 25
$button2_servers.location = New-Object System.Drawing.Point(350,199)
$button2_servers.Font = 'Microsoft Sans Serif,9,style=Bold'
$button2_servers.FlatStyle = "Flat"
$label2_serverStatus = New-Object system.Windows.Forms.Label
$label2_serverStatus.text = ""
$label2_serverStatus.AutoSize = $true
$label2_serverStatus.width = 70
$label2_serverStatus.height = 20
$label2_serverStatus.location = New-Object System.Drawing.Point(350,225)
$label2_serverStatus.Font = 'Microsoft Sans Serif,8'
$label2_serverStatus.ForeColor = "#ffff00"
$label2_notice2 = New-Object system.Windows.Forms.Label
$label2_notice2.text = ""
$label2_notice2.AutoSize = $true
$label2_notice2.width = 70
$label2_notice2.height = 20
$label2_notice2.location = New-Object System.Drawing.Point(15,350)
$label2_notice2.Font = 'Microsoft Sans Serif,8'
$label2_notice2.ForeColor = "#ffffff"
$label2_saveStatus = New-Object system.Windows.Forms.Label
$label2_saveStatus.text = ""
$label2_saveStatus.AutoSize = $true
$label2_saveStatus.width = 70
$label2_saveStatus.height = 20
$label2_saveStatus.location = New-Object System.Drawing.Point(110,275)
$label2_saveStatus.Font = 'Microsoft Sans Serif,8'
$label2_saveStatus.ForeColor = "#00ff00"
$label2_help = New-Object system.Windows.Forms.LinkLabel
$label2_help.text = "Help"
$label2_help.AutoSize = $true
$label2_help.width = 70
$label2_help.height = 20
$label2_help.location = New-Object System.Drawing.Point(15,480)
$label2_help.Font = 'Microsoft Sans Serif,9'
$label2_help.ForeColor = "#00ff00"
$label2_help.LinkColor = "#f5a623"
$label2_help.ActiveLinkColor = "#f5a623"
$label2_help.add_Click({[system.Diagnostics.Process]::start("http://github.com/ninthwalker/saverr")})
$label2_version = New-Object system.Windows.Forms.Label
$label2_version.text = "Ver. 1.0.0"
$label2_version.AutoSize = $true
$label2_version.width = 70
$label2_version.height = 20
$label2_version.location = New-Object System.Drawing.Point(480,480)
$label2_version.Font = 'Microsoft Sans Serif,9'
$label2_version.ForeColor = "#f5a623"
$form2.controls.AddRange(@($label2_title,$label2_username,$label2_password,$label2_dlPath,$label2_server,$label2_pathStatus,$label2_serverStatus,$label2_notice,$label2_notice2,$label2_saveStatus,$label2_tokenStatus,$label2_help,$label2_version,$textBox2_username,$textBox2_password,$textBox2_dlPath,$label2_debug,$checkBox_debug,$comboBox2_servers,$button2_servers,$pictureBox2_logo,$button2_getToken,$button2_dlPath))
############################## CODE ################################
# search server for media. Movies/tv are by firstletter. Music is by artist.
function search {
Try {
# clear old searches
clearMediaInfo
clearDLStatus
$comboBox_results.Text = "Searching ..."
# get sections
$sections = "http://" + $settings.server + "/library/sections/" + "?X-Plex-Token=" + $settings.serverToken
$xmlsearch = plx $sections
#$sectionType = $groupBox_type.Controls | ? { $_.Checked } | Select-Object Text
# GUI Selection of 'type' to search for. Remove spaces and leading 'the' and 'a' since plex removes those from search words
$searchName = ($textBox_search.Text).TrimStart().TrimEnd()
$searchName = $searchName -replace '^the |^a ', ''
$sectionType = $groupBox_type.Controls | ? { $_.Checked -eq $true} | Select-Object Text
Switch ($sectionType.Text)
{
'Movies' {$script:type = "movie"
$subSection = "Video"; Break
}
'TV Shows' {$script:type = "show"
$subSection = "Directory"; Break
}
'Artists' {$script:type = "artist"
$subSection = "Directory"; Break
}
}
# get 'type' of key
$sections2search = $xmlsearch.MediaContainer.Directory | ? {$_.type -eq $type} | select key
$firstChar = $searchName.ToUpper()[0]
# Search movies/tv
if ($type -ne "artist") {
$sectionsList = new-object collections.generic.list[object]
foreach ($section in $sections2search) {
$sectionsUrl = "http://" + $settings.server + "/library/sections/$($section.key)/firstCharacter/$firstChar/" + "?X-Plex-Token=" + $settings.serverToken
$sectionsList.Add((plx $sectionsUrl))
}
# search through list for match
$script:searchResults = $sectionsList.MediaContainer.$subSection | ? {$_.title -like "*$searchName*" -and $_.type -eq $type} | select title,type,key,tagline,summary,year,contentrating,thumb,rating
}
#search artists
else {
$artistList = new-object collections.generic.list[object]
foreach ($section in $sections2search) {
$sectionsUrl = "http://" + $settings.server + "/library/sections/$($section.key)/all" + "?X-Plex-Token=" + $settings.serverToken
$artistList.Add((plx $sectionsUrl))
}
$script:searchResults = $artistList.MediaContainer.$subSection | ? {$_.title -like "*$searchName*" -and $_.type -eq $type} | select title,type,key,thumb
# search through list for match
$trackList = new-object collections.generic.list[object]
$artistPath = $artistsList.MediaContainer.$subSection | select key
foreach ($artist in $artistPath) {
$artistURL = "http://" + $settings.server + "$($artist.key)" + "?X-Plex-Token=" + $settings.serverToken
$trackList.Add((plx $artistURl))
}
}
#show results
if ($searchresults) {
$comboBox_results.Text = "$(@($searchResults).count) $($sectionType.Text) found!"
$comboBox_results.Text = "$(@($searchResults).count) $($sectionType.Text) found!"
foreach ($item in $searchresults) {
if ($type -ne "artist") {
if ($item.year) {
$comboBox_results.Items.Add($item.title + ' (' + $item.year + ')')
}
else {
$comboBox_results.Items.Add($item.title)
}
}
else {
$comboBox_results.Items.Add($item.title)
}
}
}
else {
$ComboBox_results.Text = "No results found!"
}
}
Catch {
$comboBox_results.Items.Clear()
$ComboBox_results.Text = "Error! Check settings/token/server status?"
logit
}
}
function mediaInfo {
clearDLStatus
$comboBox_index = $comboBox_results.SelectedIndex
$script:info = $searchResults[$comboBox_index] | Select title,type,key,tagline,summary,year,contentrating,thumb,rating,size
$thumb = "http://" + $settings.server + $info.thumb + "?X-Plex-Token=" + $settings.serverToken
# enable download button if no other downloads in progress
if (!(Get-BitsTransfer)) {
$button_download.Enabled = $true
}
if ($info.thumb) {
$pictureBox_thumb.ImageLocation = "$thumb"
$pictureBox_thumb.Visible = $true
}
else {
$pictureBox_thumb.ImageLocation = ""
$pictureBox_thumb.Image = $loading
$pictureBox_thumb.Visible = $true
}
if ($info.year) {
$label_mediaTitle.Text = "$($info.title) ($($info.year))"
}
else {
$label_mediaTitle.Text = "$($info.title)"
}
if ($info.contentrating) {
$label_mediaRating.Text = "$($info.contentrating)"
}
elseif ($type -ne "artist") {
$label_mediaRating.Text = "No Rating"
}
if ($info.rating) {
$label_mediaScore.Text = "$($info.rating)"
}
if ($info.summary) {
$label_mediaSummary.Text = "$($info.summary)"
}
# show season/ep boxes
if ($type -eq "show") {
#get seasons
$comboBox_seasons.Items.Clear()
$seasonPath = "http://" + $settings.server + "$($info.key)" + "?X-Plex-Token=" + $settings.serverToken
$xmlSeason = plx $seasonPath
$script:seasons = $xmlSeason.MediaContainer.directory | select title,key,index
foreach ($season in $seasons) {
$comboBox_seasons.Items.Add($season.title)
}
if (($comboBox_seasons.Items).count -ne "1" ) {
$comboBox_seasons.Text = $comboBox_seasons.items[1]
}
else {
$comboBox_seasons.Text = $comboBox_seasons.items[0]
}
}
if ($type -eq "artist") {
#get albums
$comboBox_seasons.Items.Clear()
$seasonPath = "http://" + $settings.server + "$($info.key)" + "?X-Plex-Token=" + $settings.serverToken
$xmlSeason = plx $seasonPath
$script:seasons = $xmlSeason.MediaContainer.directory | select title,key,index,year