added rusian regex to ptt.parse

This commit is contained in:
Daniel Shleifman
2021-06-10 01:13:16 +03:00
parent 77db011252
commit 2b55352d37

View File

@@ -10,6 +10,11 @@ import { TableStyle, ShortTableWrapper, ShortTable } from './style'
const { memo } = require('react') const { memo } = require('react')
// russian episode detection support
ptt.addHandler('episode', /(\d{1,4})[- |. ]серия|серия[- |. ](\d{1,4})/i, { type: 'integer' })
ptt.addHandler('season', /sezon[- |. ](\d{1,3})|(\d{1,3})[- |. ]sezon/i, { type: 'integer' })
ptt.addHandler('season', /сезон[- |. ](\d{1,3})|(\d{1,3})[- |. ]сезон/i, { type: 'integer' })
const Table = memo( const Table = memo(
({ playableFileList, viewedFileList, selectedSeason, seasonAmount, hash }) => { ({ playableFileList, viewedFileList, selectedSeason, seasonAmount, hash }) => {
const { t } = useTranslation() const { t } = useTranslation()
@@ -20,6 +25,9 @@ const Table = memo(
const fileHasSeasonText = !!playableFileList?.find(({ path }) => ptt.parse(path).season) const fileHasSeasonText = !!playableFileList?.find(({ path }) => ptt.parse(path).season)
const fileHasResolutionText = !!playableFileList?.find(({ path }) => ptt.parse(path).resolution) const fileHasResolutionText = !!playableFileList?.find(({ path }) => ptt.parse(path).resolution)
// if files in list is more then 1 and no season text detected by ptt.parse, show full name
const shouldDisplayFullFileName = playableFileList.length > 1 && !fileHasEpisodeText
return !playableFileList?.length ? ( return !playableFileList?.length ? (
'No playable files in this torrent' 'No playable files in this torrent'
) : ( ) : (
@@ -47,7 +55,7 @@ const Table = memo(
(season === selectedSeason || !seasonAmount?.length) && ( (season === selectedSeason || !seasonAmount?.length) && (
<tr key={id} className={isViewed ? 'viewed-file-row' : null}> <tr key={id} className={isViewed ? 'viewed-file-row' : null}>
<td data-label='viewed' className={isViewed ? 'viewed-file-indicator' : null} /> <td data-label='viewed' className={isViewed ? 'viewed-file-indicator' : null} />
<td data-label='name'>{title}</td> <td data-label='name'>{shouldDisplayFullFileName ? path : title}</td>
{fileHasSeasonText && seasonAmount?.length === 1 && <td data-label='season'>{season}</td>} {fileHasSeasonText && seasonAmount?.length === 1 && <td data-label='season'>{season}</td>}
{fileHasEpisodeText && <td data-label='episode'>{episode}</td>} {fileHasEpisodeText && <td data-label='episode'>{episode}</td>}
{fileHasResolutionText && <td data-label='resolution'>{resolution}</td>} {fileHasResolutionText && <td data-label='resolution'>{resolution}</td>}