ridhwaans / homehost

self-hosted, Netflix-like app made for streaming
MIT License
1.06k stars 119 forks source link

Server: Missing MOVIES_API and MOVIES_KEY #18

Open jrichardsz opened 2 years ago

jrichardsz commented 2 years ago

I tried to start the server using the readme: npx prisma migrate dev

I got this error:

Generating data for Movies...
GET: /foo/bar/like-netflix/movies/kate 597891.mkv
url: https://undefined/movie/597891?api_key=undefined&append_to_response=images,credits,similar
There was a problem adding this movie TypeError: Cannot read property 'status' of undefined
    at getMovieMetaData (/tmp/workspace/homehost/server/models/index.js:16:13)
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at async upsertManyMovies (/tmp/workspace/homehost/server/jobs/index.js:80:20)
    at async sync (/tmp/workspace/homehost/server/jobs/index.js:55:27)

My server env is:

TMDB_KEY = '47422a2813d47422a2813d'
SPOTIFY_CLIENT_ID = '<client_id>'
SPOTIFY_CLIENT_SECRET = '<client_secret>'

MOVIES_PATH = '/var/tmp/lisu/like-netflix/movies'
TV_PATH = '/opt/tv/directory'
MUSIC_PATH = '/opt/music/directory'

DATABASE_URL = 'file:./data/media.db'
CLIENT_BASE_URL = 'http://192.168.A.B:3000'

Research

I found that the error is trowed in this file:

homehost/server/services/metadata.js

if (item.type == Type.Movie){
    request_url = `https://${process.env.MOVIES_API}/movie/${item.id}?api_key=${process.env.MOVIES_KEY}&append_to_response=images,credits,similar`
}

So my question is, what are the expected values for MOVIES_API and MOVIES_KEY?

Thanks

jrichardsz commented 2 years ago

Reviewing and with some intuition

image

I found the values:

MOVIES_API = api.themoviedb.org/3
MOVIES_KEY = 81*****e0b

MOVIES_KEY is the TMDB API KEY

Whit these values, there are some successes and errors in the log:

Generating data for Movies...
GET: /foo/bar/like-netflix/movies/kate 597891.mkv
url: https://api.themoviedb.org/3/movie/597891?api_key=81****0b&append_to_response=images,credits,similar
GET: /foo/bar/like-netflix/movies/shang-chi-and-the-legend-of-the-ten-rings 566525.mkv
url: https://api.themoviedb.org/3/movie/566525?api_key=81****0b&append_to_response=images,credits,similar
GET: /foo/bar/like-netflix/movies/shang-chi-and-the-legend-of-the-ten-rings 566525.mkv
url: https://api.themoviedb.org/3/movie/566525?api_key=81****0b&append_to_response=images,credits,similar
GET: /foo/bar/like-netflix/movies/shang-chi-and-the-legend-of-the-ten-rings 566525.mkv
url: https://api.themoviedb.org/3/movie/566525?api_key=81****0b&append_to_response=images,credits,similar
GET: /foo/bar/like-netflix/movies/shang-chi-and-the-legend-of-the-ten-rings 566525.mkv
url: https://api.themoviedb.org/3/movie/566525?api_key=81****0b&append_to_response=images,credits,similar
There was a problem adding this movie PrismaClientUnknownRequestError: 
Invalid `prisma.movie.upsert()` invocation:

  Error occurred during query execution:
ConnectorError(ConnectorError { user_facing_error: None, kind: ConnectionError(Timed out during query execution.) })
    at cb (/tmp/workspace/homehost/server/node_modules/@prisma/client/runtime/index.js:36956:17)
    at async upsertManyMovies (/tmp/workspace/homehost/server/jobs/index.js:114:7)
    at async sync (/tmp/workspace/homehost/server/jobs/index.js:55:27) {
  clientVersion: '3.1.1'
}

And when I try to load the web, there is nothing to see :(

image

This is the log when web page try to query something:

(node:24817) UnhandledPromiseRejectionWarning: TypeError: Cannot convert undefined or null to object
    at Function.keys (<anonymous>)
    at format (/tmp/workspace/homehost/server/utils/index.js:15:21)
    at getRandomMovie (/tmp/workspace/homehost/server/data/index.js:348:10)
    at async getRandomMovieOrTVShow (/tmp/workspace/homehost/server/data/index.js:336:31)
    at async /tmp/workspace/homehost/server/routes/index.js:232:25
(Use `node --trace-warnings ...` to show where the warning was created)

What I'm doing wrong?

jrichardsz commented 2 years ago

I was able to run everything:

image

But when I try to watch a video, I got this error:

image

I will create another issue with this new error.

Steps to startup

export REACT_APP_IMAGE_BASE="https://image.tmdb.org/t/p/"
export REACT_APP_TMDB_BASE="https://www.imdb.com/title/"
export TMDB_KEY='811****ce0b'
export SPOTIFY_CLIENT_ID='<client_id>'
export SPOTIFY_CLIENT_SECRET='<client_secret>'
export MOVIES_PATH='/foo/bar/storage/movies'
export TV_PATH='/opt/tv/directory'
export MUSIC_PATH='/opt/music/directory'
export DATABASE_URL='file:./data/media.db'
export CLIENT_BASE_URL='http://192.168.A.B:3000'
export MOVIES_API=api.themoviedb.org/3
export MOVIES_KEY=811****ce0b

Coming soon