Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Server: Missing MOVIES_API and MOVIES_KEY #18

Open
jrichardsz opened this issue Sep 22, 2021 · 2 comments
Open

Server: Missing MOVIES_API and MOVIES_KEY #18

jrichardsz opened this issue Sep 22, 2021 · 2 comments

Comments

@jrichardsz
Copy link

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
Copy link
Author

jrichardsz commented Sep 22, 2021

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
Copy link
Author

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

  • create an api key in tmdb service: https://stackoverflow.com/a/31047912/3957754
  • choose some movies in the tmdb web and store its movie-id
  • in your local disk, create a folder and put 3 videos (mkv/mp4). Rename them setting the movie-id + space + whatever. Example : 1402 another movie.mkv
  • As in this test, probably you cannot a spotify account or videos for tv, we are using only movies. If this is your case, modify this line in the client to render just movies:
    • if (containerRef.current && containerRef.current.firstChild && data) {
  • npm install in server and client folder
  • open 3 shells and export these variables. Note the use of the local ip in CLIENT_BASE_URL variables:
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
  • create the database running npx prisma migrate dev in the server folder, using one of the previous opened shells
  • startup the prisma server running npx prisma studio in the server, using one of the previous opened shells
  • startup the home-host server running npm run dev, using one of the previous opened shells
  • startup the home-host web client running npm run start, using one of the previous opened shells
  • an url will be opened in your default browser. Change the localhost in the url by your local ip

Coming soon

  • I will perform a PR with Docker docker-compose alternative
  • Create an issue related to video load error
  • Create an issue to enable or disable categories: movies, tvs, songs. In this version, if you cannot pass all of categories (videos/songa on your local disk), an error is throwed. That why a react modification is required in the previous steps

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant