Skip to content

Commit

Permalink
Allow to immediately select one subtitle with the addon settings
Browse files Browse the repository at this point in the history
  • Loading branch information
peno64 committed Nov 12, 2024
1 parent fb7c148 commit 641c3a5
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 40 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ The following subtitle extensions are allowed: .srt, .sub, .ssa, .ass, .idx, .sm
However if dual subtitles are chosen then only .srt subtitle files are allowed.
Since version 1.7.0 also a zip file with a subtitle is allowed. Both for single and dual subtitles.

The difference between with Kodi Settings and with Addon settings is that with Kodi settings the settings from Kodi settings are used: (Settings, Player, Language, Subtitles) (Font, size, ...)
With Addon Settings the settings defined in the Addon are used
The difference between single subtitle and dual subtitle is the following.
When Single Subtitle is chosen then only one subtitle can be chosen and when done it is used as is with the kodi setting (Settings, Player, Language, Subtitles) (Font, size, ...)
When Dual Subtitle is chosen then it is possible to select 2 subtitle files. The first selected file will be shown at the bottom, the second one on top (can be swapped).
When Dual Subtitle is chosen then it is possible to select 2 subtitle files.
There are 3 ways to show the two subtitles. Bottom, top or above each other at the bottom or next to each other at the bottom.
As such subtitles of two languages can be displayed at the same time. But it is also possible to only select one subtitle. This to also have the advantages of dual function functionality.
As extra several extra feastures are added in this case:
- Minimal time subtitles on screen: For the slow readers
Expand Down
7 changes: 5 additions & 2 deletions addon.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="service.subtitles.localsubtitle"
name="LocalSubtitle"
version="1.12.4"
version="1.12.5"
provider-name="peno">
<requires>
<import addon="script.module.pysubs2" version="0.1.0"/>
Expand All @@ -28,8 +28,9 @@ The following subtitle extensions are allowed: .srt, .sub, .ssa, .ass, .idx, .sm
However if dual subtitles are chosen then only .srt subtitle files are allowed.
Since version 1.7.0 also a zip file with a subtitle is allowed. Both for single and dual subtitles.

The difference between with Kodi Settings and with Addon settings is that with Kodi settings the settings from Kodi settings are used: (Settings, Player, Language, Subtitles) (Font, size, ...)
With Addon Settings the settings defined in the Addon are used
The difference between single subtitle and dual subtitle is the following.
When Single Subtitle is chosen then only one subtitle can be chosen and when done it is used as is with the kodi setting (Settings, Player, Language, Subtitles) (Font, size, ...)
When Dual Subtitle is chosen then it is possible to select 2 subtitle files.
There are 3 ways to show the two subtitles. Bottom, top or above each other at the bottom or next to each other at the bottom.
As such subtitles of two languages can be displayed at the same time. But it is also possible to only select one subtitle. This to also have the advantages of dual function functionality.
Expand All @@ -39,6 +40,8 @@ As extra several extra feastures are added in this case:
- Font, character set, color, ... selection: This overrules the kodi settings</description>
<disclaimer lang="en"></disclaimer>
<news>
v1.12.5 (2024-11-12)
- Add possibility to choose one subtitle with the addon settings. This was already possible via choosing Dual subtitle and then canceling on the question of the second subtitle.
v1.12.4 (2024-04-07)
- Add possibility to choose the Kodi selected subtitle font
v1.12.3 (2024-03-24)
Expand Down
42 changes: 22 additions & 20 deletions resources/language/English/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ msgstr ""
#English

msgctxt "#33001"
msgid "Manual search not supported"
msgid "Manual Search Not Supported"

msgctxt "#33002"
msgid "Browse Single Subtitle..."
msgid "Single Subtitle with Kodi Settings..."

msgctxt "#33003"
msgid "Choose Subtitle File"

msgctxt "#33004"
msgid "Browse Dual Subtitles..."
msgid "Dual Subtitles with Addon Settings..."

msgctxt "#33005"
msgid "Choose First Subtitle File"
Expand All @@ -33,17 +33,19 @@ msgctxt "#33006"
msgid "Choose Second Subtitle File"

msgctxt "#33007"
msgid "Zip file does not contain a supported subtitle file"
msgid "Zip File Does Not Contain a Supported Subtitle File"

msgctxt "#33008"
msgid "Addon Settings..."

msgctxt "#33009"
msgid "(Press Cancel for no subtitle)"
msgid "(Press Cancel for No second Subtitle)"

msgctxt "#33010"
msgid "These options only apply if Browse Dual Subtitles is chosen.\nNot for a single subtitle in which case standard Kodi settings are used."
msgid "These Options Only Apply if Subtitle(s) ...with Addon Settings... Is Chosen.\nNot for ...with Kodi Settings..."

msgctxt "#33011"
msgid "Single Subtitle with Addon Settings..."

msgctxt "#32507"
msgid "Bottom-Top"
Expand Down Expand Up @@ -76,7 +78,7 @@ msgctxt "#32516"
msgid "Black Translucent Background"

msgctxt "#32517"
msgid "Subtitle locations"
msgid "Subtitle Locations"

msgctxt "#32518"
msgid "Vertical Margin"
Expand All @@ -91,34 +93,34 @@ msgctxt "#32521"
msgid "Time Difference Threshold (milliseconds)"

