可用
This commit is contained in:
		
							
								
								
									
										17
									
								
								bin/main.go
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								bin/main.go
									
									
									
									
									
								
							@@ -4,8 +4,8 @@ import (
 | 
			
		||||
	"context"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"log"
 | 
			
		||||
	"net/url"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"net/url"
 | 
			
		||||
	"runtime"
 | 
			
		||||
	"strings"
 | 
			
		||||
	"time"
 | 
			
		||||
@@ -603,7 +603,7 @@ func main() {
 | 
			
		||||
	})
 | 
			
		||||
 | 
			
		||||
	// 获取转换后的m3u8视频链接
 | 
			
		||||
	http.HandleFunc("/video/", func(w http.ResponseWriter, r *http.Request) {
 | 
			
		||||
	http.HandleFunc("/video", func(w http.ResponseWriter, r *http.Request) {
 | 
			
		||||
		defer LogComponent(time.Now().UnixNano(), r) // 最后打印日志
 | 
			
		||||
 | 
			
		||||
		queryParam := r.URL.Query().Get("url")
 | 
			
		||||
@@ -615,18 +615,15 @@ func main() {
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		fmt.Println("safeParam", safeParam)
 | 
			
		||||
		urls := models.GetVideoM3U8(safeParam)
 | 
			
		||||
 | 
			
		||||
		// 将对象转换为有缩进的JSON输出
 | 
			
		||||
		json, err := json.MarshalIndent(&struct{Urls string `json:"urls"`}{
 | 
			
		||||
			Urls: urls,
 | 
			
		||||
		}, "", "    ")
 | 
			
		||||
		urls, err := models.GetVideoM3U8(safeParam)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			log.Println(err)
 | 
			
		||||
			log.Println("获取视频链接失败", err)
 | 
			
		||||
			w.WriteHeader(http.StatusBadRequest)
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// 输出JSON
 | 
			
		||||
		// 将对象转换为有缩进的JSON输出
 | 
			
		||||
		json, _ := json.MarshalIndent(urls, "", "    ")
 | 
			
		||||
		w.Header().Set("Content-Type", "application/json")
 | 
			
		||||
		w.Write(json)
 | 
			
		||||
	})
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user