gemercheung 1 rok pred
commit
f13aa969f3
11 zmenil súbory, kde vykonal 807 pridanie a 0 odobranie
  1. 8 0
      .idea/.gitignore
  2. 9 0
      .idea/downloadQJ.iml
  3. 8 0
      .idea/modules.xml
  4. 6 0
      .idea/vcs.xml
  5. 160 0
      cmd/download.go
  6. 35 0
      go.mod
  7. 72 0
      go.sum
  8. 9 0
      main.go
  9. 88 0
      utils/getScenes.go
  10. 67 0
      utils/localizeMainJson.go
  11. 345 0
      utils/somedataType.go

+ 8 - 0
.idea/.gitignore

@@ -0,0 +1,8 @@
+# 默认忽略的文件
+/shelf/
+/workspace.xml
+# 基于编辑器的 HTTP 客户端请求
+/httpRequests/
+# Datasource local storage ignored files
+/dataSources/
+/dataSources.local.xml

+ 9 - 0
.idea/downloadQJ.iml

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="WEB_MODULE" version="4">
+  <component name="Go" enabled="true" />
+  <component name="NewModuleRootManager">
+    <content url="file://$MODULE_DIR$" />
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+  </component>
+</module>

+ 8 - 0
.idea/modules.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ProjectModuleManager">
+    <modules>
+      <module fileurl="file://$PROJECT_DIR$/.idea/downloadQJ.iml" filepath="$PROJECT_DIR$/.idea/downloadQJ.iml" />
+    </modules>
+  </component>
+</project>

+ 6 - 0
.idea/vcs.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="VcsDirectoryMappings">
+    <mapping directory="$PROJECT_DIR$" vcs="Git" />
+  </component>
+</project>

+ 160 - 0
cmd/download.go

