Skip to content

Commit

Permalink
Merge pull request #65 from brotherlogic/run_rip
Browse files Browse the repository at this point in the history
Working on ripper
  • Loading branch information
brotherlogic committed Jan 12, 2019
2 parents 661ddb3 + eb31cac commit 1699c6c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
35 changes: 34 additions & 1 deletion cdprocessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"strings"
"time"

pbgd "github.com/brotherlogic/godiscogs"
"github.com/brotherlogic/goserver"
"github.com/brotherlogic/goserver/utils"
"golang.org/x/net/context"
Expand All @@ -19,12 +18,44 @@ import (
"google.golang.org/grpc/status"

pb "github.com/brotherlogic/cdprocessor/proto"
pbe "github.com/brotherlogic/executor/proto"
pbgh "github.com/brotherlogic/githubcard/proto"
pbgd "github.com/brotherlogic/godiscogs"
pbg "github.com/brotherlogic/goserver/proto"
pbrc "github.com/brotherlogic/recordcollection/proto"
pbvs "github.com/brotherlogic/versionserver/proto"
)

type ripper interface {
ripToMp3(ctx context.Context, pathIn, pathOut string)
}

type prodRipper struct {
server string
}

func (pr *prodRipper) ripToMp3(ctx context.Context, pathIn, pathOut string) {
entries, err := utils.ResolveAll("executor")

if err != nil {
return
}

for _, entry := range entries {
if entry.Identifier == pr.server {
conn, err := grpc.Dial(entry.Ip+":"+strconv.Itoa(int(entry.Port)), grpc.WithInsecure())
defer conn.Close()

if err != nil {
log.Fatalf("Unable to dial: %v", err)
}

client := pbe.NewExecutorServiceClient(conn)
client.Execute(ctx, &pbe.ExecuteRequest{Command: &pbe.Command{Binary: "lame", Parameters: []string{pathIn, pathOut}}})
}
}
}

type getter interface {
getRecord(ctx context.Context, id int32) (*pbrc.Record, error)
updateRecord(ctx context.Context, rec *pbrc.Record)
Expand Down Expand Up @@ -179,6 +210,7 @@ type Server struct {
adjust int
rips []*pb.Rip
ripCount int64
dir string
}

// Init builds the server
Expand All @@ -188,6 +220,7 @@ func Init(dir string) *Server {
rc: &prodRc{},
gh: &prodGh{},
getter: &prodGetter{},
dir: dir,
}
s.io = &prodIo{dir: dir, log: s.Log}
s.getter = &prodGetter{log: s.Log}
Expand Down
4 changes: 3 additions & 1 deletion cdprocessorutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ func (s *Server) convertToMP3(ctx context.Context) {
for _, t := range rip.Tracks {
if len(t.WavPath) > 0 && len(t.Mp3Path) == 0 {
s.ripCount++
s.Log(fmt.Sprintf("Ripping %v", t))
s.Log(fmt.Sprintf("Ripping %v -> %v", s.dir+t.WavPath, s.dir+t.WavPath[0:len(t.WavPath)-3]+".mp3"))
s.buildConfig(ctx)
return
}
}
}
Expand Down

0 comments on commit 1699c6c

Please sign in to comment.