mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 21:46:11 +05:00
allow http links in source
This commit is contained in:
@@ -14,7 +14,7 @@ import { getTorrents } from 'utils/Utils'
|
|||||||
import parseTorrent from 'parse-torrent'
|
import parseTorrent from 'parse-torrent'
|
||||||
import { ButtonWrapper, Header } from 'style/DialogStyles'
|
import { ButtonWrapper, Header } from 'style/DialogStyles'
|
||||||
|
|
||||||
import { checkImageURL, getMoviePosters, chechTorrentSource, parseTorrentTitle } from './helpers'
|
import { checkImageURL, getMoviePosters, checkTorrentSource, parseTorrentTitle } from './helpers'
|
||||||
import { Content } from './style'
|
import { Content } from './style'
|
||||||
import RightSideComponent from './RightSideComponent'
|
import RightSideComponent from './RightSideComponent'
|
||||||
import LeftSideComponent from './LeftSideComponent'
|
import LeftSideComponent from './LeftSideComponent'
|
||||||
@@ -147,7 +147,7 @@ export default function AddDialog({
|
|||||||
const prevTorrentSourceState = usePreviousState(torrentSource)
|
const prevTorrentSourceState = usePreviousState(torrentSource)
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const isCorrectSource = chechTorrentSource(torrentSource)
|
const isCorrectSource = checkTorrentSource(torrentSource)
|
||||||
if (!isCorrectSource) return setIsTorrentSourceCorrect(false)
|
if (!isCorrectSource) return setIsTorrentSourceCorrect(false)
|
||||||
|
|
||||||
setIsTorrentSourceCorrect(true)
|
setIsTorrentSourceCorrect(true)
|
||||||
@@ -227,10 +227,10 @@ export default function AddDialog({
|
|||||||
{!isEditMode && (
|
{!isEditMode && (
|
||||||
<LeftSideComponent
|
<LeftSideComponent
|
||||||
setIsUserInteractedWithPoster={setIsUserInteractedWithPoster}
|
setIsUserInteractedWithPoster={setIsUserInteractedWithPoster}
|
||||||
|
selectedFile={selectedFile}
|
||||||
setSelectedFile={setSelectedFile}
|
setSelectedFile={setSelectedFile}
|
||||||
torrentSource={torrentSource}
|
torrentSource={torrentSource}
|
||||||
setTorrentSource={setTorrentSource}
|
setTorrentSource={setTorrentSource}
|
||||||
selectedFile={selectedFile}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|||||||
@@ -34,8 +34,13 @@ export const checkImageURL = async url => {
|
|||||||
const magnetRegex = /^magnet:\?xt=urn:[a-z0-9].*/i
|
const magnetRegex = /^magnet:\?xt=urn:[a-z0-9].*/i
|
||||||
export const hashRegex = /^\b[0-9a-f]{32}\b$|^\b[0-9a-f]{40}\b$|^\b[0-9a-f]{64}\b$/i
|
export 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
|
const torrentRegex = /^.*\.(torrent)$/i
|
||||||
export const chechTorrentSource = source =>
|
const linkRegex = /^(http(s?)):\/\/.*/i
|
||||||
source.match(hashRegex) !== null || source.match(magnetRegex) !== null || source.match(torrentRegex) !== null
|
|
||||||
|
export const checkTorrentSource = source =>
|
||||||
|
source.match(hashRegex) !== null ||
|
||||||
|
source.match(magnetRegex) !== null ||
|
||||||
|
source.match(torrentRegex) !== null ||
|
||||||
|
source.match(linkRegex) !== null
|
||||||
|
|
||||||
export const parseTorrentTitle = (parsingSource, callback) => {
|
export const parseTorrentTitle = (parsingSource, callback) => {
|
||||||
parseTorrent.remote(parsingSource, (err, { name, files } = {}) => {
|
parseTorrent.remote(parsingSource, (err, { name, files } = {}) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user