mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 21:46:11 +05:00
torrent source regex added
This commit is contained in:
@@ -35,7 +35,7 @@ import {
|
|||||||
TorrentIconWrapper,
|
TorrentIconWrapper,
|
||||||
RightSideContainer,
|
RightSideContainer,
|
||||||
} from './style'
|
} from './style'
|
||||||
import { checkImageURL, getMoviePosters } from './helpers'
|
import { checkImageURL, getMoviePosters, chechTorrentSource } from './helpers'
|
||||||
|
|
||||||
export default function AddDialog({ handleClose }) {
|
export default function AddDialog({ handleClose }) {
|
||||||
const { t } = useTranslation()
|
const { t } = useTranslation()
|
||||||
@@ -44,6 +44,7 @@ export default function AddDialog({ handleClose }) {
|
|||||||
const [title, setTitle] = useState('')
|
const [title, setTitle] = useState('')
|
||||||
const [posterUrl, setPosterUrl] = useState('')
|
const [posterUrl, setPosterUrl] = useState('')
|
||||||
const [isPosterUrlCorrect, setIsPosterUrlCorrect] = useState(false)
|
const [isPosterUrlCorrect, setIsPosterUrlCorrect] = useState(false)
|
||||||
|
const [isTorrentSourceCorrect, setIsTorrentSourceCorrect] = useState(false)
|
||||||
const [posterList, setPosterList] = useState()
|
const [posterList, setPosterList] = useState()
|
||||||
const [isUserInteractedWithPoster, setIsUserInteractedWithPoster] = useState(false)
|
const [isUserInteractedWithPoster, setIsUserInteractedWithPoster] = useState(false)
|
||||||
const [isUserInteractedWithTitle, setIsUserInteractedWithTitle] = useState(false)
|
const [isUserInteractedWithTitle, setIsUserInteractedWithTitle] = useState(false)
|
||||||
@@ -102,6 +103,10 @@ export default function AddDialog({ handleClose }) {
|
|||||||
})
|
})
|
||||||
}, [selectedFile, delayedPosterSearch, torrentSource, posterSearchLanguage, isUserInteractedWithTitle])
|
}, [selectedFile, delayedPosterSearch, torrentSource, posterSearchLanguage, isUserInteractedWithTitle])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setIsTorrentSourceCorrect(chechTorrentSource(torrentSource))
|
||||||
|
}, [torrentSource])
|
||||||
|
|
||||||
const handleCapture = files => {
|
const handleCapture = files => {
|
||||||
const [file] = files
|
const [file] = files
|
||||||
if (!file) return
|
if (!file) return
|
||||||
@@ -214,7 +219,7 @@ export default function AddDialog({ handleClose }) {
|
|||||||
</LeftSide>
|
</LeftSide>
|
||||||
|
|
||||||
<RightSide>
|
<RightSide>
|
||||||
<RightSideContainer isHidden={!torrentSource}>
|
<RightSideContainer isHidden={!isTorrentSourceCorrect}>
|
||||||
<TextField
|
<TextField
|
||||||
onChange={handleTitleChange}
|
onChange={handleTitleChange}
|
||||||
value={title}
|
value={title}
|
||||||
@@ -279,7 +284,13 @@ export default function AddDialog({ handleClose }) {
|
|||||||
</PosterWrapper>
|
</PosterWrapper>
|
||||||
</RightSideContainer>
|
</RightSideContainer>
|
||||||
|
|
||||||
<RightSideContainer notificationMessage={t('AddTorrentSourceNotification')} isHidden={torrentSource} />
|
<RightSideContainer
|
||||||
|
isError={torrentSource && !isTorrentSourceCorrect}
|
||||||
|
notificationMessage={
|
||||||
|
!torrentSource ? t('AddTorrentSourceNotification') : !isTorrentSourceCorrect && t('WrongTorrentSource')
|
||||||
|
}
|
||||||
|
isHidden={isTorrentSourceCorrect}
|
||||||
|
/>
|
||||||
</RightSide>
|
</RightSide>
|
||||||
</Content>
|
</Content>
|
||||||
|
|
||||||
|
|||||||
@@ -21,3 +21,9 @@ export const checkImageURL = async url => {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const magnetRegex = /magnet:\?xt=urn:[a-z0-9]{20,50}/i
|
||||||
|
const hashRegex = /\b[0-9a-f]{32}\b|\b[0-9a-f]{40}\b|\b[0-9a-f]{64}\b/i
|
||||||
|
const torrentRegex = /^.*\.(torrent)$/i
|
||||||
|
export const chechTorrentSource = source =>
|
||||||
|
source.match(hashRegex) !== null || source.match(magnetRegex) !== null || source.match(torrentRegex) !== null
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ export const RightSide = styled.div`
|
|||||||
`
|
`
|
||||||
|
|
||||||
export const RightSideContainer = styled.div`
|
export const RightSideContainer = styled.div`
|
||||||
${({ isHidden, notificationMessage }) => css`
|
${({ isHidden, notificationMessage, isError }) => css`
|
||||||
height: 455px;
|
height: 455px;
|
||||||
|
|
||||||
${notificationMessage &&
|
${notificationMessage &&
|
||||||
@@ -44,7 +44,7 @@ export const RightSideContainer = styled.div`
|
|||||||
content: '${notificationMessage}';
|
content: '${notificationMessage}';
|
||||||
display: grid;
|
display: grid;
|
||||||
place-items: center;
|
place-items: center;
|
||||||
background: #84cda7;
|
background: ${isError ? '#cda184' : '#84cda7'};
|
||||||
padding: 10px 15px;
|
padding: 10px 15px;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 50%;
|
top: 50%;
|
||||||
|
|||||||
@@ -103,5 +103,6 @@
|
|||||||
},
|
},
|
||||||
"TorrentSourceOptions": "magnet / hash / .torrent file link",
|
"TorrentSourceOptions": "magnet / hash / .torrent file link",
|
||||||
"Clear": "Clear",
|
"Clear": "Clear",
|
||||||
"AddTorrentSourceNotification": "First add your torrent source"
|
"AddTorrentSourceNotification": "First add your torrent source",
|
||||||
|
"WrongTorrentSource": "Wrong torrent source"
|
||||||
}
|
}
|
||||||
@@ -101,7 +101,8 @@
|
|||||||
"Or": "ИЛИ",
|
"Or": "ИЛИ",
|
||||||
"ClickOrDrag": "НАЖМИТЕ / ПЕРЕТАЩИТЕ ФАЙЛ (.torrent)"
|
"ClickOrDrag": "НАЖМИТЕ / ПЕРЕТАЩИТЕ ФАЙЛ (.torrent)"
|
||||||
},
|
},
|
||||||
"TorrentSourceOptions": "магнитная ссылка / хеш / ссылка на .torrent файл",
|
"TorrentSourceOptions": "magnet ссылка / хеш / ссылка на .torrent файл",
|
||||||
"Clear": "Очистить",
|
"Clear": "Очистить",
|
||||||
"AddTorrentSourceNotification": "Сначала добавьте торрент источник"
|
"AddTorrentSourceNotification": "Сначала добавьте торрент источник",
|
||||||
|
"WrongTorrentSource": "Неправильный torrent источник"
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user