@@ -0,0 +1,160 @@
+package cmd
+
+import (
+	"downloadQJ/utils"
+	"fmt"
+	"github.com/mitchellh/go-homedir"
+	"github.com/spf13/cobra"
+	"github.com/spf13/viper"
+	"os"
+	"os/exec"
+	"strings"
+)
+
+var url string
+var outputFile string
+var cfgFile string
+
+var rootCmd = &cobra.Command{
+	Use:   "",
+	Short: "",
+	Long:  `This command will get QJkankan image tiles`,
+	Run:   RunCmd,
+}
+
+func RunCmd(cmd *cobra.Command, args []string) {
+	//log.Printf("url: %v\n", url)
+	//log.Printf("outputFile: %v\n\n", outputFile)
+	////
+	//if url == "" {
+	//	log.Println("url is empty!")
+	//}
+	//if outputFile == "" {
+	//	log.Println("outputFile is empty!")
+
+	//if !utils.IsCommandAvailable("ossutil") {
+	//	log.Println("ossutil is not exist")
+	//	return
+	//}
+
+	//}
+
+	dest := "D:\\data"
+	data := &utils.ScenesDataType{}
+
+	if _, err := os.Stat(dest); os.IsNotExist(err) {
+		err = os.Mkdir(dest, 0644)
+	}
+
+	err := utils.GetJson("https://4dkk.4dage.com/720yun_fd_manage/WK1792459279224066048/someData.json?_=0.08240579686447669", data)
+
+	//dataFile := dest + "/someData.json"
+	err = utils.CovertJsonAndDownload("https://4dkk.4dage.com/720yun_fd_manage/WK1792459279224066048/someData.json?_=0.08240579686447669", dest)
+
+	return
+
+	if err != nil {
+		fmt.Println("Error: ", err)
+	}
+	excludeArray := []string{"*.exe", "tour_testingserver_macos", "tour.html", "*.js", "vtourskin*.xml", "webvr.xml", "combobox.xml", "vtourskin*.png", "vtourskin.png", "rotate_device.png"}
+	exclString := " --exclude " + strings.Join(excludeArray, " --exclude ")
+
+	fmt.Printf("exclString -> %s\n", exclString)
+
+	if len(data.Scenes) > 0 {
+		for _, v := range data.Scenes {
+			if v.Type == "pano" {
+
+				for _, Hotspots := range v.SomeData.Hotspots {
+					// 主Tiles图
+					runMainTileDownload(v.SceneCode, dest, exclString)
+					// 热点封面图
+					if len(Hotspots.Secne.Icon) > 0 {
+						fmt.Printf("Hotspots-Icon -- %s\n", Hotspots.Secne.Icon)
+						url = utils.DetectSource(Hotspots.Secne.Icon, dest)
+						err = utils.DownloadFile(url, Hotspots.Secne.Icon)
+						fmt.Printf("Hotspots-Icon-save -- %s\n", url)
+					}
+					// 热点图集
+					if len(Hotspots.ImageTextInfo.ImageList) > 0 {
+						for _, img := range Hotspots.ImageTextInfo.ImageList {
+							fmt.Printf("Hotspots-ImageList-save -- %s\n", img.OssPath)
+							url = utils.DetectSource(img.OssPath, dest)
+							err = utils.DownloadFile(url, img.OssPath)
+							fmt.Printf("Hotspots-ImageList-save -- %s\n", url)
+						}
+					}
+				}
+
+				if len(v.CustomMask.Sky.Icon) > 0 {
+					fmt.Printf("CustomMask-Sky -- %s\n", v.CustomMask.Sky.Icon)
+					url = utils.DetectSource(v.CustomMask.Sky.Icon, dest)
+					err = utils.DownloadFile(url, v.CustomMask.Sky.Icon)
+					fmt.Printf("CustomMask-Sky-save -- %s\n", url)
+				}
+
+				if len(v.CustomMask.Earth.Icon) > 0 {
+					fmt.Printf("CustomMask-Earth -- %s\n", v.CustomMask.Earth.Icon)
+					url = utils.DetectSource(v.CustomMask.Earth.Icon, dest)
+					err = utils.DownloadFile(url, v.CustomMask.Earth.Icon)
+					fmt.Printf("CustomMask-Sky-save -- %s\n", url)
+				}
+			}
+
+		}
+	}
+
+}
+func runMainTileDownload(sceneCode string, dest string, exclString string) {
+	fmt.Printf("Scenescode -- %s\n", sceneCode)
+	command := "ossutil cp -r oss://4dkankan/720yun_fd_manage/" + sceneCode + " " + dest + " " + exclString
+
+	c := exec.Command("powershell", command)
+
+	fmt.Printf("copying folder:: %s\n", command)
+	if err := c.Run(); err != nil {
+		fmt.Println("Error: ", err)
+	}
+}
+
+func init() {
+	cobra.OnInitialize(initConfig)
+	rootCmd.PersistentFlags().StringVarP(&url, "url", "i", os.Getenv("HOME"), "clash online url")
+	rootCmd.PersistentFlags().StringVarP(&outputFile, "out", "o", os.Getenv("HOME"), "clash output file path")
+
+}
+
+// initConfig reads in config file and ENV variables if set.
+func initConfig() {
+	if cfgFile != "" {
+		// Use config file from the flag.
+		fmt.Printf("%v", cfgFile)
+		viper.SetConfigFile(cfgFile)
+	} else {
+		// Find home directory.
+		home, err := homedir.Dir()
+		if err != nil {
+			fmt.Println(err)
+			os.Exit(1)
+		}
+
+		// Search config in home directory with name ".dadjoke" (without extension).
+		viper.AddConfigPath(home)
+		viper.SetConfigName(".config")
+	}
+
+	viper.AutomaticEnv() // read in environment variables that match
+
+	// If a config file is found, read it in.
+	if err := viper.ReadInConfig(); err == nil {
+		fmt.Println("Using config file:", viper.ConfigFileUsed())
+	}
+}
+
+func Execute() {
+	err := rootCmd.Execute()
+	if err != nil {
+		os.Exit(1)
+	}
+
+}

