Add more logs
This commit is contained in:
parent
175955cdd1
commit
a6fd44cda7
2 changed files with 7 additions and 0 deletions
|
|
@ -75,10 +75,12 @@ func FetchMediaApi(w http.ResponseWriter, r *http.Request) {
|
|||
url, args := getUrl(r)
|
||||
medias, _, err := getMediaResults(url, args)
|
||||
if err != nil {
|
||||
log.Error().Msgf("error getting media results: %v", err)
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
if len(medias) == 0 {
|
||||
log.Error().Msgf("not media found")
|
||||
http.Error(w, "Media not found", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
|
@ -151,6 +153,7 @@ func downloadMedia(url string, requestArgs map[string]string) (string, string, e
|
|||
"--format": "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best",
|
||||
"--merge-output-format": "mp4",
|
||||
"--trim-filenames": "100",
|
||||
"--recode-video": "mp4",
|
||||
"--restrict-filenames": "",
|
||||
"--write-info-json": "",
|
||||
"--verbose": "",
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ func ServeMedia(w http.ResponseWriter, r *http.Request) {
|
|||
func streamFileToClientById(w http.ResponseWriter, r *http.Request, id string) {
|
||||
filename, err := getFileFromId(id)
|
||||
if err != nil {
|
||||
log.Error().Msgf("error getting file from id %s: %v", id, err)
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
}
|
||||
|
||||
|
|
@ -40,6 +41,7 @@ func streamFileToClient(w http.ResponseWriter, r *http.Request, filename string)
|
|||
openfile, err := os.Open(filename)
|
||||
if err != nil {
|
||||
//File not found, send 404
|
||||
log.Error().Msgf("error opening file %s: %v", filename, err)
|
||||
http.Error(w, "File not found.", 404)
|
||||
return
|
||||
}
|
||||
|
|
@ -62,6 +64,8 @@ func streamFileToClient(w http.ResponseWriter, r *http.Request, filename string)
|
|||
w.Header().Set("Content-Disposition", "filename="+filepath.Base(filename))
|
||||
w.Header().Set("Content-Type", fileContentType)
|
||||
|
||||
log.Info().Msgf("Opening file for streaming %s", filename)
|
||||
|
||||
// Send the file
|
||||
// We read n bytes from the file already, so we reset the offset back to 0
|
||||
if _, err = openfile.Seek(0, 0); err != nil {
|
||||
|
|
|
|||
Loading…
Reference in a new issue