Skip to content

Commit

Permalink
Merge pull request #106 from bcc-code/feat/sha-title
Browse files Browse the repository at this point in the history
feat(bmmexport): Add SHA of title to the end of VX-ID
  • Loading branch information
fredrikvedvik authored Nov 10, 2023
2 parents e88bbcf + f404f02 commit 542c52a
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions workflows/export/vx_export_bmm.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package export

import (
"crypto/sha1"
"encoding/json"
"fmt"
"net/http"
Expand Down Expand Up @@ -124,9 +125,8 @@ func VXExportToBMM(ctx workflow.Context, params VXExportChildWorkflowParams) (*V
// Prepare data for the JSON file
jsonData := prepareBMMData(audioResults, normalizedResults)
jsonData.Length = int(params.MergeResult.Duration)
jsonData.MediabankenID = params.ParentParams.VXID
jsonData.MediabankenID = fmt.Sprintf("%s-%s", params.ParentParams.VXID, HashTitle(params.ExportData.Title))

// TODO: Title is messy, we should have "Human readable" variant
jsonData.Title = params.ExportData.Title

marshalled, err := json.Marshal(jsonData)
Expand Down Expand Up @@ -234,3 +234,8 @@ func prepareBMMData(audioFiles map[string][]common.AudioResult, analysis map[str
return out

}

func HashTitle(title string) string {
hash := sha1.Sum([]byte(title))
return fmt.Sprintf("%x", hash)[0:8]
}

0 comments on commit 542c52a

Please sign in to comment.