+ 35 - 0
go.mod

@@ -0,0 +1,35 @@
+module downloadQJ
+
+go 1.22.2
+
+require github.com/spf13/cobra v1.8.0
+
+require (
+	github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible // indirect
+	github.com/fsnotify/fsnotify v1.7.0 // indirect
+	github.com/hashicorp/hcl v1.0.0 // indirect
+	github.com/inconshreveable/mousetrap v1.1.0 // indirect
+	github.com/magiconair/properties v1.8.7 // indirect
+	github.com/mitchellh/go-homedir v1.1.0 // indirect
+	github.com/mitchellh/mapstructure v1.5.0 // indirect
+	github.com/pelletier/go-toml/v2 v2.2.2 // indirect
+	github.com/sagikazarmark/locafero v0.4.0 // indirect
+	github.com/sagikazarmark/slog-shim v0.1.0 // indirect
+	github.com/sourcegraph/conc v0.3.0 // indirect
+	github.com/spf13/afero v1.11.0 // indirect
+	github.com/spf13/cast v1.6.0 // indirect
+	github.com/spf13/pflag v1.0.5 // indirect
+	github.com/spf13/viper v1.18.2 // indirect
+	github.com/subosito/gotenv v1.6.0 // indirect
+	github.com/tidwall/gjson v1.17.1 // indirect
+	github.com/tidwall/match v1.1.1 // indirect
+	github.com/tidwall/pretty v1.2.1 // indirect
+	go.uber.org/atomic v1.11.0 // indirect
+	go.uber.org/multierr v1.11.0 // indirect
+	golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect
+	golang.org/x/sys v0.20.0 // indirect
+	golang.org/x/text v0.15.0 // indirect
+	golang.org/x/time v0.5.0 // indirect
+	gopkg.in/ini.v1 v1.67.0 // indirect
+	gopkg.in/yaml.v3 v3.0.1 // indirect
+)

+ 72 - 0
go.sum

@@ -0,0 +1,72 @@
+github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible h1:8psS8a+wKfiLt1iVDX79F7Y6wUM49Lcha2FMXt4UM8g=
+github.com/aliyun/aliyun-oss-go-sdk v3.0.2+incompatible/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8=
+github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
+github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
+github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
+github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM=
+github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
+github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
+github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
+github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
+github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY=
+github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
+github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y=
+github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
+github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
+github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
+github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
+github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
+github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
+github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
+github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ=
+github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4=
+github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE=
+github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ=
+github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo=
+github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0=
+github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8=
+github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY=
+github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0=
+github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
+github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0=
+github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho=
+github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
+github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
+github.com/spf13/viper v1.18.2 h1:LUXCnvUvSM6FXAsj6nnfc8Q2tp1dIgUfY9Kc8GsSOiQ=
+github.com/spf13/viper v1.18.2/go.mod h1:EKmWIqdnk5lOcmR72yw6hS+8OPYcwD0jteitLMVB+yk=
+github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
+github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
+github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
+github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
+github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
+github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
+github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
+github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
+github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8=
+github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU=
+github.com/tidwall/gjson v1.17.1 h1:wlYEnwqAHgzmhNUFfw7Xalt2JzQvsMx2Se4PcoFCT/U=
+github.com/tidwall/gjson v1.17.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
+github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
+github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
+github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
+github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
+github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
+go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE=
+go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
+go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
+go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
+golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 h1:vr/HnozRka3pE4EsMEg1lgkXJkTFJCVUX+S/ZT6wYzM=
+golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc=
+golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
+golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
+golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
+golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
+golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
+golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
+gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
+gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
+gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
+gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
+gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
+gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

+ 9 - 0
main.go

@@ -0,0 +1,9 @@
+package main
+
+import (
+	"downloadQJ/cmd"
+)
+
+func main() {
+	cmd.Execute()
+}

