-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
78304b4
commit 684d7ce
Showing
12 changed files
with
2,731 additions
and
3,585 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,12 @@ | ||
.PHONY: proto run | ||
|
||
proto: | ||
rm -rf generated | ||
mkdir generated | ||
protoc ./proto/**/*.proto --go_out=. --go-grpc_out=. | ||
rm -rf web/generated | ||
mkdir web/generated | ||
protoc --grpc-web_out=import_style=typescript,mode=grpcwebtext:web/generated/ proto/**/*.proto | ||
|
||
run: | ||
go run ./cmd/subtle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package media | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/nandesh-dev/subtle/generated/api/media" | ||
"github.com/nandesh-dev/subtle/pkgs/config" | ||
"github.com/nandesh-dev/subtle/pkgs/filemanager" | ||
) | ||
|
||
func (s *MediaServiceServer) GetDirectory(ctx context.Context, req *media.GetDirectoryRequest) (*media.GetDirectoryResponse, error) { | ||
if req.Path == "/" || req.Path == "" { | ||
res := media.GetDirectoryResponse{ | ||
Directories: make([]*media.Directory, 0), | ||
Videos: make([]*media.Video, 0), | ||
} | ||
|
||
for _, rootDirectory := range config.Config().Media.RootDirectories { | ||
res.Directories = append(res.Directories, &media.Directory{ | ||
Path: rootDirectory.Path, | ||
}) | ||
} | ||
|
||
return &res, nil | ||
} | ||
|
||
res := media.GetDirectoryResponse{ | ||
Directories: make([]*media.Directory, 0), | ||
} | ||
|
||
dir, _, _ := filemanager.ReadDirectory(req.Path) | ||
|
||
for _, child := range dir.Children() { | ||
res.Directories = append(res.Directories, &media.Directory{ | ||
Path: child.Path(), | ||
}) | ||
} | ||
|
||
for _, video := range dir.VideoFiles() { | ||
res.Videos = append(res.Videos, &media.Video{ | ||
Name: video.Basename(), | ||
Extension: video.Extension(), | ||
}) | ||
} | ||
|
||
return &res, nil | ||
} | ||
|
||
func compileResponseDirectory(directory filemanager.Directory) *media.Directory { | ||
return &media.Directory{ | ||
Path: directory.Path(), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package media | ||
|
||
import ( | ||
"github.com/nandesh-dev/subtle/generated/api/media" | ||
) | ||
|
||
type MediaServiceServer struct { | ||
media.UnsafeMediaServiceServer | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
syntax = "proto3"; | ||
|
||
package media; | ||
|
||
option go_package = "generated/api/media"; | ||
|
||
service MediaService { | ||
rpc GetDirectory(GetDirectoryRequest) returns (GetDirectoryResponse); | ||
} | ||
|
||
message GetDirectoryRequest { | ||
string path = 1; | ||
} | ||
|
||
message Video { | ||
string name = 1; | ||
string extension = 2; | ||
} | ||
|
||
message Directory { | ||
string path = 1; | ||
} | ||
|
||
message GetDirectoryResponse { | ||
repeated Directory directories = 1; | ||
repeated Video videos = 2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.