Skip to content

Commit afd04b4

Browse files
authored
Merge pull request #5 from Valyreon/dev
Dev
2 parents 30e380d + a9797c0 commit afd04b4

26 files changed

+937
-385
lines changed

.editorconfig

+441
Large diffs are not rendered by default.

NSIS/Newtonsoft.Json.dll

-660 KB
Binary file not shown.

NSIS/SubtitleSuppliers.dll

-12 KB
Binary file not shown.

NSIS/script.nsi

+20-47
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ Section "Install"
2424
SetOutPath "$INSTDIR"
2525

2626
File "SubLoad.exe"
27-
File "SubtitleSuppliers.dll"
28-
File "Newtonsoft.Json.dll"
2927

3028
;create start-menu items
3129
CreateDirectory "$SMPROGRAMS\Subloader"
@@ -37,50 +35,28 @@ Section "Install"
3735
WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Subloader" "UninstallString" "$INSTDIR\Uninstall.exe"
3836

3937
;CONTEXT REGISTRY COMMANDS
40-
Var /GLOBAL defaultAvi
41-
Var /GLOBAL defaultMp4
42-
Var /GLOBAL defaultMkv
43-
44-
ReadRegStr $defaultAvi HKEY_CLASSES_ROOT .avi ""
45-
ReadRegStr $defaultMp4 HKEY_CLASSES_ROOT .mp4 ""
46-
ReadRegStr $defaultMkv HKEY_CLASSES_ROOT .mkv ""
47-
48-
;HKEY_CURRENT_USER\Software\Classes\jpegfile\shell
38+
Var /GLOBAL extPath
4939

40+
StrCpy $extPath "SystemFileAssociations\.avi"
5041
DetailPrint "Writing registry keys for AVI context menu"
5142
;AVI
52-
WriteRegStr HKEY_CLASSES_ROOT "$defaultAvi\shell\Subloader" "" "Find subtitles"
53-
WriteRegStr HKEY_CLASSES_ROOT "$defaultAvi\shell\Subloader" "Icon" '"$INSTDIR\SubLoad.exe"'
54-
WriteRegStr HKEY_CLASSES_ROOT "$defaultAvi\shell\Subloader\command" "" '"$INSTDIR\SubLoad.exe" "%1"'
55-
;IN HKCU
56-
WriteRegStr HKEY_LOCAL_MACHINE "Software\Classes\$defaultAvi\shell\Subloader" "" "Find subtitles"
57-
WriteRegStr HKEY_LOCAL_MACHINE "Software\Classes\$defaultAvi\shell\Subloader" "Icon" '"$INSTDIR\SubLoad.exe"'
58-
WriteRegStr HKEY_LOCAL_MACHINE "Software\Classes\$defaultAvi\shell\Subloader\command" "" '"$INSTDIR\SubLoad.exe" "%1"'
43+
WriteRegStr HKEY_CLASSES_ROOT "$extPath\shell\Subloader" "" "Find subtitles"
44+
WriteRegStr HKEY_CLASSES_ROOT "$extPath\shell\Subloader" "Icon" '"$INSTDIR\SubLoad.exe"'
45+
WriteRegStr HKEY_CLASSES_ROOT "$extPath\shell\Subloader\command" "" '"$INSTDIR\SubLoad.exe" "%1"'
5946