msgctxt "#32522"
msgid "Enabling Auto Shift will try to sync the second subtitle with the first\naccording to the Time Difference Threshold"
msgid "Enabling Auto Shift Will Try to Sync the Second Subtitle With the First\nAccording to the Time Difference Threshold"

msgctxt "#32523"
msgid "The depth of the text shadow, in pixels"
msgid "The Depth of the Text Shadow, in Pixels"

msgctxt "#32524"
msgid "The width of the text outline, in pixels"
msgid "The Width of the Text Outline, in Pixels"

msgctxt "#32525"
msgid "Swap Bottom/Left - Top/Right subtitles"
msgid "Swap Bottom/Left - Top/Right Subtitles"

msgctxt "#32526"
msgid "Minimal Time (milliseconds) Subtitles On Screen"
msgid "Minimal Time (milliseconds) Subtitles on Screen"

msgctxt "#32527"
msgid "When this time is set, all subtitles are extended to stay on screen\nfor at least this time."
msgid "When This Time Is Set, All Subtitles Are Extended to Stay on Screen\nfor at Least This Time."

msgctxt "#32528"
msgid "However if a next subtitle occurs earlier this time is of course cut off.\nThis allows people that read slower to read the text."
msgid "However, If a Next Subtitle Occurs Earlier, This Time Is of Course Cut Off.\nThis Allows People That Read Slower to Read the Text."

msgctxt "#32529"
msgid "Character set"
msgid "Character Set"

msgctxt "#32530"
msgid "An error that a subtitle cannot be downloaded can popup after closing this message. Please ignore this since there is no work around for it to not display it."
msgid "An Error That a Subtitle Cannot Be Downloaded Can Popup After Closing This Message. Please Ignore This Since There Is No Workaround for It Not to Display This Message."

msgctxt "#32531"
msgid "Error loading subtitle file"
msgid "Error Loading Subtitle File"

msgctxt "#32532"
msgid "White"
Expand All @@ -127,10 +129,10 @@ msgctxt "#32533"
msgid "Yellow"

msgctxt "#32534"
msgid "Charset_normalizer not supported by Python 2 (kodi 18 or lower)"
msgid "Charset Normalizer Not Supported by Python 2 (Kodi 18 or Lower)"

msgctxt "#32535"
msgid "In Kodi Settings, Player, Subtitles, Font, the default font is selected which cannot be used. Please choose a specific font there or in this addon settings."
msgid "In Kodi Settings, Player, Subtitles, Font, the Default Font Is Selected Which Cannot Be Used. Please Choose a Specific Font There or in This Addon Settings."

msgctxt "#32536"
msgid "Unable to retrieve the subtitles font from Kodi Settings, Player, Subtitles, Font."
msgid "Unable to Retrieve the Subtitles Font from Kodi Settings, Player, Subtitles, Font."
36 changes: 20 additions & 16 deletions service.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def Search():
AddItem(__subtitle__, "plugin://%s/?action=download" % (__scriptid__))

AddItem(__language__(33002), "plugin://%s/?action=browse" % (__scriptid__))
AddItem(__language__(33011), "plugin://%s/?action=browsesingle" % (__scriptid__))
AddItem(__language__(33004), "plugin://%s/?action=browsedual" % (__scriptid__))
AddItem(__language__(33008), "plugin://%s/?action=settings" % (__scriptid__))

Expand Down Expand Up @@ -164,9 +165,11 @@ def Download(filename):
if subtitlefile != __subtitlepath__:
Download(subtitlefile)

elif params['action'] == 'browsedual':
elif params['action'] == 'browsesingle' or params['action'] == 'browsedual':
while True:
if __addon__.getSetting('dualsub_swap') == 'true':
if params['action'] == 'browsesingle':
title = __language__(33003)
elif __addon__.getSetting('dualsub_swap') == 'true':
title = __language__(33006)
else:
title = __language__(33005)
Expand All @@ -181,21 +184,22 @@ def Download(filename):
subs=[]
subs.append(subtitlefile1)

while True:
if __addon__.getSetting('dualsub_swap') == 'true':
title = __language__(33005)
else:
title = __language__(33006)
title = title + ' ' + __language__(33009)
subtitlefile2 = __msg_box__.browse(1, title, "video", ".zip|.srt", False, False, __subtitlepath__, False)
if subtitlefile2 == __subtitlepath__:
break
else:
if subtitlefile2.endswith('.zip'):
subtitlefile2 = unzip(subtitlefile2, [ ".srt" ])
if subtitlefile2 != None:
subs.append(subtitlefile2)
if params['action'] != 'browsesingle':
while True:
if __addon__.getSetting('dualsub_swap') == 'true':
title = __language__(33005)
else:
title = __language__(33006)
title = title + ' ' + __language__(33009)
subtitlefile2 = __msg_box__.browse(1, title, "video", ".zip|.srt", False, False, __subtitlepath__, False)
if subtitlefile2 == __subtitlepath__:
break
else:
if subtitlefile2.endswith('.zip'):
subtitlefile2 = unzip(subtitlefile2, [ ".srt" ])
if subtitlefile2 != None:
subs.append(subtitlefile2)
break

substemp=[]
for sub in subs:
Expand Down

0 comments on commit 641c3a5

Please sign in to comment.