Skip to content

Commit d9feca4

Browse files
authored
Dev (#11)
* Implemented option to keep Subloader window always on top plus some refactorings * #10 : Implemented feature that allows users to download multiple files in directory where video file is located or in separate Subs folder * style fixes * Refactored settings logic * Some folder reorganization * Main Control UI refactor plus fix save search by settings * Tiny task refactors * Added overwrite same language file option, and updated readme * settings screenshot update
1 parent 6319b78 commit d9feca4

23 files changed

+347
-229
lines changed

.editorconfig

+20-15
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,10 @@ visual_basic_preferred_modifier_order = Partial,Default,Private,Protected,Public
101101
dotnet_style_readonly_field = true:warning
102102
# Parentheses preferences
103103
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#parentheses-preferences
104-
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:warning
105-
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:warning
106-
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:warning
107-
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:suggestion
104+
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:silent
105+
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:silent
106+
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:silent
107+
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:warning
108108
# Expression-level preferences
109109
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#expression-level-preferences
110110
dotnet_style_object_initializer = true:warning
@@ -114,8 +114,8 @@ dotnet_style_prefer_inferred_tuple_names = true:warning
114114
dotnet_style_prefer_inferred_anonymous_type_member_names = true:warning
115115
dotnet_style_prefer_auto_properties = true:warning
116116
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:warning
117-
dotnet_style_prefer_conditional_expression_over_assignment = false:suggestion
118-
dotnet_style_prefer_conditional_expression_over_return = false:suggestion
117+
dotnet_style_prefer_conditional_expression_over_assignment = true:suggestion
118+
dotnet_style_prefer_conditional_expression_over_return = true:suggestion
119119
dotnet_style_prefer_compound_assignment = true:warning
120120
# Null-checking preferences
121121
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#null-checking-preferences
@@ -140,18 +140,21 @@ csharp_style_var_when_type_is_apparent = true:warning
140140
csharp_style_var_elsewhere = true:warning
141141
# Expression-bodied members
142142
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#expression-bodied-members
143-
csharp_style_expression_bodied_methods = true:warning
144-
csharp_style_expression_bodied_constructors = true:warning
145-
csharp_style_expression_bodied_operators = true:warning
146-
csharp_style_expression_bodied_properties = true:warning
147-
csharp_style_expression_bodied_indexers = true:warning
148-
csharp_style_expression_bodied_accessors = true:warning
149-
csharp_style_expression_bodied_lambdas = true:warning
150-
csharp_style_expression_bodied_local_functions = true:warning
143+
csharp_style_expression_bodied_accessors = when_on_single_line:warning
144+
csharp_style_expression_bodied_constructors = false:warning
145+
csharp_style_expression_bodied_indexers = when_on_single_line:warning
146+
csharp_style_expression_bodied_lambdas = when_on_single_line:warning
147+
csharp_style_expression_bodied_local_functions = when_on_single_line:warning
148+
csharp_style_expression_bodied_methods = false:warning
149+
csharp_style_expression_bodied_operators = when_on_single_line:warning
150+
csharp_style_expression_bodied_properties = when_on_single_line:warning
151151
# Pattern matching
152152
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#pattern-matching
153153
csharp_style_pattern_matching_over_is_with_cast_check = true:warning
154154
csharp_style_pattern_matching_over_as_with_null_check = true:warning
155+
csharp_style_prefer_not_pattern = true:warning
156+
csharp_style_prefer_pattern_matching = true:warning
157+
csharp_style_prefer_switch_expression = true:warning
155158
# Inlined variable declarations
156159
# https://docs.microsoft.com/visualstudio/ide/editorconfig-language-conventions#inlined-variable-declarations
157160
csharp_style_inlined_variable_declaration = true:warning
@@ -435,7 +438,9 @@ dotnet_naming_rule.parameters_rule.severity = warning
435438
##########################################
436439

437440
# IDE0002: Name can be simplified
438-
# dotnet_diagnostic.IDE0002.severity = warning
441+
dotnet_diagnostic.IDE0002.severity = warning
439442

440443
# IDE0005: Remove unnecessary imports
441444
dotnet_diagnostic.IDE0005.severity = warning
445+
dotnet_diagnostic.IDE0058.severity = none
446+
dotnet_diagnostic.IDE1006.severity = none

README.md

+22-9
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,55 @@
33
# Subloader
44
![](https://img.shields.io/badge/Price-Free-brightgreen.svg)
55
![](https://img.shields.io/badge/License-MIT-blue.svg)
6-
![](https://img.shields.io/badge/Release-1.3.0-blue.svg)
6+
![](https://img.shields.io/badge/Release-1.4.0-blue.svg)
77

88
**Subloader** is a simple and minimalistic software written in **C#** and **.NET Core 3.1** 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. It will also follow Windows 10 accent color for UI main color.
1111

12-
Search and download is provided by **[Opensubtitles](http://www.opensubtitles.org/)**. Big thanks to their team for this great project. Please consider showing your appreciation by **[supporting them](https://www.opensubtitles.org/en/support)**.
12+
Search and download is provided by **[Opensubtitles](http://www.opensubtitles.org/)**. Big thanks to their team, please consider showing your appreciation by **[supporting them](https://www.opensubtitles.org/en/support)**.
1313

1414
### Installation
1515

1616
Subloader requires **[.NET Core 3.1 Runtime](https://dotnet.microsoft.com/download)** to run. It was developed in Visual Studio Community 2019.
1717

1818
Download the **[latest version of Subloader](https://github.com/Valyreon/Subloader/releases)**, run the setup and that's it. You can now right click your video file and get your subtitles in a matter of seconds. Enjoy!
1919

20+
#### Manual installation
21+
22+
To compile Subloader yourself you don't have to install Visual Studio, just .NET Core 3.1 SDK. Go to the Subloader folder that contains the solution, open terminal and run:
23+
24+
```
25+
dotnet publish SubloaderWpf -p:PublishSingleFile=true --no-self-contained -r win-x64 -o .
26+
```
27+
28+
This will output the compiled exe file in the current directory. Generated pdb files are not neccessary.
29+
2030
### Usage
2131

22-
Subloader can be opened from Start Menu, and then using the 'Open' button you can choose a video file. Search will begin immediately.
32+
Subloader can be opened from Start Menu, and then using the 'Open' button you can choose a video file. Search will begin immediately. Installer will also add 'Find subtitles' menu in right click context menu of .avi, .mkv and .mp4 files for easy access.
2333

2434
After the search is complete, you can select a subtitle from the list and click 'Download' or doubleclick the subtitle.
2535

26-
When you click 'Download' Subloader will download subtitle in the same directory where video file is, under the same name and appropriate extension. If there is an existing subtitle with the same name, it will overwrite it.
36+
When you click 'Download' or double click an item in the table Subloader will download the subtitle. The name and location of the file depends on Settings, default (without options below checked) behaviour is to download subtitles into a file that is the same name as the video file with a different extension.
2737

2838
Depending on the time of day, Opensubtitles server will sometimes be busy and you will get a 'Service temporarily unavailable'. In that case, try clicking 'Refresh' a few times.
2939

30-
Installer will also add 'Find subtitles' menu in right click context menu of .avi, .mkv and .mp4 files for easy access.
40+
In **Settings** you can configure wanted **subtitle languages** as well as other options:
3141

32-
SubLoader now has a working UI for configuring wanted subtitle languages. You can access it via 'Settings' button on the main form in the bottom right corner.
42+
* **Always on top** - When checked, Subloader will stay above other windows.
43+
* **Allow multiple downloads** - If this option is checked Subloader will allow downloading multiple subtitle files named *movie-title.lang-id.format*, for example: *matrix-reloaded.eng.srt*. If user downloads multiple subtitles from the same language, the files will be named *movie-name.(1).lang-id.format*.
44+
* **Download to Subs folder** - This option allows user to download subtitles into a separate Subs folder in the same directory as the file. This option can be used only if option above is checked as well. The naming of the files is the same as for the option above.
45+
* **Overwrite same language files** - If checked, when user downloads multiple subtitles of the same language Subloader won't create multiple files named *movie-name.(1).lang-id.format*, *movie-name.(2).lang-id.format* etc. but overwrite the existing *movie-title.lang-id.format* file with the last downloaded subtitle.
3346

3447
### Acknowledgments
3548

3649
Icon made by **[Freepik](https://www.flaticon.com/authors/freepik)** from **[Flaticon](https://www.flaticon.com )**.
3750

3851
### Screenshots
39-
| | | |
40-
|:-------------------------:|:-------------------------:|:-------------------------:|
41-
|<img width="1604" alt="screenshot 1" src="https://raw.githubusercontent.com/Valyreon/Subloader/master/screenshot.png"> | <img width="1604" alt="screen shot 2017-08-07 at 12 18 15 pm" src="https://raw.githubusercontent.com/Valyreon/Subloader/master/screenshot2.png">|<img width="1604" alt="screen shot 2017-08-07 at 12 18 15 pm" src="https://raw.githubusercontent.com/Valyreon/Subloader/master/screenshot3.png">|
52+
| | |
53+
|:-------------------------:|:-------------------------:|
54+
| <img width="1604" alt="screen shot 2017-08-07 at 12 18 15 pm" src="https://raw.githubusercontent.com/Valyreon/Subloader/master/screenshot3.png">|<img width="1604" alt="screen shot 2017-08-07 at 12 18 15 pm" src="https://raw.githubusercontent.com/Valyreon/Subloader/master/screenshot2.png">|
4255

4356
### To do
4457
- ~~**Language settings window**~~

SubloaderWpf/App.xaml.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using System;
22
using System.Threading;
33
using System.Windows;
4-
using SubloaderWpf.Models;
54
using SubloaderWpf.Utilities;
65

76
namespace SubloaderWpf
@@ -13,6 +12,8 @@ public partial class App : Application
1312

1413
public string PathArg { get; set; }
1514

15+
public static Settings Settings { get; } = SettingsParser.Load();
16+
1617
protected override void OnStartup(StartupEventArgs e)
1718
{
1819
if (e.Args.Length > 0)
@@ -47,7 +48,6 @@ protected override void OnStartup(StartupEventArgs e)
4748

4849
private void ApplicationExit(object sender, ExitEventArgs e)
4950
{
50-
ApplicationSettings.Instance.SaveIfDirty();
5151
Cleanup();
5252
}
5353

SubloaderWpf/ViewModels/INavigator.cs renamed to SubloaderWpf/Interfaces/INavigator.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace SubloaderWpf.ViewModels
1+
namespace SubloaderWpf.Interfaces
22
{
33
public interface INavigator
44
{

SubloaderWpf/Models/ApplicationSettings.cs

-132
This file was deleted.

SubloaderWpf/Models/Settings.cs

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
using System.Collections.Generic;
2+
3+
namespace SubloaderWpf.Utilities
4+
{
5+
public class Settings
6+
{
7+
public bool IsByNameChecked { get; set; } = false;
8+
9+
public bool IsByHashChecked { get; set; } = true;
10+
11+
public bool KeepWindowOnTop { get; set; } = true;
12+
13+
public bool DownloadToSubsFolder { get; set; } = false;
14+
15+
public bool AllowMultipleDownloads { get; set; } = false;
16+
17+
public bool OverwriteSameLanguageSub { get; set; } = false;
18+
19+
public IEnumerable<SubtitleLanguage> WantedLanguages { get; set; } = new List<SubtitleLanguage>();
20+
}
21+
}

SubloaderWpf/Models/SubtitleEntry.cs

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
using System.ComponentModel;
22
using SuppliersLibrary;
33

4-
namespace SubloaderWpf.Models
4+
namespace SubloaderWpf.Utilities
55
{
66
public class SubtitleEntry : INotifyPropertyChanged
77
{
8-
public SubtitleEntry(ISubtitleResultItem item) => Model = item;
8+
public SubtitleEntry(ISubtitleResultItem item)
9+
{
10+
Model = item;
11+
}
912

1013
public event PropertyChangedEventHandler PropertyChanged;
1114

@@ -15,7 +18,9 @@ public class SubtitleEntry : INotifyPropertyChanged
1518

1619
public ISubtitleResultItem Model { get; }
1720

18-
protected void OnPropertyChanged(string name) =>
21+
protected void OnPropertyChanged(string name)
22+
{
1923
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
24+
}
2025
}
2126
}

SubloaderWpf/Models/SubtitleLanguage.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using System.Collections.Generic;
22

3-
namespace SubloaderWpf.Models
3+
namespace SubloaderWpf.Utilities
44
{
55
public class SubtitleLanguage
66
{

SubloaderWpf/Utilities/InstanceMediator.cs

+6-3
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ public class InstanceMediator
1515

1616
public void StartListening()
1717
{
18-
var x = Task.Run(() =>
18+
Task.Run(() =>
1919
{
2020
while (true)
2121
{
22-
using var server = new NamedPipeServerStream(NamedPipeName as string);
22+
using var server = new NamedPipeServerStream(NamedPipeName);
2323
server.WaitForConnection();
2424

2525
using var reader = new StreamReader(server);
@@ -30,7 +30,10 @@ public void StartListening()
3030
}, tokenSource.Token);
3131
}
3232

33-
public void StopListening() => tokenSource.Cancel();
33+
public void StopListening()
34+
{
35+
tokenSource.Cancel();
36+
}
3437

3538
public static void SendArgumentToRunningInstance(string arg)
3639
{

0 commit comments

Comments
 (0)