47+
StrCpy $extPath "SystemFileAssociations\.mp4"
6048
DetailPrint "Writing registry keys for MP4 context menu"
6149
;for mp4
62-
WriteRegStr HKEY_CLASSES_ROOT "$defaultMp4\shell\Subloader" "" "Find subtitles"
63-
WriteRegStr HKEY_CLASSES_ROOT "$defaultMp4\shell\Subloader" "Icon" '"$INSTDIR\SubLoad.exe"'
64-
WriteRegStr HKEY_CLASSES_ROOT "$defaultMp4\shell\Subloader\command" "" '"$INSTDIR\SubLoad.exe" "%1"'
65-
;IN HKCU
66-
WriteRegStr HKEY_LOCAL_MACHINE "Software\Classes\$defaultMp4\shell\Subloader" "" "Find subtitles"
67-
WriteRegStr HKEY_LOCAL_MACHINE "Software\Classes\$defaultMp4\shell\Subloader" "Icon" '"$INSTDIR\SubLoad.exe"'
68-
WriteRegStr HKEY_LOCAL_MACHINE "Software\Classes\$defaultMp4\shell\Subloader\command" "" '"$INSTDIR\SubLoad.exe" "%1"'
50+
WriteRegStr HKEY_CLASSES_ROOT "$extPath\shell\Subloader" "" "Find subtitles"
51+
WriteRegStr HKEY_CLASSES_ROOT "$extPath\shell\Subloader" "Icon" '"$INSTDIR\SubLoad.exe"'
52+
WriteRegStr HKEY_CLASSES_ROOT "$extPath\shell\Subloader\command" "" '"$INSTDIR\SubLoad.exe" "%1"'
6953

54+
StrCpy $extPath "SystemFileAssociations\.mkv"
7055
DetailPrint "Writing registry keys for MKV context menu"
7156
;for mkv
72-
WriteRegStr HKEY_CLASSES_ROOT "$defaultMkv\shell\Subloader" "" "Find subtitles"
73-
WriteRegStr HKEY_CLASSES_ROOT "$defaultMkv\shell\Subloader" "Icon" '"$INSTDIR\SubLoad.exe"'
74-
WriteRegStr HKEY_CLASSES_ROOT "$defaultMkv\shell\Subloader\command" "" '"$INSTDIR\SubLoad.exe" "%1"'
75-
;IN HKCU
76-
WriteRegStr HKEY_LOCAL_MACHINE "Software\Classes\$defaultMkv\shell\Subloader" "" "Find subtitles"
77-
WriteRegStr HKEY_LOCAL_MACHINE "Software\Classes\$defaultMkv\shell\Subloader" "Icon" '"$INSTDIR\SubLoad.exe"'
78-
WriteRegStr HKEY_LOCAL_MACHINE "Software\Classes\$defaultMkv\shell\Subloader\command" "" '"$INSTDIR\SubLoad.exe" "%1"'
79-
80-
;memorize for deletion
81-
WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Subloader" "aviCR" "$defaultAvi"
82-
WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Subloader" "mp4CR" "$defaultMp4"
83-
WriteRegStr HKEY_LOCAL_MACHINE "SOFTWARE\Subloader" "mkvCR" "$defaultMkv"
57+
WriteRegStr HKEY_CLASSES_ROOT "$extPath\shell\Subloader" "" "Find subtitles"
58+
WriteRegStr HKEY_CLASSES_ROOT "$extPath\shell\Subloader" "Icon" '"$INSTDIR\SubLoad.exe"'
59+
WriteRegStr HKEY_CLASSES_ROOT "$extPath\shell\Subloader\command" "" '"$INSTDIR\SubLoad.exe" "%1"'
8460

8561
;-------------------------
8662

@@ -99,24 +75,21 @@ Section "Uninstall"
9975

10076
Var /GLOBAL crVar
10177

102-
ReadRegStr $crVar HKEY_LOCAL_MACHINE "SOFTWARE\Subloader" "aviCR"
78+
StrCpy $crVar "SystemFileAssociations\.avi"
79+
;ReadRegStr $crVar HKEY_LOCAL_MACHINE "SOFTWARE\Subloader" "aviCR"
10380
DetailPrint "Deleting registry key: HKCR\$crVar\shell\Subloader"
10481
DeleteRegKey HKEY_CLASSES_ROOT "$crVar\shell\Subloader"
105-
DetailPrint "Deleting registry key: HKLM\Software\Classes\$crVar\shell\Subloader"
106-
DeleteRegKey HKEY_LOCAL_MACHINE "Software\Classes\$crVar\shell\Subloader"
10782

