Skip to content

Commit

Permalink
Json does not have nice rune mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
KillerX committed Nov 28, 2024
1 parent cb50823 commit 728c056
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions workflows/misc/merge_import_subs.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ type MergeAndImportSubtitlesFromCSVParams struct {
TargetVXID string
CSVData string
Title string
Separator rune
Separator string
}

func convertCSVTimestamp(timestamp string) (float64, error) {
Expand All @@ -45,6 +45,13 @@ func convertCSVTimestamp(timestamp string) (float64, error) {
return float64(t.Hour()*3600+t.Minute()*60+t.Second()) + ms.Seconds(), nil
}

func getSeparatorRune(s string) rune {
for _, r := range s {
return r
}
return ','
}

func MergeAndImportSubtitlesFromCSV(ctx workflow.Context, params MergeAndImportSubtitlesFromCSVParams) (bool, error) {

logger := workflow.GetLogger(ctx)
Expand All @@ -58,7 +65,7 @@ func MergeAndImportSubtitlesFromCSV(ctx workflow.Context, params MergeAndImportS
tempPath, _ := wfutils.GetWorkflowTempFolder(ctx)
outputPath, _ := wfutils.GetWorkflowAuxOutputFolder(ctx)

entries, err := parseSubMergeData([]byte(params.CSVData), params.Separator)
entries, err := parseSubMergeData([]byte(params.CSVData), getSeparatorRune(params.Separator))
if err != nil {
return false, err
}
Expand Down

0 comments on commit 728c056

Please sign in to comment.