+ 88 - 0
utils/getScenes.go

@@ -0,0 +1,88 @@
+package utils
+
+import (
+	"encoding/json"
+	"io"
+	"net/http"
+	"os"
+	"os/exec"
+	"path/filepath"
+	"strings"
+	"time"
+)
+
+var myClient = &http.Client{Timeout: 10 * time.Second}
+
+func GetJson(url string, target interface{}) error {
+	r, err := myClient.Get(url)
+	if err != nil {
+		return err
+	}
+	defer r.Body.Close()
+
+	return json.NewDecoder(r.Body).Decode(target)
+}
+
+func DownloadFile(path string, url string) (err error) {
+
+	dir := filepath.Dir(path)
+
+	err = os.MkdirAll(dir, 0644)
+	if err != nil {
+		return err
+	}
+	out, err := os.Create(path)
+	if err != nil {
+		return err
+	}
+	defer out.Close()
+
+	// Get the data
+	resp, err := http.Get(url)
+	if err != nil {
+		return err
+	}
+	defer resp.Body.Close()
+
+	// Writer the body to file
+	_, err = io.Copy(out, resp.Body)
+	if err != nil {
+		return err
+	}
+
+	return nil
+}
+
+func IsCommandAvailable(name string) bool {
+	cmd := exec.Command("command", "-v", name)
+	if err := cmd.Run(); err != nil {
+		return false
+	}
+	return true
+}
+
+func DetectSource(path string, dest string) (url string) {
+	saveP := strings.Split(path, "?")[0]
+
+	if strings.Contains(saveP, "https://4dkk.4dage.com/720yun_fd_manage") {
+		p := strings.ReplaceAll(saveP, "https://4dkk.4dage.com/720yun_fd_manage", "")
+		url = dest + p
+	}
+	if strings.Contains(saveP, "https://4dkk.4dage.com/scene_edit_data") {
+		p := strings.ReplaceAll(saveP, "https://4dkk.4dage.com", "")
+		url = dest + p
+	}
+
+	return url
+}
+
+func EnsureDir(dirName string) error {
+
+	err := os.MkdirAll(dirName, os.ModeDir)
+
+	if err == nil || os.IsExist(err) {
+		return nil
+	} else {
+		return err
+	}
+}

+ 67 - 0
utils/localizeMainJson.go

@@ -0,0 +1,67 @@
+package utils
+
+import (
+	"bytes"
+	"encoding/gob"
+	"encoding/json"
+	"fmt"
+	"io"
+	"net/http"
+	"os"
+	"strings"
+)
+
+func CovertJsonAndDownload(path string, dest string) (err error) {
+
+	dataFile := dest + "/someData.json"
+
+	out, err := os.Create(dataFile)
+	if err != nil {
+		return err
+	}
+	defer out.Close()
+
+	// Get the data
+	resp, err := http.Get(path)
+	if err != nil {
+		return err
+	}
+	defer resp.Body.Close()
+
+	bodyBytes, err := io.ReadAll(resp.Body)
+
+	content := string(bodyBytes)
+	//以字串过滤所有url到本地
+	if strings.Contains(content, "https://4dkk.4dage.com/720yun_fd_manage/") {
+		content = strings.ReplaceAll(content, "https://4dkk.4dage.com/720yun_fd_manage/", "/data/")
+	}
+	if strings.Contains(content, "https://4dkk.4dage.com/scene_edit_data") {
+		content = strings.ReplaceAll(content, "https://4dkk.4dage.com/", "/data/")
+
+	}
+
+	filterContent, _ := json.Marshal(content)
+
+	fmt.Println("data json:", string(filterContent))
+
+	buf := &bytes.Buffer{}
+	//err = json.NewEncoder(buf).Encode(&filterContent)
+	////err = json.NewDecoder(buf).Decode(&filterContent)
+	//if err != nil {
+	//	return err
+	//}
+	enc := gob.NewEncoder(buf)
+	err = enc.Encode(content)
+	if err != nil {
+		return err
+	}
+	// Writer the body to file
+	_, err = io.Copy(out, buf)
+
+	if err != nil {
+		return err
+	}
+
+	return nil
+
+}