108-
ReadRegStr $crVar HKEY_LOCAL_MACHINE "SOFTWARE\Subloader" "mp4CR"
83+
StrCpy $crVar "SystemFileAssociations\.mp4"
84+
;ReadRegStr $crVar HKEY_LOCAL_MACHINE "SOFTWARE\Subloader" "mp4CR"
10985
DetailPrint "Deleting registry key: HKCR\$crVar\shell\Subloader"
11086
DeleteRegKey HKEY_CLASSES_ROOT "$crVar\shell\Subloader"
111-
DetailPrint "Deleting registry key: HKLM\Software\Classes\$crVar\shell\Subloader"
112-
DeleteRegKey HKEY_LOCAL_MACHINE "Software\Classes\$crVar\shell\Subloader"
11387

114-
ReadRegStr $crVar HKEY_LOCAL_MACHINE "SOFTWARE\Subloader" "mkvCR"
88+
StrCpy $crVar "SystemFileAssociations\.mkv"
89+
;ReadRegStr $crVar HKEY_LOCAL_MACHINE "SOFTWARE\Subloader" "mkvCR"
11590
DetailPrint "Deleting registry key: HKLM\$crVar\shell\Subloader"
11691
DeleteRegKey HKEY_CLASSES_ROOT "$crVar\shell\Subloader"
117-
DetailPrint "Deleting registry key: HKLM\Software\Classes\$crVar\shell\Subloader"
118-
DeleteRegKey HKEY_LOCAL_MACHINE "Software\Classes\$crVar\shell\Subloader"
119-
92+
12093
;Delete Start Menu Shortcuts
12194
Delete "$SMPROGRAMS\Subloader\*.*"
12295
RmDir "$SMPROGRAMS\Subloader"

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
![](https://img.shields.io/badge/License-MIT-blue.svg)
66
![](https://img.shields.io/badge/Release-1.2.0-blue.svg)
77

8-
**Subloader** is a simple and minimalistic software written in **C#** that enables you to quickly find and download subtitles for your movies and TV Shows. It interfaces with **Opensubtitles** database by using REST API for searching and downloading subtitles.
8+
**Subloader** is a simple and minimalistic software written in **C#** and **.NET Core 3.0** that enables you to quickly find and download subtitles for your movies and TV Shows. It interfaces with **Opensubtitles** database by using REST API for searching and downloading subtitles.
99

1010
Subloader searches subtitles by using a special file hash. This enables the user to get the best possible search results for their video file. **Installer** will also add an entry to **right click context menu** of **.avi**, **.mkv** and **.mp4** files for easy access. **Note:** This feature might not work on Windows 7.
1111

SubLoad.sln

+6-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ VisualStudioVersion = 16.0.29326.143
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SubloaderWpf", "SubloaderWpf\SubloaderWpf.csproj", "{2793A000-A5EE-47FB-8AD3-5952FFFC3C05}"
77
EndProject
8-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SuppliersLibrary", "SuppliersLibrary\SuppliersLibrary.csproj", "{71FD54B9-BA12-4557-B1BD-3FC54DF800FD}"
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SuppliersLibrary", "SuppliersLibrary\SuppliersLibrary.csproj", "{71FD54B9-BA12-4557-B1BD-3FC54DF800FD}"
9+
EndProject
10+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{63B9A7FC-E701-4B87-896B-C49031E68AD8}"
11+
ProjectSection(SolutionItems) = preProject
12+
.editorconfig = .editorconfig
13+
EndProjectSection
914
EndProject
1015
Global
1116
GlobalSection(SolutionConfigurationPlatforms) = preSolution

SubloaderWpf/App.xaml.cs

+9-13
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Configuration;
4-
using System.Data;
5-
using System.Linq;
6-
using System.Threading.Tasks;
71
using System.Windows;
82
using System.Windows.Controls;
93
using System.Windows.Input;
@@ -28,18 +22,19 @@ protected override void OnStartup(StartupEventArgs e)
2822
new RoutedEventHandler(SelectAllText));
2923
if (e.Args.Length > 0)
3024
{
31-
this.PathArg = e.Args[0];
32-
base.OnStartup(e);
25+
PathArg = e.Args[0];
3326
}
3427
base.OnStartup(e);
3528
}
3629

