Skip to content

Commit ac99339

Browse files
committed
Agent: Sort Title Fixes/Tweaks
- this fixes an issue found by a-bates where titles with the year appended in parenthesis could sort incorrectly outside of collections - note that the separator is an en dash and not a hyphen - update force-metadata to reflect this - additionally, prevent cases where a title that underwent common prefix modification would repeat itself (pre modification) in the sort title - bump versions snippet for updating everything without doing a full metadata refresh (insert into force-metadata.py's add original titles): `if series.title != series.titleSort: series.edit(**{'titleSort.value': series.titleSort.replace('[', '– ').replace(']', '')})`
1 parent e59f09a commit ac99339

4 files changed

Lines changed: 10 additions & 7 deletions

File tree

Contents/Code/__init__.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def Start():
1111
HTTP.CacheTime = 0.1 # Reduce the cache time as much as possible since Shoko has all the metadata
1212
ValidatePrefs()
1313
ordering = ' Single Season' if Prefs['SingleSeasonOrdering'] else ' Multi Seasons'
14-
Log('===============[Shoko Relay Agent v1.2.31%s]===============' % ordering)
14+
Log('===============[Shoko Relay Agent v1.2.32%s]===============' % ordering)
1515

1616
def GetApiKey():
1717
global API_KEY
@@ -92,8 +92,8 @@ def Update(self, metadata, media, lang, force):
9292
alt_title = try_get(series_titles, lang, None)
9393
if alt_title: break
9494

95-
# Append the Alternate title to the Sort Title to make it searchable
96-
if alt_title and alt_title != metadata.title: metadata.title_sort = title + ' ! [' + alt_title + ']'
95+
# Append the Alternate title to the Sort Title to make it searchable (padded with an en dash)
96+
if alt_title and alt_title != metadata.title and alt_title != revert_title(metadata.title): metadata.title_sort = title + ' ' + alt_title
9797
else: alt_title, metadata.title_sort = 'Alternate Title Matches the Title - Skipping!', title
9898
Log('Alt Title (AddToSort) [LANG]: %s [%s]' % (alt_title, lang.upper()))
9999

@@ -411,6 +411,9 @@ def title_case(text):
411411
for key, value in force_special.items(): text = re.sub(r'\b' + key + r'\b', value, text, flags=re.I) # Apply special cases as a last step
412412
return text
413413

414+
# revert common series title prefix modifications
415+
def revert_title(t): return t.split(' — ')[1] + ' ' + t.split(' — ')[0] if ' — ' in t else t
416+
414417
def try_get(arr, idx, default=''):
415418
try: return arr[idx]
416419
except Exception: return default

Contents/Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<string>Elevated</string>
1919
<key>PlexAgentAttributionText</key>
2020
<string>
21-
&lt;a href=&quot;https://github.com/natyusha/ShokoRelay.bundle&quot;&gt;Shoko Relay&lt;/a&gt; [v1.2.31] is natyusha's fork of &lt;a href=&quot;https://github.com/Cazzar/ShokoMetadata.bundle&quot;&gt;Shoko Metadata&lt;/a&gt; (created by Cazzar) and its v3 API migration (spearheaded by Harshith Mohan). It utilizes &lt;a href=&quot;https://shokoanime.com/&quot;&gt;Shoko Server&lt;/a&gt; in conjunction with metadata sourced from &lt;a href=&quot;https://anidb.net/&quot;&gt;AniDB&lt;/a&gt;, &lt;a href=&quot;https://www.themoviedb.org/&quot;&gt;TMDB&lt;/a&gt;, and &lt;a href=&quot;https://animethemes.moe/&quot;&gt;AnimeThemes&lt;/a&gt;.
21+
&lt;a href=&quot;https://github.com/natyusha/ShokoRelay.bundle&quot;&gt;Shoko Relay&lt;/a&gt; [v1.2.32] is natyusha's fork of &lt;a href=&quot;https://github.com/Cazzar/ShokoMetadata.bundle&quot;&gt;Shoko Metadata&lt;/a&gt; (created by Cazzar) and its v3 API migration (spearheaded by Harshith Mohan). It utilizes &lt;a href=&quot;https://shokoanime.com/&quot;&gt;Shoko Server&lt;/a&gt; in conjunction with metadata sourced from &lt;a href=&quot;https://anidb.net/&quot;&gt;AniDB&lt;/a&gt;, &lt;a href=&quot;https://www.themoviedb.org/&quot;&gt;TMDB&lt;/a&gt;, and &lt;a href=&quot;https://animethemes.moe/&quot;&gt;AnimeThemes&lt;/a&gt;.
2222
</string>
2323
</dict>
2424
</plist>

Contents/Scanners/Series/Shoko Relay Scanner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def Scan(path, files, mediaList, subdirs, language=None, root=None):
7070

7171
for subdir in subdirs: Log.debug('[Folder] %s' % os.path.relpath(subdir, root))
7272
ordering = ' Single Season' if cfg.getboolean('Prefs', 'SingleSeasonOrdering') else ' Multi Seasons'
73-
Log.info('===========================[Shoko Relay Scanner v1.2.31%s]%s' % (ordering, '=' * 230))
73+
Log.info('===========================[Shoko Relay Scanner v1.2.32%s]%s' % (ordering, '=' * 230))
7474

7575
if files:
7676
# Scan for video files

Contents/Scripts/force-metadata.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,10 @@
106106
elif season.title == 'Season -4': season.editTitle('Other')
107107
print('│╰─Finished Renaming Seasons!')
108108

109-
# add original titles if there are sort title additions from Shoko Relay
109+
# add original titles if there are sort title additions from Shoko Relay (denoted by an en dash)
110110
print(f"├┬Adding Original Titles @ {cfg.Plex['ServerName']}/{library}")
111111
for series in section.search(title=args.target):
112-
if series.title != series.titleSort: series.editOriginalTitle(series.titleSort.replace(series.title + ' [', '')[:-1], locked=False)
112+
if series.title != series.titleSort: series.editOriginalTitle(series.titleSort.replace(series.title + ' ', ''), locked=False)
113113
print('│╰─Finished Adding Original Titles!')
114114

115115
# clear any empty collections that are left over and set the sort title to match the title

0 commit comments

Comments
 (0)