Skip to content

Commit

Permalink
prisma backend complete, logo banner, misc
Browse files Browse the repository at this point in the history
  • Loading branch information
ridhwaans committed Jul 11, 2021
1 parent ced3f18 commit 8116832
Show file tree
Hide file tree
Showing 25 changed files with 134 additions and 169 deletions.
71 changes: 38 additions & 33 deletions README.md
Expand Up @@ -26,12 +26,14 @@
![movies_2](media/movies_2.png)
## 📺 TV Shows
### Home
![tv](media/tv.png)
![tv](media/tv_1.png)
## 🎵 Music
### Home
![music](media/music_1.png)
### Album
### Search
![music](media/music_2.png)
### Album
![music](media/music_3.png)

## ⚙️ Setup

Expand Down Expand Up @@ -115,37 +117,40 @@ While running, *homehost* continuously saves and retrieves metadata for any medi

#### Server-side

**POST**
`/api?generate=movies,tv,music`
**GET**
`/api/about`
`/api/movies`
`/api/movies/most_popular`
`/api/movies/highest_rated`
`/api/movies/recently_added`
`/api/movies/genres`
`/api/movies/genres/:name`
`/api/movies/random`
`/api/movies/:id`
`/api/tv`
`/api/tv/most_popular`
`/api/tv/highest_rated`
`/api/tv/recently_added`
`/api/tv/genres`
`/api/tv/genres/:name`
`/api/tv/random`
`/api/tv/:id`
`/api/music/recently_added`
`/api/music/artists`
`/api/music/albums`
`/api/music/albums/:id`
`/api/music/songs`
`/movies/:id`
`/tv/:tv_show_id/:season_number/:episode_number`
`/music/:album_id/:disc_number/:track_number`
`/api/watch/search`
`/api/listen/search`
`/api/watch/billboard`
**POST**
`/api?generate=movies,tv,music`
**GET**
`/api/about`
`/api/movies`
`/api/movies/most_popular`
`/api/movies/highest_rated`
`/api/movies/recently_added`
`/api/movies/genres`
`/api/movies/genre/:name`
`/api/movies/random`
`/api/movies/:id`
`/api/tv`
`/api/tv/most_popular`
`/api/tv/highest_rated`
`/api/tv/recently_added`
`/api/tv/genres`
`/api/tv/genre/:name`
`/api/tv/random`
`/api/tv/:id`
`/api/music/albums/recently_added`
`/api/music/albums/latest`
`/api/music/artists`
`/api/music/artists/most_popular`
`/api/music/albums`
`/api/music/albums/:id`
`/api/music/songs`
`/api/music/songs/recently_added`
`/movies/:id`
`/tv/:tv_show_id/:season_number/:episode_number`
`/music/:album_id/:disc_number/:track_number`
`/api/watch/search`
`/api/listen/search`
`/api/watch/billboard`

#### Client-side