37-
void SelectivelyIgnoreMouseButton(object sender, MouseButtonEventArgs e)
30+
private void SelectivelyIgnoreMouseButton(object sender, MouseButtonEventArgs e)
3831
{
3932
// Find the TextBox
4033
DependencyObject parent = e.OriginalSource as UIElement;
4134
while (parent != null && !(parent is TextBox))
35+
{
4236
parent = VisualTreeHelper.GetParent(parent);
37+
}
4338

4439
if (parent != null)
4540
{
@@ -48,17 +43,18 @@ void SelectivelyIgnoreMouseButton(object sender, MouseButtonEventArgs e)
4843
{
4944
// If the text box is not yet focused, give it the focus and
5045
// stop further processing of this click event.
51-
textBox.Focus();
46+
_ = textBox.Focus();
5247
e.Handled = true;
5348
}
5449
}
5550
}
5651

57-
void SelectAllText(object sender, RoutedEventArgs e)
52+
private void SelectAllText(object sender, RoutedEventArgs e)
5853
{
59-
TextBox textBox = e.OriginalSource as TextBox;
60-
if (textBox != null)
54+
if (e.OriginalSource is TextBox textBox)
55+
{
6156
textBox.SelectAll();
57+
}
6258
}
6359
}
6460
}

SubloaderWpf/Models/ApplicationSettings.cs

