Skip to content

Commit

Permalink
watchlist and wishlist fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Dado555 committed Aug 18, 2022
1 parent 462a793 commit 04721a6
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 38 deletions.
4 changes: 2 additions & 2 deletions gleficu-frontend/src/components/users/WatchedMovies.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<div class="grid grid-cols-1 sm:grid-cols-3 md:grid-cols-3 lg:grid-cols-7 gap-8">
<MovieItem
:key="movie.id"
:key="movie.imdbID"
v-for="movie in movies"
:movie="movie"
/>
Expand Down Expand Up @@ -56,7 +56,7 @@ export default {
}
listsService.getWatchlist(params).then((response) => {
this.movies = response.data.watchlist;
console.log(response);
// console.log(response);
});
},
next() {
Expand Down
4 changes: 2 additions & 2 deletions gleficu-frontend/src/components/users/WishlistMovies.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<div class="grid grid-cols-1 sm:grid-cols-3 md:grid-cols-3 lg:grid-cols-7 gap-8">
<MovieItem
:key="movie.id"
:key="movie.imdbID"
v-for="movie in movies"
:movie="movie"
/>
Expand Down Expand Up @@ -60,7 +60,7 @@ export default {
}
listsService.getWishlist(params).then((response) => {
this.movies = response.data.wishlist;
console.log(response);
// console.log(response);
});
},
next() {
Expand Down
1 change: 0 additions & 1 deletion gleficu-frontend/src/services/movieService.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ class MovieService {
}

saveMovie(movie) {
console.log(movie);
return axios.post(SAVE_MOVIE, movie, {
headers: { Authorization: "Bearer " + localStorage.getItem("id_token") }
})
Expand Down
5 changes: 2 additions & 3 deletions scrape-movie-service/api/movies.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package api

import (
"encoding/json"
"fmt"
"github.com/Dado555/glef.icu/scrape-movie-service/downloadPlay"
"github.com/Dado555/glef.icu/scrape-movie-service/models"
"github.com/Dado555/glef.icu/scrape-movie-service/repository"
Expand Down Expand Up @@ -73,7 +72,7 @@ func (api *API) GetMovies(w http.ResponseWriter, request *http.Request) {
w.Header().Set("Content-Type", "application/json")
queryParams := request.URL.Query()

fmt.Println(queryParams)
// fmt.Println(queryParams)

page := queryParams.Get("page")
size := queryParams.Get("size")
Expand Down Expand Up @@ -155,7 +154,7 @@ func (api *API) SearchMovies(w http.ResponseWriter, request *http.Request) {
w.Header().Set("Content-Type", "application/json")
queryParams := request.URL.Query()

fmt.Println(queryParams)
// fmt.Println(queryParams)
title := queryParams.Get("title")
movies := api.movies.SearchMovies(title)

Expand Down
3 changes: 1 addition & 2 deletions scrape-movie-service/api/tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ package api

import (
"encoding/json"
"fmt"
"net/http"
)

func (api *API) SearchTags(w http.ResponseWriter, request *http.Request) {
w.Header().Set("Content-Type", "application/json")
queryParams := request.URL.Query()

fmt.Println(queryParams)
// fmt.Println(queryParams)
name := queryParams.Get("name")
tags := api.tags.SearchTags(name)

Expand Down
8 changes: 4 additions & 4 deletions scrape-movie-service/downloadPlay/subtitle.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func getSubtitleFilePath(folderName string) string {
if filepath.Ext(file) == ".srt" {
subtitlePath = file
}
fmt.Println(file)
// fmt.Println(file)
}

return subtitlePath
Expand All @@ -37,11 +37,11 @@ func DownloadSubtitle(subtitleWebPath string) string {
log.Fatal(err)
}

fmt.Println("Download saved to", resp.Filename)
fmt.Println("Response: ", resp)
// fmt.Println("Download saved to", resp.Filename)
//fmt.Println("Response: ", resp)

var folderName = resp.Filename[5 : len(resp.Filename)-4]
fmt.Println(folderName)
//fmt.Println(folderName)
UnzipFile(resp.Filename, "/tmp/"+folderName)

return folderName
Expand Down
10 changes: 5 additions & 5 deletions scrape-movie-service/repository/movieRepository.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ func FindTorrentMagnetAndSubtitleLink(movie models.Movie) (string, string) {
} else {
// Iterate through results and print their magnet URLs
for _, torrent := range torrents {
fmt.Println()
fmt.Println(torrent)
fmt.Printf("Found torrent: %v\n\n", torrent.MagnetURL)
//fmt.Println()
//fmt.Println(torrent)
//fmt.Printf("Found torrent: %v\n\n", torrent.MagnetURL)
if strings.Contains(torrent.Quality, "720p") || strings.Contains(torrent.Quality, "1080p") {
torrentLinks = torrent.MagnetURL
fmt.Printf("\nSaved torrent: %v\n\n", torrent.MagnetURL)
//fmt.Printf("\nSaved torrent: %v\n\n", torrent.MagnetURL)
}
}
}
Expand All @@ -54,7 +54,7 @@ func FindTorrentMagnetAndSubtitleLink(movie models.Movie) (string, string) {

// Anonymous login will set c.Token when successful
if err = c.LogIn("Dado1856", "Teslatesla#555", "eng"); err != nil {
fmt.Println("Logged in as user..")
//fmt.Println("Logged in as user..")
}

languages := []string{"srp", "hrv", "bos"}
Expand Down
9 changes: 4 additions & 5 deletions user-movies-service/api/watchlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package api

import (
"encoding/json"
"fmt"
"github.com/Dado555/glef.icu/user-movies-service/models"
"net/http"
"strconv"
Expand All @@ -12,7 +11,7 @@ func (api *API) GetWatchlist(w http.ResponseWriter, request *http.Request) {
w.Header().Set("Content-Type", "application/json")
queryParams := request.URL.Query()

fmt.Println(queryParams)
//fmt.Println(queryParams)

page := queryParams.Get("page")
size := queryParams.Get("size")
Expand All @@ -25,7 +24,7 @@ func (api *API) GetWatchlist(w http.ResponseWriter, request *http.Request) {
watchlist := api.watchlist.GetWatchlist(pageParsed, sizeParsed, uint(userIdParsed))

watchlistPage := models.WatchlistPage{
Watchlist: watchlist,
Watchlist: *watchlist,
}

err := json.NewEncoder(w).Encode(watchlistPage)
Expand All @@ -39,7 +38,7 @@ func (api *API) GetWatchlistItem(w http.ResponseWriter, request *http.Request) {
w.Header().Set("Content-Type", "application/json")
queryParams := request.URL.Query()

fmt.Println(queryParams)
//fmt.Println(queryParams)

userId := queryParams.Get("userId")
movieId := queryParams.Get("movieId")
Expand Down Expand Up @@ -84,7 +83,7 @@ func (api *API) DeleteWatchlistItem(w http.ResponseWriter, request *http.Request
w.Header().Set("Content-Type", "application/json")
queryParams := request.URL.Query()

fmt.Println(queryParams)
//fmt.Println(queryParams)

userId := queryParams.Get("userId")
movieId := queryParams.Get("movieId")
Expand Down
9 changes: 4 additions & 5 deletions user-movies-service/api/wishlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package api

import (
"encoding/json"
"fmt"
"github.com/Dado555/glef.icu/user-movies-service/models"
"net/http"
"strconv"
Expand All @@ -12,7 +11,7 @@ func (api *API) GetWishlist(w http.ResponseWriter, request *http.Request) {
w.Header().Set("Content-Type", "application/json")
queryParams := request.URL.Query()

fmt.Println(queryParams)
//fmt.Println(queryParams)

page := queryParams.Get("page")
size := queryParams.Get("size")
Expand All @@ -25,7 +24,7 @@ func (api *API) GetWishlist(w http.ResponseWriter, request *http.Request) {
wishlist := api.wishlist.GetWishlist(pageParsed, sizeParsed, uint(userIdParsed))

wishlistPage := models.WishlistPage{
Wishlist: wishlist,
Wishlist: *wishlist,
}

err := json.NewEncoder(w).Encode(wishlistPage)
Expand All @@ -39,7 +38,7 @@ func (api *API) GetWishlistItem(w http.ResponseWriter, request *http.Request) {
w.Header().Set("Content-Type", "application/json")
queryParams := request.URL.Query()

fmt.Println(queryParams)
//fmt.Println(queryParams)

userId := queryParams.Get("userId")
movieId := queryParams.Get("movieId")
Expand Down Expand Up @@ -84,7 +83,7 @@ func (api *API) DeleteWishlistItem(w http.ResponseWriter, request *http.Request)
w.Header().Set("Content-Type", "application/json")
queryParams := request.URL.Query()

fmt.Println(queryParams)
//fmt.Println(queryParams)

userId := queryParams.Get("userId")
movieId := queryParams.Get("movieId")
Expand Down
6 changes: 3 additions & 3 deletions user-movies-service/models/watchlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type WatchlistItem struct {
}

type WatchlistPage struct {
Watchlist *[]WatchlistItem `json:"watchlist"`
Watchlist []WatchlistItem `json:"watchlist"`
}

type WatchlistItemJSON struct {
Expand All @@ -44,13 +44,13 @@ func NewWatchlistManager(db *DB) (*WatchlistManager, error) {

func (state *WatchlistManager) GetWatchlist(page uint64, size uint64, userId uint) *[]WatchlistItem {
var watchlist []WatchlistItem
state.db.Where("user_id=? AND deleted_at=?", userId, nil).Find(&watchlist).Offset(int(page * size)).Limit(int(size))
state.db.Where("user_id=?", userId).Find(&watchlist).Offset(int(page * size)).Limit(int(size))
return &watchlist
}

func (state *WatchlistManager) FindWatchlistItem(userId uint, movieId string) *WatchlistItem {
watchlistItem := WatchlistItem{}
state.db.Where("imdb_id=? AND user_id=? AND deleted_at=?", movieId, userId, nil).Find(&watchlistItem)
state.db.Where("imdb_id=? AND user_id=?", movieId, userId).Find(&watchlistItem)
return &watchlistItem
}

Expand Down
6 changes: 3 additions & 3 deletions user-movies-service/models/wishlist.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type WishlistItem struct {
}

type WishlistPage struct {
Wishlist *[]WishlistItem `json:"wishlist"`
Wishlist []WishlistItem `json:"wishlist"`
}

type WishlistItemJSON struct {
Expand Down Expand Up @@ -45,13 +45,13 @@ func NewWishlistManager(db *DB) (*WishlistManager, error) {

func (state *WishlistManager) GetWishlist(page uint64, size uint64, userId uint) *[]WishlistItem {
var wishlist []WishlistItem
state.db.Where("user_id=? AND deleted_at=?", userId, nil).Find(&wishlist).Offset(int(page * size)).Limit(int(size))
state.db.Where("user_id=?", userId).Find(&wishlist).Offset(int(page * size)).Limit(int(size))
return &wishlist
}

func (state *WishlistManager) FindWishlistItem(userId uint, movieId string) *WishlistItem {
wishlistItem := WishlistItem{}
state.db.Where("imdb_id=? AND user_id=? AND deleted_at=?", movieId, userId, nil).Find(&wishlistItem)
state.db.Where("imdb_id=? AND user_id=?", movieId, userId).Find(&wishlistItem)
return &wishlistItem
}

Expand Down
5 changes: 2 additions & 3 deletions user-service/api/users.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package api

import (
"encoding/json"
"fmt"
"github.com/Dado555/glef.icu/user-service/auth"
"github.com/Dado555/glef.icu/user-service/models"
"github.com/gorilla/mux"
Expand Down Expand Up @@ -166,7 +165,7 @@ func (api *API) UserSearch(w http.ResponseWriter, req *http.Request) {
w.Header().Set("Content-Type", "application/json")
queryParams := req.URL.Query()

fmt.Println(queryParams)
// fmt.Println(queryParams)
name := queryParams.Get("name")
users := api.users.SearchUsers(name)

Expand Down Expand Up @@ -217,7 +216,7 @@ func (api *API) GetUsersPage(w http.ResponseWriter, request *http.Request) {
w.Header().Set("Content-Type", "application/json")
queryParams := request.URL.Query()

fmt.Println(queryParams)
//fmt.Println(queryParams)

page := queryParams.Get("page")
size := queryParams.Get("size")
Expand Down

0 comments on commit 04721a6

Please sign in to comment.