mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 21:46:11 +05:00
refactor
This commit is contained in:
@@ -77,6 +77,11 @@ export default function AddDialog({ handleClose }) {
|
|||||||
const posterSearch = useMemo(
|
const posterSearch = useMemo(
|
||||||
() =>
|
() =>
|
||||||
(movieName, language, settings = {}) => {
|
(movieName, language, settings = {}) => {
|
||||||
|
if (!movieName) {
|
||||||
|
setPosterList()
|
||||||
|
removePoster()
|
||||||
|
return
|
||||||
|
}
|
||||||
const { shouldRefreshMainPoster = false } = settings
|
const { shouldRefreshMainPoster = false } = settings
|
||||||
|
|
||||||
getMoviePosters(movieName, language).then(urlList => {
|
getMoviePosters(movieName, language).then(urlList => {
|
||||||
|
|||||||
@@ -1,11 +1,17 @@
|
|||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
|
|
||||||
export const getMoviePosters = (movieName, language = 'en') => {
|
export const getMoviePosters = (movieName, language = 'en') => {
|
||||||
if (!movieName) return new Promise(resolve => resolve(null))
|
const url = 'http://api.themoviedb.org/3/search/multi'
|
||||||
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
|
return axios
|
||||||
.get(request)
|
.get(url, {
|
||||||
|
params: {
|
||||||
|
api_key: process.env.REACT_APP_TMDB_API_KEY,
|
||||||
|
language,
|
||||||
|
include_image_language: `${language},null`,
|
||||||
|
query: movieName,
|
||||||
|
},
|
||||||
|
})
|
||||||
.then(({ data: { results } }) =>
|
.then(({ data: { results } }) =>
|
||||||
results.filter(el => el.poster_path).map(el => `https://image.tmdb.org/t/p/w300${el.poster_path}`),
|
results.filter(el => el.poster_path).map(el => `https://image.tmdb.org/t/p/w300${el.poster_path}`),
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user