+16-27
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.IO;
44
using System.Linq;
@@ -7,55 +7,46 @@ namespace SubloaderWpf.Models
77
{
88
public class ApplicationSettings
99
{
10-
private static ApplicationSettings _instance;
10+
private static ApplicationSettings instance;
1111

1212
public static ApplicationSettings GetInstance()
1313
{
14-
if (_instance == null)
14+
if (instance == null)
1515
{
1616
Refresh();
1717
}
18-
return _instance;
18+
return instance;
1919
}
2020

21-
public static void Refresh()
22-
{
23-
_instance = LoadApplicationSettings();
24-
}
21+
public static void Refresh() => instance = LoadApplicationSettings();
2522

2623
private List<SubtitleLanguage> wantedLanguages;
2724
public List<SubtitleLanguage> WantedLanguages
2825
{
29-
get
30-
{
31-
return wantedLanguages;
32-
}
26+
get => wantedLanguages;
3327
set
3428
{
3529
wantedLanguages = value;
3630
WriteApplicationSettings();
3731
}
3832
}
3933

40-
private ApplicationSettings(List<SubtitleLanguage> langWant)
41-
{
42-
wantedLanguages = langWant;
43-
}
34+
private ApplicationSettings(List<SubtitleLanguage> langWant) => wantedLanguages = langWant;
4435

4536
private static ApplicationSettings LoadApplicationSettings()
4637
{
4738
var appDataFolder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
48-
string pathToDefaultConfig = Path.Combine(appDataFolder, @"SubLoader\config.cfg");
39+
var pathToDefaultConfig = Path.Combine(appDataFolder, @"SubLoader\config.cfg");
4940
return LoadApplicationSettings(pathToDefaultConfig);
5041
}
5142

5243
private static ApplicationSettings LoadApplicationSettings(string path)
5344
{
54-
List<SubtitleLanguage> langs = new List<SubtitleLanguage>();
45+
var langs = new List<SubtitleLanguage>();
5546

5647
if (!File.Exists(path))
5748
{
58-
Directory.CreateDirectory(Path.GetDirectoryName(path));
49+
_ = Directory.CreateDirectory(Path.GetDirectoryName(path));
5950
File.Create(path).Close();
6051
}
6152

@@ -75,20 +66,18 @@ private static ApplicationSettings LoadApplicationSettings(string path)
7566
private static void WriteApplicationSettings()
7667
{
7768
var appDataFolder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
78-
string pathToDefaultConfig = Path.Combine(appDataFolder, @"SubLoader\config.cfg");
69+
var pathToDefaultConfig = Path.Combine(appDataFolder, @"SubLoader\config.cfg");
7970
WriteApplicationSettings(pathToDefaultConfig);
8071
}
8172

8273
private static void WriteApplicationSettings(string path)
8374
{
84-
Directory.CreateDirectory(Path.GetDirectoryName(path));
85-
using (var fileStream = new FileStream(path, FileMode.Create))
86-
using (var writer = new StreamWriter(fileStream))
75+
_ = Directory.CreateDirectory(Path.GetDirectoryName(path));
76+
using var fileStream = new FileStream(path, FileMode.Create);
77+
using var writer = new StreamWriter(fileStream);
78+
foreach (var x in GetInstance().WantedLanguages)
8779
{
88-
foreach (var x in GetInstance().WantedLanguages)
89-
{
90-
writer.WriteLine(x.Code);
91-
}
80+
writer.WriteLine(x.Code);
9281
}
9382
}
9483
}

SubloaderWpf/Models/SubtitleEntry.cs

+7-26
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,20 @@
1-
using SuppliersLibrary;
1+
using SuppliersLibrary;
22
using System.ComponentModel;
33

44
namespace SubloaderWpf.Models
55
{
66
public class SubtitleEntry: INotifyPropertyChanged
77
{
8-
private readonly ISubtitleResultItem model;
8+
public SubtitleEntry(ISubtitleResultItem item) => Model = item;
99

10-
public SubtitleEntry(ISubtitleResultItem item)
11-
{
12-
model = item;
13-
}
10+
public string Name => Model.Name;
1411

15-
public string Name
16-
{
17-
get
18-
{
19-
return model.Name;
20-
}
21-
}
12+
public string Language => Model.Language;
2213

23-
public string Language
24-
{
25-
get
26-
{
27-
return model.Language;
28-
}
29-
}
14+
public ISubtitleResultItem Model { get; }
3015

31-
public ISubtitleResultItem Model { get => model; }
32-
33-
protected void OnPropertyChanged(string name)
34-
{
35-
this.PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
36-
}
16+
protected void OnPropertyChanged(string name) =>
17+
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
3718

3819
public event PropertyChangedEventHandler PropertyChanged;
3920
}

SubloaderWpf/Models/SubtitleLanguage.cs

+3-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
using System;
21
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
62

73
namespace SubloaderWpf.Models
84
{
@@ -11,7 +7,7 @@ public class SubtitleLanguage
117
public string Name { get; }
128
public string Code { get; }
139

14-
private static readonly List<SubtitleLanguage> allLanguages = new List<SubtitleLanguage>()
10+
public static IEnumerable<SubtitleLanguage> AllLanguages { get; } = new List<SubtitleLanguage>()
1511
{
1612
new SubtitleLanguage("Afar", "aar"),
1713
new SubtitleLanguage("Abkhazian", "abk"),
@@ -489,12 +485,10 @@ public class SubtitleLanguage
489485
new SubtitleLanguage("Extremaduran", "ext"),
490486
};
491487

492-
public static IEnumerable<SubtitleLanguage> AllLanguages { get => allLanguages.AsEnumerable(); }
493-
494488
public SubtitleLanguage(string name, string code)
495489
{
496-
this.Name = name;
497-
this.Code = code;
490+
Name = name;
491+
Code = code;
498492
}
499493
}
500494
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
https://go.microsoft.com/fwlink/?LinkID=208121.
4+
-->
5+
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
6+
<PropertyGroup>
7+
<Configuration>Release</Configuration>
8+
<Platform>Any CPU</Platform>
9+
<PublishDir>bin\Release\netcoreapp3.1\publish\</PublishDir>
10+
<PublishProtocol>FileSystem</PublishProtocol>
11+
<TargetFramework>netcoreapp3.1</TargetFramework>
12+
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
13+
<SelfContained>false</SelfContained>
14+
<PublishSingleFile>True</PublishSingleFile>
15+
<PublishReadyToRun>False</PublishReadyToRun>
16+
</PropertyGroup>
17+
</Project>

0 commit comments

Comments
 (0)