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)
|
url, args := getUrl(r)
|
||||||
medias, _, err := getMediaResults(url, args)
|
medias, _, err := getMediaResults(url, args)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Error().Msgf("error getting media results: %v", err)
|
||||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if len(medias) == 0 {
|
if len(medias) == 0 {
|
||||||
|
log.Error().Msgf("not media found")
|
||||||
http.Error(w, "Media not found", http.StatusBadRequest)
|
http.Error(w, "Media not found", http.StatusBadRequest)
|
||||||
return
|
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",
|
"--format": "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/best",
|
||||||
"--merge-output-format": "mp4",
|
"--merge-output-format": "mp4",
|
||||||
"--trim-filenames": "100",
|
"--trim-filenames": "100",
|
||||||
|
"--recode-video": "mp4",
|
||||||
"--restrict-filenames": "",
|
"--restrict-filenames": "",
|
||||||
"--write-info-json": "",
|
"--write-info-json": "",
|
||||||
"--verbose": "",
|
"--verbose": "",
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ func ServeMedia(w http.ResponseWriter, r *http.Request) {
|
||||||
func streamFileToClientById(w http.ResponseWriter, r *http.Request, id string) {
|
func streamFileToClientById(w http.ResponseWriter, r *http.Request, id string) {
|
||||||
filename, err := getFileFromId(id)
|
filename, err := getFileFromId(id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Error().Msgf("error getting file from id %s: %v", id, err)
|
||||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
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)
|
openfile, err := os.Open(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
//File not found, send 404
|
//File not found, send 404
|
||||||
|
log.Error().Msgf("error opening file %s: %v", filename, err)
|
||||||
http.Error(w, "File not found.", 404)
|
http.Error(w, "File not found.", 404)
|
||||||
return
|
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-Disposition", "filename="+filepath.Base(filename))
|
||||||
w.Header().Set("Content-Type", fileContentType)
|
w.Header().Set("Content-Type", fileContentType)
|
||||||
|
|
||||||
|
log.Info().Msgf("Opening file for streaming %s", filename)
|
||||||
|
|
||||||
// Send the file
|
// Send the file
|
||||||
// We read n bytes from the file already, so we reset the offset back to 0
|
// We read n bytes from the file already, so we reset the offset back to 0
|
||||||
if _, err = openfile.Seek(0, 0); err != nil {
|
if _, err = openfile.Seek(0, 0); err != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue