Skip to content

Commit

Permalink
Change maxtitlelength behavior for Japanese/AlternateTitle (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
jvlflame committed Oct 11, 2020
1 parent 6ea64d6 commit b5720a9
Showing 1 changed file with 32 additions and 8 deletions.
40 changes: 32 additions & 8 deletions src/Javinizer/Private/Convert-JVString.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,41 @@ function Convert-JVString {
if ($maxTitleLength) {
if ($Data.Title.Length -ge $MaxTitleLength) {
$shortTitle = $Data.Title.Substring(0, $MaxTitleLength)
$splitTitle = $shortTitle -split ' '
if ($splitTitle.Count -gt 1) {
# Remove the last word of the title just in case it is cut off
$title = ($splitTitle[0..($splitTitle.Length - 2)] -join ' ')
if ($title[-1] -match '\W') {
$Data.Title = ($title.Substring(0, $title.Length - 2)) + '...'
if ($shortTitle -match '[\u3040-\u309f]|[\u30a0-\u30ff]|[\uff66-\uff9f]|[\u4e00-\u9faf]') {
$Data.Title = $shortTitle + '...'
} else {
$splitTitle = $shortTitle -split ' '
if ($splitTitle.Count -gt 1) {
# Remove the last word of the title just in case it is cut off
$title = ($splitTitle[0..($splitTitle.Length - 2)] -join ' ')
if ($title[-1] -match '\W') {
$Data.Title = ($title.Substring(0, $title.Length - 2)) + '...'
} else {
$Data.Title = $title + '...'
}
} else {
$Data.Title = $title + '...'
$Data.Title = $shortTitle + '...'
}
}
}

if ($Data.AlternateTitle.Length -ge $MaxTitleLength) {
$shortTitle = $Data.AlternateTitle.Substring(0, $MaxTitleLength)
if ($shortTitle -match '[\u3040-\u309f]|[\u30a0-\u30ff]|[\uff66-\uff9f]|[\u4e00-\u9faf]') {
$Data.AlternateTitle = $shortTitle + '...'
} else {
$Data.Title = $shortTitle + '...'
$splitTitle = $shortTitle -split ' '
if ($splitTitle.Count -gt 1) {
# Remove the last word of the title just in case it is cut off
$title = ($splitTitle[0..($splitTitle.Length - 2)] -join ' ')
if ($title[-1] -match '\W') {
$Data.AlternateTitle = ($title.Substring(0, $title.Length - 2)) + '...'
} else {
$Data.AlternateTitle = $title + '...'
}
} else {
$Data.AlternateTitle = $shortTitle + '...'
}
}
}
}
Expand Down

0 comments on commit b5720a9

Please sign in to comment.