mirror of
https://github.com/JuLi0n21/pwa-player.git
synced 2026-04-19 23:40:05 +00:00
var switch, fmt, npe fix
This commit is contained in:
@@ -37,16 +37,6 @@ type Server struct {
|
|||||||
v1.UnimplementedMusicBackendServer
|
v1.UnimplementedMusicBackendServer
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) registerRoutes() *http.ServeMux {
|
|
||||||
mux := http.NewServeMux()
|
|
||||||
|
|
||||||
mux.HandleFunc("/api/v1/audio/{filepath}", s.songFile)
|
|
||||||
mux.HandleFunc("/api/v1/image/{filepath}", s.imageFile)
|
|
||||||
mux.HandleFunc("/api/v1/callback", s.callback)
|
|
||||||
|
|
||||||
return mux
|
|
||||||
}
|
|
||||||
|
|
||||||
func logRequests(next http.Handler) http.Handler {
|
func logRequests(next http.Handler) http.Handler {
|
||||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
log.Printf("%s %s %s", r.RemoteAddr, r.Method, r.URL.Path)
|
log.Printf("%s %s %s", r.RemoteAddr, r.Method, r.URL.Path)
|
||||||
@@ -73,10 +63,6 @@ func (s *Server) Ping(ctx context.Context, req *v1.PingRequest) (*v1.PingRespons
|
|||||||
return &v1.PingResponse{Pong: "pong"}, nil
|
return &v1.PingResponse{Pong: "pong"}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) login(w http.ResponseWriter, r *http.Request) {
|
|
||||||
http.Redirect(w, r, "https://proxy.illegalesachen.download/login", http.StatusTemporaryRedirect)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (s *Server) Song(ctx context.Context, req *v1.SongRequest) (*v1.SongResponse, error) {
|
func (s *Server) Song(ctx context.Context, req *v1.SongRequest) (*v1.SongResponse, error) {
|
||||||
|
|
||||||
hash := req.Hash
|
hash := req.Hash
|
||||||
@@ -153,9 +139,9 @@ func (s *Server) Collections(ctx context.Context, req *v1.CollectionRequest) (*v
|
|||||||
}
|
}
|
||||||
|
|
||||||
c, err := s.Sqlc.GetCollectionByOffset(ctx, sqlcdb.GetCollectionByOffsetParams{
|
c, err := s.Sqlc.GetCollectionByOffset(ctx, sqlcdb.GetCollectionByOffsetParams{
|
||||||
Offset: int64(req.Index),
|
Offset: int64(offset),
|
||||||
Limit: int64(limit),
|
Limit: int64(limit),
|
||||||
Offset_2: int64(offset),
|
Index: int64(req.Index),
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
@@ -196,8 +182,7 @@ func (s *Server) Search(ctx context.Context, req *v1.SearchSharedRequest) (*v1.S
|
|||||||
func (s *Server) SearchCollections(ctx context.Context, req *v1.SearchCollectionRequest) (*v1.SearchCollectionResponse, error) {
|
func (s *Server) SearchCollections(ctx context.Context, req *v1.SearchCollectionRequest) (*v1.SearchCollectionResponse, error) {
|
||||||
q := req.Query
|
q := req.Query
|
||||||
q = "%" + q + "%"
|
q = "%" + q + "%"
|
||||||
//limit := defaultLimit(int(req.Limit))
|
limit := defaultLimit(int(req.Limit))
|
||||||
limit := 10000
|
|
||||||
offset := int(req.Offset)
|
offset := int(req.Offset)
|
||||||
|
|
||||||
preview, err := s.Sqlc.SearchCollection(ctx, sqlcdb.SearchCollectionParams{
|
preview, err := s.Sqlc.SearchCollection(ctx, sqlcdb.SearchCollectionParams{
|
||||||
|
|||||||
@@ -224,6 +224,7 @@ const searchBeatmaps = `-- name: SearchBeatmaps :many
|
|||||||
SELECT beatmapid, artist, artistunicode, title, titleunicode, creator, difficulty, audio, md5hash, file, rankedstatus, lastmodifiedtime, totaltime, audiopreviewtime, beatmapsetid, source, tags, lastplayed, folder
|
SELECT beatmapid, artist, artistunicode, title, titleunicode, creator, difficulty, audio, md5hash, file, rankedstatus, lastmodifiedtime, totaltime, audiopreviewtime, beatmapsetid, source, tags, lastplayed, folder
|
||||||
FROM Beatmap
|
FROM Beatmap
|
||||||
WHERE Title LIKE ? OR Artist LIKE ?
|
WHERE Title LIKE ? OR Artist LIKE ?
|
||||||
|
GROUP BY Folder
|
||||||
LIMIT ? OFFSET ?
|
LIMIT ? OFFSET ?
|
||||||
`
|
`
|
||||||
|
|
||||||
|
|||||||
@@ -92,13 +92,13 @@ WHERE c.Name = (
|
|||||||
ORDER BY Name
|
ORDER BY Name
|
||||||
LIMIT 1 OFFSET ?1
|
LIMIT 1 OFFSET ?1
|
||||||
)
|
)
|
||||||
LIMIT ?2 OFFSET ?3
|
LIMIT ?3 OFFSET ?2
|
||||||
`
|
`
|
||||||
|
|
||||||
type GetCollectionByOffsetParams struct {
|
type GetCollectionByOffsetParams struct {
|
||||||
|
Index int64 `json:"index"`
|
||||||
Offset int64 `json:"offset"`
|
Offset int64 `json:"offset"`
|
||||||
Limit int64 `json:"limit"`
|
Limit int64 `json:"limit"`
|
||||||
Offset_2 int64 `json:"offset_2"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type GetCollectionByOffsetRow struct {
|
type GetCollectionByOffsetRow struct {
|
||||||
@@ -115,7 +115,7 @@ type GetCollectionByOffsetRow struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (q *Queries) GetCollectionByOffset(ctx context.Context, arg GetCollectionByOffsetParams) ([]GetCollectionByOffsetRow, error) {
|
func (q *Queries) GetCollectionByOffset(ctx context.Context, arg GetCollectionByOffsetParams) ([]GetCollectionByOffsetRow, error) {
|
||||||
rows, err := q.db.QueryContext(ctx, getCollectionByOffset, arg.Offset, arg.Limit, arg.Offset_2)
|
rows, err := q.db.QueryContext(ctx, getCollectionByOffset, arg.Index, arg.Offset, arg.Limit)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ FROM Beatmap GROUP BY Folder ORDER BY LastModifiedTime DESC LIMIT ? OFFSET ?;
|
|||||||
SELECT *
|
SELECT *
|
||||||
FROM Beatmap
|
FROM Beatmap
|
||||||
WHERE Title LIKE ? OR Artist LIKE ?
|
WHERE Title LIKE ? OR Artist LIKE ?
|
||||||
|
GROUP BY Folder
|
||||||
LIMIT ? OFFSET ?;
|
LIMIT ? OFFSET ?;
|
||||||
|
|
||||||
-- name: SearchArtists :many
|
-- name: SearchArtists :many
|
||||||
|
|||||||
@@ -35,9 +35,9 @@ WHERE c.Name = (
|
|||||||
FROM Collection
|
FROM Collection
|
||||||
GROUP BY Name
|
GROUP BY Name
|
||||||
ORDER BY Name
|
ORDER BY Name
|
||||||
LIMIT 1 OFFSET ?1
|
LIMIT 1 OFFSET @index
|
||||||
)
|
)
|
||||||
LIMIT ?2 OFFSET ?3;
|
LIMIT @limit OFFSET @offset;
|
||||||
|
|
||||||
-- name: GetCollectionByName :many
|
-- name: GetCollectionByName :many
|
||||||
SELECT c.Name, b.BeatmapId, b.MD5Hash, b.Title, b.Artist, b.Creator, b.Folder, b.File, b.Audio, b.TotalTime
|
SELECT c.Name, b.BeatmapId, b.MD5Hash, b.Title, b.Artist, b.Creator, b.Folder, b.File, b.Audio, b.TotalTime
|
||||||
|
|||||||
@@ -70,8 +70,13 @@ func toProtoCollectionoffsetSqlc(rows []db.GetCollectionByOffsetRow) *v1.Collect
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
name := "Empty Collection"
|
||||||
|
if len(rows) > 0 {
|
||||||
|
name = rows[0].Name.String
|
||||||
|
}
|
||||||
|
|
||||||
return &v1.CollectionResponse{
|
return &v1.CollectionResponse{
|
||||||
Name: rows[0].Name.String,
|
Name: name,
|
||||||
Items: int32(len(rows)),
|
Items: int32(len(rows)),
|
||||||
Songs: songs,
|
Songs: songs,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user