mirror of
https://github.com/tgbot-collection/YYeTsBot.git
synced 2025-11-25 11:29:38 +08:00
auto download
This commit is contained in:
@@ -88,12 +88,9 @@ yyets_offline - 人人影视离线数据
|
||||
|
||||
这个版本使用起来也很简单,不过页面比较朴素(又不是不能用)。无依赖。步骤如下
|
||||
|
||||
1. 请到 [GitHub Release](https://github.com/tgbot-collection/YYeTsBot/releases) 根据自己平台下载一键运行包
|
||||
2. 请到 [database download](https://yyets.dmesg.app/database) 下载SQLite数据库,然后解压缩
|
||||
3. 把这两个文件放到同一个目录
|
||||
4. windows:双击第一步下载的文件; macos/Linux,cd到你的目录, `chmod +x yyetsweb ; ./yyetsweb`
|
||||
|
||||
打开浏览器 http://127.0.0.1:8888 就可以看到熟悉的搜索界面啦!
|
||||
1. 请到 [GitHub Release](https://github.com/tgbot-collection/YYeTsBot/releases) 根据自己平台下载最新的一键运行包
|
||||
2. windows:双击第一步下载的exe文件; macos/Linux,cd到你的目录, `chmod +x yyetsweb ; ./yyetsweb`
|
||||
3. 程序会自动下载数据库并启动。等到出现启动banner时, 打开浏览器 http://127.0.0.1:8888 就可以看到熟悉的搜索界面啦!
|
||||
|
||||
# 开发
|
||||
|
||||
|
||||
@@ -1,25 +1,31 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"archive/zip"
|
||||
"database/sql"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
_ "github.com/glebarez/go-sqlite"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const dbFile = "yyets_sqlite.db"
|
||||
|
||||
func main() {
|
||||
downloadDB()
|
||||
banner := `
|
||||
▌ ▌ ▌ ▌ ▀▛▘
|
||||
▝▞ ▝▞ ▞▀▖ ▌ ▞▀▘
|
||||
▌ ▌ ▛▀ ▌ ▝▀▖
|
||||
▘ ▘ ▝▀▘ ▘ ▀▀
|
||||
|
||||
Lazarus came back from the dead. By @Bennythink
|
||||
Lazarus came back from the dead. By @Bennythink
|
||||
http://127.0.0.1:8888/
|
||||
`
|
||||
r := gin.Default()
|
||||
r.GET("/api/resource", entrance)
|
||||
@@ -33,7 +39,6 @@ func main() {
|
||||
r.GET("/", bindataStaticHandler)
|
||||
|
||||
fmt.Printf(banner)
|
||||
|
||||
_ = r.Run("localhost:8888") // listen and serve on 0.0.0.0:8080 (for windows "localhost:8080")
|
||||
}
|
||||
|
||||
@@ -132,3 +137,31 @@ func entrance(c *gin.Context) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func downloadDB() {
|
||||
if _, err := os.Stat("yyets_sqlite.db"); err == nil {
|
||||
log.Println("File already exists")
|
||||
return
|
||||
}
|
||||
|
||||
log.Println("Downloading database file...")
|
||||
var downloadUrl = "https://yyets.dmesg.app/dump/yyets_sqlite.zip"
|
||||
resp, _ := http.Get(downloadUrl)
|
||||
file, _ := os.Create("yyets_sqlite.zip")
|
||||
_, _ = io.Copy(file, resp.Body)
|
||||
_ = resp.Body.Close()
|
||||
_ = file.Close()
|
||||
|
||||
log.Println("Download complete, extracting...")
|
||||
archive, _ := zip.OpenReader("yyets_sqlite.zip")
|
||||
for _, f := range archive.File {
|
||||
dstFile, _ := os.OpenFile(f.Name, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, f.Mode())
|
||||
fileInArchive, _ := f.Open()
|
||||
_, _ = io.Copy(dstFile, fileInArchive)
|
||||
_ = dstFile.Close()
|
||||
_ = fileInArchive.Close()
|
||||
}
|
||||
|
||||
log.Println("Extraction complete, cleaning up...")
|
||||
_ = os.Remove("yyets_sqlite.zip")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user