mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-20 14:06:09 +05:00
refactor
This commit is contained in:
23
web/src/components/Add/helpers.js
Normal file
23
web/src/components/Add/helpers.js
Normal file
@@ -0,0 +1,23 @@
|
||||
import axios from 'axios'
|
||||
|
||||
export const getMoviePosters = (movieName, language = 'en') => {
|
||||
const request = `${`http://api.themoviedb.org/3/search/multi?api_key=${process.env.REACT_APP_TMDB_API_KEY}`}&language=${language}&include_image_language=${language},null&query=${movieName}`
|
||||
|
||||
return axios
|
||||
.get(request)
|
||||
.then(({ data: { results } }) =>
|
||||
results.filter(el => el.poster_path).map(el => `https://image.tmdb.org/t/p/w300${el.poster_path}`),
|
||||
)
|
||||
.catch(() => null)
|
||||
}
|
||||
|
||||
export const checkImageURL = async url => {
|
||||
if (!url || !url.match(/.(jpg|jpeg|png|gif)$/i)) return false
|
||||
|
||||
try {
|
||||
await fetch(url)
|
||||
return true
|
||||
} catch (e) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user