Skip to content
This repository has been archived by the owner on Jul 30, 2022. It is now read-only.

Commit

Permalink
Add support for customizing video titles
Browse files Browse the repository at this point in the history
  • Loading branch information
imaginary-upside committed Sep 15, 2020
1 parent 191155f commit 280b060
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 2 deletions.
7 changes: 7 additions & 0 deletions JellyfinJav/PluginConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@ public enum ActressNameOrder
LastFirst
}

public enum VideoDisplayName
{
CodeTitle,
Title
}

public class PluginConfiguration : BasePluginConfiguration
{
public ActressNameOrder actressNameOrder { get; set; } = ActressNameOrder.LastFirst;
public VideoDisplayName videoDisplayName { get; set; } = VideoDisplayName.Title;
}
}
2 changes: 1 addition & 1 deletion JellyfinJav/Providers/Javlibrary/JavlibraryProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public async Task<MetadataResult<Movie>> GetMetadata(MovieInfo info, Cancellatio
Item = new Movie
{
OriginalTitle = originalTitle,
Name = result.Value.Title,
Name = Utility.CreateVideoDisplayName(result.Value),
ProviderIds = new Dictionary<string, string> { { "Javlibrary", result.Value.Id } },
Studios = new[] { result.Value.Studio }.OfType<string>().ToArray(),
Genres = result.Value.Genres.ToArray()
Expand Down
2 changes: 1 addition & 1 deletion JellyfinJav/Providers/R18/R18Provider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public async Task<MetadataResult<Movie>> GetMetadata(MovieInfo info,
Item = new Movie
{
OriginalTitle = info.Name,
Name = video.Value.Title,
Name = Utility.CreateVideoDisplayName(video.Value),
PremiereDate = video.Value.ReleaseDate,
ProviderIds = new Dictionary<string, string> { { "R18", video.Value.Id } },
Studios = new[] { video.Value.Studio }.OfType<string>().ToArray(),
Expand Down
14 changes: 14 additions & 0 deletions JellyfinJav/Providers/Utility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,19 @@ public static string ExtractCodeFromFilename(string filename)
var match = rx.Match(filename);
return match?.Value.ToUpper();
}

public static string CreateVideoDisplayName(Api.Video video)
{
switch(Plugin.Instance.Configuration.videoDisplayName)
{
case VideoDisplayName.CodeTitle:
return video.Code + " " + video.Title;
case VideoDisplayName.Title:
return video.Title;
default:
// This should be impossible to reach.
return null;
}
}
}
}
11 changes: 11 additions & 0 deletions JellyfinJav/config_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@
<option id="LastFirst" value="LastFirst">Last Name - First Name</option>
</select>
</div>
<div class="selectContainer">
<label class="selectLabel" for="videoDisplayName">Video Display Name</label>
<select is="emby-select" id="videoDisplayName" name="videoDisplayName"
class="emby-select-withcolor emby-select">
<option id="CodeTitle" value="CodeTitle">Code Title</option>
<option id="Title" value="Title">Title</option>
</select>
</div>
<div>
<button is="emby-button" type="submit" class="raised button-submit block emby-button">
<span>Save</span>
Expand All @@ -34,12 +42,15 @@
$('#JellyfinJavConfigPage').on('pageshow', () => {
ApiClient.getPluginConfiguration(pluginUniqueId).then(config => {
$('#actressNameOrder').val(config.actressNameOrder).change();
$('#videoDisplayName').val(config.videoDisplayName).change();
});
});

$('#JellyfinJavConfigForm').on('submit', function () {
ApiClient.getPluginConfiguration(pluginUniqueId).then(config => {
config.actressNameOrder = $('#actressNameOrder').val();
config.videoDisplayName = $('#videoDisplayName').val();

ApiClient.updatePluginConfiguration(pluginUniqueId, config).then(function (result) {
Dashboard.processPluginConfigurationUpdateResult(result);
});
Expand Down

0 comments on commit 280b060

Please sign in to comment.