Expand Down
2 changes: 1 addition & 1 deletion client/package.json
@@ -1,6 +1,6 @@
{
"name": "homehost-client",
"version": "1.5.0",
"version": "1.9.0",
"private": true,
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^1.2.27",
Expand Down
49 changes: 45 additions & 4 deletions client/src/api.js
Expand Up @@ -57,7 +57,7 @@ export async function getMovieGenres() {

export async function getMoviesByGenre(genre) {

return await axios.get(`${process.env.REACT_APP_HOMEHOST_BASE}/api/movies/genres/${genre}`)
return await axios.get(`${process.env.REACT_APP_HOMEHOST_BASE}/api/movies/genre/${genre}`)
.then(function (response) {
return response.data

Expand Down Expand Up @@ -121,7 +121,7 @@ export async function getTVShowGenres() {

export async function getTVShowsByGenre(genre) {

return await axios.get(`${process.env.REACT_APP_HOMEHOST_BASE}/api/tv/genres/${genre}`)
return await axios.get(`${process.env.REACT_APP_HOMEHOST_BASE}/api/tv/genre/${genre}`)
.then(function (response) {
return response.data

Expand Down Expand Up @@ -190,13 +190,54 @@ export async function getAlbumInformation(id) {
})
}

export async function getMusicBy(type) {
export async function getAlbumsBy(type) {

let discover = null

switch (type) {
case "recently_added":
discover = `${process.env.REACT_APP_HOMEHOST_BASE}/api/music/recently_added`
discover = `${process.env.REACT_APP_HOMEHOST_BASE}/api/music/albums/recently_added`
break;
case "latest":
discover = `${process.env.REACT_APP_HOMEHOST_BASE}/api/music/albums/latest`
break;
default:

}

return await axios.get(discover)
.then(function (response) {
return response.data

})
}

export async function getSongsBy(type) {

let discover = null

switch (type) {
case "recently_added":
discover = `${process.env.REACT_APP_HOMEHOST_BASE}/api/music/songs/recently_added`
break;
default:

}

return await axios.get(discover)
.then(function (response) {
return response.data

})
}

export async function getArtistsBy(type) {

let discover = null

switch (type) {
case "most_popular":
discover = `${process.env.REACT_APP_HOMEHOST_BASE}/api/music/artists/most_popular`
break;
default:

Expand Down
8 changes: 8 additions & 0 deletions client/src/assets/Movies.css
Expand Up @@ -1108,6 +1108,14 @@ background-position: 50% -50%;
transform-origin: 0 0;
}

.ai-content-area-banner-logo {
background-size: contain;
background-repeat: no-repeat;
background-position: center;
height: 200px;
width: 600px;
}


/* PAGINATION INDICATOR DE UN SLIDER */

Expand Down
12 changes: 6 additions & 6 deletions client/src/components/Movies/index.js
Expand Up @@ -16,7 +16,7 @@ function Movies() {
const [popularMovies, setPopularMovies] = useState(null)
const [animationMovies, setAnimationMovies] = useState(null)
const [highestRatedMovies, setHighestRatedMovies] = useState(null)
const [horrorMovies, setHorrorMovies] = useState(null)
const [warMovies, setWarMovies] = useState(null)

const searchContext = useContext(SearchContext)

Expand All @@ -26,9 +26,9 @@ function Movies() {
let popularMovies = await getMoviesBy("most_popular")
let animationMovies = await getMoviesByGenre("Animation")
let highestRatedMovies = await getMoviesBy("highest_rated")
let horrorMovies = await getMoviesByGenre("Horror")
let warMovies = await getMoviesByGenre("War")

return { recentlyAddedMovies, popularMovies, animationMovies, highestRatedMovies, horrorMovies }
return { recentlyAddedMovies, popularMovies, animationMovies, highestRatedMovies, warMovies }
}

useEffect(() => {
Expand All @@ -41,7 +41,7 @@ function Movies() {
setPopularMovies(response.popularMovies)
setAnimationMovies(response.animationMovies)
setHighestRatedMovies(response.highestRatedMovies)
setHorrorMovies(response.horrorMovies)
setWarMovies(response.warMovies)

})

Expand All @@ -51,7 +51,7 @@ function Movies() {
setPopularMovies(null)
setAnimationMovies(null)
setHighestRatedMovies(null)
setHorrorMovies(null)
setWarMovies(null)
}


Expand All @@ -77,7 +77,7 @@ function Movies() {

{highestRatedMovies && <Slider mainTitle={"Highest Rated"} data={highestRatedMovies} poster={true} />}

{horrorMovies && <Slider mainTitle={"Horror"} data={horrorMovies} poster={false} />}
{warMovies && <Slider mainTitle={"War"} data={warMovies} poster={false} />}

</React.Fragment>
)}
Expand Down
8 changes: 4 additions & 4 deletions client/src/components/Music/index.js
Expand Up @@ -3,7 +3,7 @@ import { BrowserRouter as Router, Route } from "react-router-dom";
import { Provider, connect } from "react-redux";
import { createStore, combineReducers } from "redux";

import { getAllArtists, getAllAlbums, getAllSongs } from "../../api"
import { getArtistsBy, getAlbumsBy, getSongsBy } from "../../api"
import playlistReducer from "../../store/reducers/playlists";
import playingReducer from "../../store/reducers/playing";

Expand All @@ -27,9 +27,9 @@ const Music = () => {
const [songs, setSongs] = useState(null)

const fetchMusic = async () => {
let albums = await getAllAlbums()
let artists = await getAllArtists()
let songs = await getAllSongs()
let albums = await getAlbumsBy("latest")
let artists = await getArtistsBy("most_popular")
let songs = await getSongsBy("recently_added")

return { albums, artists, songs }
}
Expand Down
13 changes: 0 additions & 13 deletions client/src/components/MusicHome/MusicHome.js
Expand Up @@ -3,19 +3,6 @@ import MusicRow from "../MusicRow/MusicRow";
import style from "./MusicHome.module.css"

const MusicHome = ({songs, albums, artists}) => {

if (songs) {
songs = songs.sort((a,b) => new Date(b.mtime) - new Date(a.mtime) );
}
if (albums) {
albums = albums.sort((a,b) => new Date(b.release_date) - new Date(a.release_date) );
}
if (artists) {
artists = artists.sort((a,b) =>
(a.popularity === undefined) - (b.popularity === undefined)
|| (b.popularity - a.popularity))
}

return (
<React.Fragment>
<div className={style.MusicHome}>
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/SearchResultsSelectedItem/index.js
Expand Up @@ -43,7 +43,7 @@ const SearchResultsSelectedItem = ({ currentSlide, additionalMovieInfo, closeInf
<React.Fragment>
<div className="ai-content-area">
<div className="ai-content-area-container">
{ additionalMovieInfo.logo_path ? (<img className="logo" src={`${process.env.REACT_APP_IMAGE_BASE}w500/${currentSlide.logo_path}`} alt="boxart" />
{ additionalMovieInfo.logo_path ? (<div className="ai-content-area-banner-logo" style={{ backgroundImage: `url(${process.env.REACT_APP_IMAGE_BASE}w500/${currentSlide.logo_path})` }} alt="boxart" />
) : (
<h3>
<div>{additionalMovieInfo.type == "Movie" ? currentSlide.title : currentSlide.name}</div>
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/SelectedItem/index.js
Expand Up @@ -33,7 +33,7 @@ const SelectedItem = ({ currentSlide, additionalMovieInfo, closeInformationWindo
<React.Fragment>
<div className="ai-content-area">
<div className="ai-content-area-container">
{ additionalMovieInfo.logo_path ? (<img className="logo" src={`${process.env.REACT_APP_IMAGE_BASE}w500/${currentSlide.logo_path}`} alt="boxart" />
{ additionalMovieInfo.logo_path ? (<div className="ai-content-area-banner-logo" style={{ backgroundImage: `url(${process.env.REACT_APP_IMAGE_BASE}w500/${currentSlide.logo_path})` }} alt="boxart" />
) : (
<h3>
<div>{additionalMovieInfo.type == "Movie" ? currentSlide.title : currentSlide.name}</div>
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/Songs/Songs.js
Expand Up @@ -72,7 +72,7 @@ const Songs = ({ loadSong, currentSong }) => {
<div className={style.Title}>
<h1>Songs</h1>
</div>
<div className={style.Categ}>something</div>
<div className={style.Categ}>Various categories</div>
<div className={style.Details}>
<span className={style.Text_Bold}>
Various Artists
Expand Down
Binary file modified media/movies_1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified media/movies_2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified media/music_1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified media/music_2.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added media/music_3.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file renamed media/tv.png → media/tv_1.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion server/data/index.js
Expand Up @@ -53,7 +53,7 @@ const searchMoviesAndTV = async (keyword) => {
]
}
})
const results = format([].concat(tv_shows).concat(movies))
const results = shuffleArr(format([].concat(tv_shows).concat(movies)))
return {
results: results,
count: results.length
Expand Down
28 changes: 6 additions & 22 deletions server/jobs/index.js
Expand Up @@ -35,19 +35,19 @@ watcher
const sync = async () => {

const notAvailable = await getNotAvailable()
const database = await getAllFiles()

console.log(`notAvailable is ${notAvailable.length}`)
console.table(notAvailable)

const filesToInsert = fileSystem.filter(x => !database.includes(x))
const databaseFiles = await getAllFiles()
const filesToInsert = fileSystem.filter(x => !databaseFiles.includes(x))
.filter(x => !notAvailable.includes(x))
const intersection = database.filter(x => fileSystem.includes(x))
const filesToDelete = database.filter(x => !fileSystem.includes(x))
const intersection = databaseFiles.filter(x => fileSystem.includes(x))
const filesToDelete = databaseFiles.filter(x => !fileSystem.includes(x))

console.log(`intersection is ${intersection.length}`)
console.log(`exclusiveToFileSystem is ${filesToInsert.length}`)
console.log(`exclusiveToDatabase is ${filesToDelete.length}`)

console.table(filesToInsert)
console.table(filesToDelete)

Expand Down Expand Up @@ -252,22 +252,6 @@ const upsertNotAvailable = async (file) => {
})
}

const getAll = async () => {
var movies = await prisma.movie.findMany({
include: { genres: true, production_companies: true, credits: true, similar: true }
})

var tv_shows = await prisma.tVShow.findMany({
include: { genres: true, production_companies: true, seasons: { include: { episodes: true } }, credits: true, similar: true }
})

var albums = await prisma.album.findMany({
include: { artists: true, songs: true }
})

return { movies: movies, tv: tv_shows, music: albums }
}

const getAllFiles = async () => {
var movies = await prisma.movie.findMany({
select: { fs_path: true }
Expand Down Expand Up @@ -338,4 +322,4 @@ const deleteManySongs = async (songs) => {
}
}

module.exports = { getAll, upsertAll }
module.exports = { upsertAll }

0 comments on commit 8116832

Please sign in to comment.