+ 345 - 0
utils/somedataType.go

@@ -0,0 +1,345 @@
+package utils
+
+import "encoding/json"
+
+type ScenesDataType struct {
+	AppIcon         string `json:"appIcon"`
+	BackgroundMusic struct {
+		ID      string `json:"id"`
+		Name    string `json:"name"`
+		OssPath string `json:"ossPath"`
+	} `json:"backgroundMusic"`
+	CatalogRoot []struct {
+		Children []any  `json:"children"`
+		ID       string `json:"id"`
+		Name     string `json:"name"`
+	} `json:"catalogRoot"`
+	Catalogs []struct {
+		ID   string `json:"id"`
+		Name string `json:"name"`
+	} `json:"catalogs"`
+	CoverInfo struct {
+		CoverImageInWay   int64  `json:"coverImageInWay"`
+		CoverImageOrder   string `json:"coverImageOrder"`
+		CoverImgBac       string `json:"coverImgBac"`
+		CoverMoLoc        string `json:"coverMoLoc"`
+		CoverPcLoc        string `json:"coverPcLoc"`
+		CoverSelect       string `json:"coverSelect"`
+		CoverVideoBac     string `json:"coverVideoBac"`
+		CoverVideoControl int64  `json:"coverVideoControl"`
+		CoverVideoInWay   int64  `json:"coverVideoInWay"`
+		ImgColorSelec     string `json:"imgColorSelec"`
+		IsShowCover       int64  `json:"isShowCover"`
+		VideoColorSelec   string `json:"videoColorSelec"`
+		VideoMo           string `json:"videoMo"`
+		VideoMoIcon       string `json:"videoMoIcon"`
+		VideoMoLoc        string `json:"videoMoLoc"`
+		VideoPc           string `json:"videoPc"`
+		VideoPcIcon       string `json:"videoPcIcon"`
+		VideoPcLoc        string `json:"videoPcLoc"`
+	} `json:"coverInfo"`
+	CoverMo      string `json:"coverMo"`
+	CoverPc      string `json:"coverPc"`
+	CoverPcLoc   string `json:"coverPcLoc"`
+	CoverSelect  string `json:"coverSelect"`
+	CreateTime   string `json:"createTime"`
+	CustomButton []struct {
+		IsShow     bool   `json:"isShow"`
+		Name       string `json:"name"`
+		OpenMethod string `json:"openMethod"`
+		Type       string `json:"type"`
+		Value      string `json:"value"`
+	} `json:"customButton"`
+	Description string `json:"description"`
+	Explanation struct {
+		AudioID       string `json:"audioId"`
+		AudioName     string `json:"audioName"`
+		AudioURL      string `json:"audioUrl"`
+		OpenByDefault bool   `json:"openByDefault"`
+		Repeat        bool   `json:"repeat"`
+	} `json:"explanation"`
+	FirstScene struct {
+		Category   int64 `json:"category"`
+		CustomMask struct {
+			Earth struct {
+				Antidistorted bool   `json:"antidistorted"`
+				FodderID      string `json:"fodderId"`
+				Icon          string `json:"icon"`
+				IsShow        bool   `json:"isShow"`
+				Scale         int64  `json:"scale"`
+			} `json:"earth"`
+			Sky struct {
+				Antidistorted bool   `json:"antidistorted"`
+				FodderID      string `json:"fodderId"`
+				Icon          string `json:"icon"`
+				IsShow        bool   `json:"isShow"`
+				Scale         int64  `json:"scale"`
+			} `json:"sky"`
+		} `json:"customMask"`
+		Icon       string `json:"icon"`
+		ID         string `json:"id"`
+		InitVisual struct {
+			Hlookat float64 `json:"hlookat"`
+			Vlookat float64 `json:"vlookat"`
+		} `json:"initVisual"`
+		MaterialType string `json:"materialType"`
+		SceneCode    string `json:"sceneCode"`
+		SceneTitle   string `json:"sceneTitle"`
+		SomeData     struct {
+			Hotspots []struct {
+				ArticleInfo struct {
+					HTML string `json:"html"`
+				} `json:"articleInfo"`
+				Ath            interface{} `json:"ath"`
+				Atv            interface{} `json:"atv"`
+				Audio          string      `json:"audio"`
+				CustomIconInfo struct {
+					Img string `json:"img"`
+				} `json:"customIconInfo"`
+				FodderID        []interface{} `json:"fodderId"`
+				FontSize        int64         `json:"fontSize"`
+				HotspotIconType string        `json:"hotspotIconType"`
+				HotspotTitle    string        `json:"hotspotTitle"`
+				HotspotType     string        `json:"hotspotType"`
+				Hyperlink       string        `json:"hyperlink"`
+				Icontype        string        `json:"icontype"`
+				Image           []interface{} `json:"image"`
+				ImageTextInfo   struct {
+					Audio        struct{}      `json:"audio"`
+					ImageList    []interface{} `json:"imageList"`
+					IsApplyToAll bool          `json:"isApplyToAll"`
+					Text         string        `json:"text"`
+				} `json:"imageTextInfo"`
+				Img     string `json:"img"`
+				Link    string `json:"link"`
+				Name    string `json:"name"`
+				PdfInfo struct {
+					Name string `json:"name"`
+					URL  string `json:"url"`
+				} `json:"pdfInfo"`
+				PersonalizedTagInfo struct {
+					BorderColor    string `json:"borderColor"`
+					FillColor      string `json:"fillColor"`
+					IsShowLine     bool   `json:"isShowLine"`
+					IsTextWrap     bool   `json:"isTextWrap"`
+					LineDirection  string `json:"lineDirection"`
+					TextColor      string `json:"textColor"`
+					TextDirection  string `json:"textDirection"`
+					TextNumPerLine int64  `json:"textNumPerLine"`
+				} `json:"personalizedTagInfo"`
+				PhoneInfo struct {
+					Phone string `json:"phone"`
+				} `json:"phoneInfo"`
+				Secne struct {
+					Category   string `json:"category"`
+					CustomMask struct {
+						Earth struct {
+							Antidistorted bool   `json:"antidistorted"`
+							FodderID      string `json:"fodderId"`
+							Icon          string `json:"icon"`
+							IsShow        bool   `json:"isShow"`
+							Scale         int64  `json:"scale"`
+						} `json:"earth"`
+						Sky struct {
+							Antidistorted bool   `json:"antidistorted"`
+							FodderID      string `json:"fodderId"`
+							Icon          string `json:"icon"`
+							IsShow        bool   `json:"isShow"`
+							Scale         int64  `json:"scale"`
+						} `json:"sky"`
+					} `json:"customMask"`
+					Icon       string `json:"icon"`
+					ID         string `json:"id"`
+					InitVisual struct {
+						Hlookat    float64 `json:"hlookat"`
+						Vlookat    float64 `json:"vlookat"`
+						Vlookatmax float64 `json:"vlookatmax"`
+						Vlookatmin float64 `json:"vlookatmin"`
+					} `json:"initVisual"`
+					MaterialType string   `json:"materialType"`
+					SceneCode    string   `json:"sceneCode"`
+					SceneTitle   string   `json:"sceneTitle"`
+					SomeData     struct{} `json:"someData"`
+					Type         string   `json:"type"`
+					Version      string   `json:"version"`
+				} `json:"secne"`
+				SerialFrameInfo struct {
+					Duration    int64  `json:"duration"`
+					FrameNumber int64  `json:"frameNumber"`
+					Img         string `json:"img"`
+				} `json:"serialFrameInfo"`
+				Size             json.Number `json:"size"`
+				Textarea         string      `json:"textarea"`
+				TitleDisplayMode string      `json:"titleDisplayMode"`
+				TitlePosition    string      `json:"titlePosition"`
+				Type             string      `json:"type"`
+				Video            string      `json:"video"`
+			} `json:"hotspots"`
+		} `json:"someData"`
+		Type string `json:"type"`
+	} `json:"firstScene"`
+	Icon                   string `json:"icon"`
+	ID                     string `json:"id"`
+	IsAuto                 int64  `json:"isAuto"`
+	IsLogo                 int64  `json:"isLogo"`
+	IsPassword             int64  `json:"isPassword"`
+	IsRemind               int64  `json:"isRemind"`
+	IsShowOpeningAnimation bool   `json:"isShowOpeningAnimation"`
+	Logo                   string `json:"logo"`
+	LogoChange             bool   `json:"logoChange"`
+	Name                   string `json:"name"`
+	OpeningAnimationType   int64  `json:"openingAnimationType"`
+	OssSomeData            string `json:"ossSomeData"`
+	Password               string `json:"password"`
+	PcIcon                 string `json:"pcIcon"`
+	QrCode                 string `json:"qrCode"`
+	RemindTime             int64  `json:"remindTime"`
+	SceneIndex             string `json:"sceneIndex"`
+	Scenes                 []struct {
+		Category   string `json:"category"`
+		CustomMask struct {
+			Earth struct {
+				Antidistorted bool   `json:"antidistorted"`
+				FodderID      string `json:"fodderId"`
+				Icon          string `json:"icon"`
+				IsShow        bool   `json:"isShow"`
+				Scale         int64  `json:"scale"`
+			} `json:"earth"`
+			Sky struct {
+				Antidistorted bool   `json:"antidistorted"`
+				FodderID      string `json:"fodderId"`
+				Icon          string `json:"icon"`
+				IsShow        bool   `json:"isShow"`
+				Scale         int64  `json:"scale"`
+			} `json:"sky"`
+		} `json:"customMask"`
+		Icon       string `json:"icon"`
+		ID         string `json:"id"`
+		InitVisual struct {
+			Hlookat    float64 `json:"hlookat"`
+			Vlookat    float64 `json:"vlookat"`
+			Vlookatmax int64   `json:"vlookatmax"`
+			Vlookatmin int64   `json:"vlookatmin"`
+		} `json:"initVisual"`
+		MaterialType string `json:"materialType"`
+		SceneCode    string `json:"sceneCode"`
+		SceneTitle   string `json:"sceneTitle"`
+		SomeData     struct {
+			Hotspots []struct {
+				ArticleInfo struct {
+					HTML string `json:"html"`
+				} `json:"articleInfo"`
+				Ath            interface{} `json:"ath"`
+				Atv            interface{} `json:"atv"`
+				Audio          string      `json:"audio"`
+				CustomIconInfo struct {
+					Img string `json:"img"`
+				} `json:"customIconInfo"`
+				FodderID        []int64       `json:"fodderId"`
+				FontSize        int64         `json:"fontSize"`
+				HotspotIconType string        `json:"hotspotIconType"`
+				HotspotTitle    string        `json:"hotspotTitle"`
+				HotspotType     string        `json:"hotspotType"`
+				Hyperlink       string        `json:"hyperlink"`
+				Icontype        string        `json:"icontype"`
+				Image           []interface{} `json:"image"`
+				ImageTextInfo   struct {
+					Audio     struct{} `json:"audio"`
+					ImageList []struct {
+						Ancestors    string `json:"ancestors"`
+						CreateTime   string `json:"createTime"`
+						DirID        int64  `json:"dirId"`
+						DirName      string `json:"dirName"`
+						Dpi          string `json:"dpi"`
+						FileName     string `json:"fileName"`
+						FileSize     string `json:"fileSize"`
+						Icon         string `json:"icon"`
+						ID           int64  `json:"id"`
+						MaterialType string `json:"materialType"`
+						Name         string `json:"name"`
+						OssPath      string `json:"ossPath"`
+						PreviewIcon  string `json:"previewIcon"`
+						SceneCode    string `json:"sceneCode"`
+						Status       int64  `json:"status"`
+						TempID       string `json:"tempId"`
+						Type         string `json:"type"`
+						UpdateTime   string `json:"updateTime"`
+						UserID       string `json:"userId"`
+					} `json:"imageList"`
+					IsApplyToAll bool   `json:"isApplyToAll"`
+					Text         string `json:"text"`
+				} `json:"imageTextInfo"`
+				Img     string `json:"img"`
+				Link    string `json:"link"`
+				Name    string `json:"name"`
+				PdfInfo struct {
+					Name string `json:"name"`
+					URL  string `json:"url"`
+				} `json:"pdfInfo"`
+				PersonalizedTagInfo struct {
+					BorderColor    string `json:"borderColor"`
+					FillColor      string `json:"fillColor"`
+					IsShowLine     bool   `json:"isShowLine"`
+					IsTextWrap     bool   `json:"isTextWrap"`
+					LineDirection  string `json:"lineDirection"`
+					TextColor      string `json:"textColor"`
+					TextDirection  string `json:"textDirection"`
+					TextNumPerLine int64  `json:"textNumPerLine"`
+				} `json:"personalizedTagInfo"`
+				PhoneInfo struct {
+					Phone string `json:"phone"`
+				} `json:"phoneInfo"`
+				Secne struct {
+					Category   string `json:"category"`
+					CustomMask struct {
+						Earth struct {
+							Antidistorted bool   `json:"antidistorted"`
+							FodderID      string `json:"fodderId"`
+							Icon          string `json:"icon"`
+							IsShow        bool   `json:"isShow"`
+							Scale         int64  `json:"scale"`
+						} `json:"earth"`
+						Sky struct {
+							Antidistorted bool   `json:"antidistorted"`
+							FodderID      string `json:"fodderId"`
+							Icon          string `json:"icon"`
+							IsShow        bool   `json:"isShow"`
+							Scale         int64  `json:"scale"`
+						} `json:"sky"`
+					} `json:"customMask"`
+					Icon       string `json:"icon"`
+					ID         string `json:"id"`
+					InitVisual struct {
+						Hlookat    float64 `json:"hlookat"`
+						Vlookat    float64 `json:"vlookat"`
+						Vlookatmax float64 `json:"vlookatmax"`
+						Vlookatmin float64 `json:"vlookatmin"`
+					} `json:"initVisual"`
+					MaterialType string   `json:"materialType"`
+					SceneCode    string   `json:"sceneCode"`
+					SceneTitle   string   `json:"sceneTitle"`
+					SomeData     struct{} `json:"someData"`
+					Type         string   `json:"type"`
+					Version      string   `json:"version"`
+				} `json:"secne"`
+				SerialFrameInfo struct {
+					Duration    int64  `json:"duration"`
+					FrameNumber int64  `json:"frameNumber"`
+					Img         string `json:"img"`
+				} `json:"serialFrameInfo"`
+				Size             json.Number `json:"size"`
+				Textarea         string      `json:"textarea"`
+				TitleDisplayMode string      `json:"titleDisplayMode"`
+				TitlePosition    string      `json:"titlePosition"`
+				Type             string      `json:"type"`
+				Video            string      `json:"video"`
+			} `json:"hotspots"`
+		} `json:"someData"`
+		Type    string `json:"type"`
+		Version string `json:"version"`
+	} `json:"scenes"`
+	Share      string `json:"share"`
+	Status     int64  `json:"status"`
+	UpdateTime string `json:"updateTime"`
+	UserID     string `json:"userId"`
+}