feat: comment out logging statements in image and video processing functions for cleaner output
This commit is contained in:
parent
3de192636b
commit
d3b9174ab8
3 changed files with 11 additions and 14 deletions
|
|
@ -186,7 +186,7 @@ func Conversion(input string) (string, string, error) {
|
||||||
outputdir := filepath.Dir(input)
|
outputdir := filepath.Dir(input)
|
||||||
ext := filepath.Ext(output)
|
ext := filepath.Ext(output)
|
||||||
output = output[0 : len(output)-len(ext)] // Remove file extension // Add .webp extension
|
output = output[0 : len(output)-len(ext)] // Remove file extension // Add .webp extension
|
||||||
log.Println("Converting", input, "to", output+".webp")
|
//log.Println("Converting", input, "to", output+".webp")
|
||||||
f, err := os.Open(input)
|
f, err := os.Open(input)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return empty, empty, err
|
return empty, empty, err
|
||||||
|
|
@ -227,7 +227,7 @@ func Conversion(input string) (string, string, error) {
|
||||||
return empty, empty, fmt.Errorf("error in thumbnail creation: %w", err)
|
return empty, empty, fmt.Errorf("error in thumbnail creation: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("Conversion completed successfully")
|
//fmt.Println("Conversion completed successfully")
|
||||||
|
|
||||||
return fmt.Sprintf("%s/%s.webp", outputdir, output), fmt.Sprintf("%s/thumbnail-%s.webp", outputdir, output), nil
|
return fmt.Sprintf("%s/%s.webp", outputdir, output), fmt.Sprintf("%s/thumbnail-%s.webp", outputdir, output), nil
|
||||||
}
|
}
|
||||||
|
|
@ -238,7 +238,7 @@ func image_creation(img image.Image, width uint, output string, outputdir string
|
||||||
|
|
||||||
// Create the output file
|
// Create the output file
|
||||||
outputPath := fmt.Sprintf("%s/%s.webp", outputdir, output)
|
outputPath := fmt.Sprintf("%s/%s.webp", outputdir, output)
|
||||||
log.Println("Creating", outputPath)
|
//log.Println("Creating", outputPath)
|
||||||
out, err := os.Create(outputPath)
|
out, err := os.Create(outputPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
@ -259,7 +259,7 @@ func thumbnail_creation(img image.Image, output string, outputdir string) error
|
||||||
|
|
||||||
// Create the output file
|
// Create the output file
|
||||||
outputPath := fmt.Sprintf("%s/thumbnail-%s.webp", outputdir, output)
|
outputPath := fmt.Sprintf("%s/thumbnail-%s.webp", outputdir, output)
|
||||||
log.Println("Creating", outputPath)
|
//log.Println("Creating", outputPath)
|
||||||
out, err := os.Create(outputPath)
|
out, err := os.Create(outputPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package utils
|
package utils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
|
|
@ -81,29 +80,27 @@ func GetDataXML[T any](url string) (T, error) {
|
||||||
|
|
||||||
resp, err := client.Do(req)
|
resp, err := client.Do(req)
|
||||||
log.Printf("Response Status: %s", resp.Status)
|
log.Printf("Response Status: %s", resp.Status)
|
||||||
if jsonBytes, err := json.MarshalIndent(resp.Header, "", " "); err == nil {
|
// if jsonBytes, err := json.MarshalIndent(resp.Header, "", " "); err == nil {
|
||||||
log.Printf("Headers:\n%s", string(jsonBytes))
|
// log.Printf("Headers:\n%s", string(jsonBytes))
|
||||||
}
|
// }
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
||||||
return result, fmt.Errorf("Failed to fetch url %s: %w", url, err)
|
return result, fmt.Errorf("Failed to fetch url %s: %w", url, err)
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
if resp.StatusCode != http.StatusOK {
|
if resp.StatusCode != http.StatusOK {
|
||||||
|
|
||||||
log.Printf("Fetch XML error: status error: %d", resp.StatusCode)
|
log.Printf("Fetch XML error: status error: %d", resp.StatusCode)
|
||||||
return result, fmt.Errorf("Failed to fetch url %s: status error: %d", url, resp.StatusCode)
|
return result, fmt.Errorf("Failed to fetch url %s: status error: %d", url, resp.StatusCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
body, err := io.ReadAll(resp.Body)
|
body, err := io.ReadAll(resp.Body)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return result, fmt.Errorf("failed to read response: %w", err)
|
return result, fmt.Errorf("failed to read response: %w, body: %s", err, string(body))
|
||||||
}
|
}
|
||||||
|
|
||||||
err = xml.Unmarshal(body, &result)
|
err = xml.Unmarshal(body, &result)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return result, fmt.Errorf("failed to unmarshal XML: %w", err)
|
return result, fmt.Errorf("failed to unmarshal XML: %w, body: %s", err, string(body))
|
||||||
}
|
}
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -202,14 +202,14 @@ func VideoConversion(input string) (string, string, error) {
|
||||||
thumbOutput := filepath.Join(outputdir, "thumbnail-"+nameWithoutExt+".webp")
|
thumbOutput := filepath.Join(outputdir, "thumbnail-"+nameWithoutExt+".webp")
|
||||||
|
|
||||||
// 1. Transcode video to H.264/AAC MP4 (web-optimized)
|
// 1. Transcode video to H.264/AAC MP4 (web-optimized)
|
||||||
log.Println("Transcoding video:", input)
|
//log.Println("Transcoding video:", input)
|
||||||
err := transcodeVideo(input, tempVideo)
|
err := transcodeVideo(input, tempVideo)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", "", fmt.Errorf("failed to transcode video: %w", err)
|
return "", "", fmt.Errorf("failed to transcode video: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Extract thumbnail from video at 1 second
|
// 2. Extract thumbnail from video at 1 second
|
||||||
log.Println("Extracting thumbnail from:", input)
|
//log.Println("Extracting thumbnail from:", input)
|
||||||
err = extractThumbnail(input, thumbOutput)
|
err = extractThumbnail(input, thumbOutput)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", "", fmt.Errorf("failed to extract thumbnail: %w", err)
|
return "", "", fmt.Errorf("failed to extract thumbnail: %w", err)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue