torrent title and name are humanized

This commit is contained in:
Daniel Shleifman
2021-06-02 08:47:30 +03:00
parent 0ccf0caf32
commit 8696f6cd0b

View File

@@ -102,6 +102,17 @@ export default function DialogTorrentDetailsContent({ closeDialog, torrent }) {
const bufferSize = settings?.PreloadBuffer ? Capacity : 33554432 // Default is 32mb if PreloadBuffer is false const bufferSize = settings?.PreloadBuffer ? Capacity : 33554432 // Default is 32mb if PreloadBuffer is false
const getTitle = value => {
const torrentParsedName = value && ptt.parse(value)
const newNameStrings = []
if (torrentParsedName?.title) newNameStrings.push(` ${torrentParsedName?.title}`)
if (torrentParsedName?.year) newNameStrings.push(`. ${torrentParsedName?.year}.`)
if (torrentParsedName?.resolution) newNameStrings.push(` (${torrentParsedName?.resolution})`)
return newNameStrings.join(' ')
}
return ( return (
<> <>
<DialogHeader <DialogHeader
@@ -132,11 +143,11 @@ export default function DialogTorrentDetailsContent({ closeDialog, torrent }) {
<div> <div>
{name && name !== title ? ( {name && name !== title ? (
<> <>
<SectionTitle>{shortenText(name, 50)}</SectionTitle> <SectionTitle>{shortenText(getTitle(name), 50)}</SectionTitle>
<SectionSubName mb={20}>{shortenText(title, 160)}</SectionSubName> <SectionSubName mb={20}>{shortenText(title, 160)}</SectionSubName>
</> </>
) : ( ) : (
<SectionTitle mb={20}>{shortenText(title, 50)}</SectionTitle> <SectionTitle mb={20}>{shortenText(getTitle(title), 50)}</SectionTitle>
)} )}
<WidgetWrapper> <WidgetWrapper>
@@ -189,8 +200,8 @@ export default function DialogTorrentDetailsContent({ closeDialog, torrent }) {
{seasonAmount?.length > 1 && ( {seasonAmount?.length > 1 && (
<> <>
<SectionSubName>Select Season</SectionSubName> <SectionSubName mb={7}>Select Season</SectionSubName>
<ButtonGroup style={{ marginBottom: '10px' }} color='primary'> <ButtonGroup style={{ marginBottom: '30px' }} color='primary'>
{seasonAmount.map(season => ( {seasonAmount.map(season => (
<Button <Button
key={season} key={season}
@@ -201,6 +212,8 @@ export default function DialogTorrentDetailsContent({ closeDialog, torrent }) {
</Button> </Button>
))} ))}
</ButtonGroup> </ButtonGroup>
<SectionTitle mb={20}>Season {selectedSeason}</SectionTitle>
</> </>
)} )}