Skip to content

Commit

Permalink
基本功能实现
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangyiming748 committed Dec 28, 2023
1 parent 742e8e5 commit c52f320
Show file tree
Hide file tree
Showing 23 changed files with 939 additions and 323 deletions.
Empty file added .github/RELEASE-TEMPLATE.md
Empty file.
41 changes: 41 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
#on:
# push:
# branches: [ "master" ]
# pull_request:
# branches: [ "master" ]
name: Latest Release

jobs:
build:
name: GoReleaser build
runs-on: ubuntu-latest

steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v2
with:
fetch-depth: 0 # See: https://goreleaser.com/ci/actions/

- name: Set up Go 1.21.4
uses: actions/setup-go@v2
with:
go-version: 1.21.4
id: go

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
version: latest
args: release --clean
# env:
# GITHUB_TOKEN: ${{ secrets.GO_RELEASER_GITHUB_TOKEN }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46 changes: 5 additions & 41 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,45 +1,9 @@
vendor
test
downloads
.idea
done
/BS4/PHUB/data/
/BS4/XM/data/
GB/
testfile
.fleet
report.md
Solution.sh
__pycache__
users.txt
.DS_Store
vendor
*.mp4
*.m4s
entry.json
*.log
*.zip
*.rpm
*.deb
*.blockmap
*.exe
*.jpg
*.png
*.mp3
*.amr
*.html
.DS_Store
#忽略产生的中间文件
info.txt
list.txt
build
dist
AVMerger4Win64.exe
AVMerger4Win32.exe
AVMerger4Raspi
AVMerger4Mac
AVMerger4M1
AVMerger4Linux32
AVMerger4Linux64
AVMerger4Android
AVMerger4Raspi64
*.json
*.xml
*.m4s
report.txt
*.db
7 changes: 7 additions & 0 deletions conf.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[merge]
;生成文件保存的位置
prefix = /mnt/d/git/AVmerger/downloads
;视频源文件目录
src = /mnt/d/git/AVmerger/downloads
[log]
level = Debug
46 changes: 46 additions & 0 deletions example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"media_type": 2,
"has_dash_audio": true,
"is_completed": true,
"total_bytes": 47675288,
"downloaded_bytes": 47675288,
"title": "蜡笔小新【人物志】特殊的一期:春日部防卫队——最强战队",
"type_tag": "80",
"cover": "http:\/\/i0.hdslb.com\/bfs\/archive\/55b5d45ee6857820890e536e8823ead726bc0cbb.jpg",
"video_quality": 80,
"prefered_video_quality": 80,
"guessed_total_bytes": 0,
"total_time_milli": 1058550,
"danmaku_count": 387,
"time_update_stamp": 1702664375269,
"time_create_stamp": 1702664199018,
"can_play_in_advance": true,
"interrupt_transform_temp_file": false,
"quality_pithy_description": "1080P",
"quality_superscript": "",
"cache_version_code": 7590200,
"preferred_audio_quality": 0,
"audio_quality": 0,
"avid": 229337132,
"spid": 0,
"seasion_id": 0,
"bvid": "",
"owner_id": 630727239,
"owner_name": "茂人小头头",
"page_data": {
"cid": 1148286376,
"page": 1,
"from": "vupload",
"part": "盘点《蜡笔小新》最强组织的发展史!永远的春日部防卫队!永远的友谊!",
"link": "",
"rich_vid": "",
"vid": "",
"has_alias": false,
"tid": 253,
"width": 1920,
"height": 1080,
"rotate": 0,
"download_title": "",
"download_subtitle": ""
}
}
17 changes: 14 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
module github.com/zhangyiming748/AVmerger

go 1.19
go 1.21

require (
github.com/zhangyiming748/replace v0.0.8
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1
github.com/klauspost/cpuid/v2 v2.2.6
github.com/zhangyiming748/GetFileInfo v0.0.39
gorm.io/driver/sqlite v1.5.4
gorm.io/gorm v1.25.5
)

require (
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/mattn/go-sqlite3 v1.14.19 // indirect
github.com/zhangyiming748/GetAllFolder v0.0.20 // indirect
github.com/zhangyiming748/filetype v0.0.1 // indirect
golang.org/x/sys v0.5.0 // indirect
)
24 changes: 20 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,20 @@
github.com/zhangyiming748/replace v0.0.8 h1:MeFF+j0tq5Yy/u8VjjH5g2dxd5EOsFxSyckbZsnvbaQ=
github.com/zhangyiming748/replace v0.0.8/go.mod h1:R3otYn+0qxaHOVaz0LafMwoDjhTexJijrLgfcDyOYCQ=
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1 h1:k/i9J1pBpvlfR+9QsetwPyERsqu1GIbi967PQMq3Ivc=
golang.org/x/exp v0.0.0-20230522175609-2e198f4a06a1/go.mod h1:V1LtkGg67GoY2N1AnLN78QLrzxkLyJw7RJb1gzOOz9w=
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
github.com/klauspost/cpuid/v2 v2.2.6 h1:ndNyv040zDGIDh8thGkXYjnFtiN02M1PVVF+JE/48xc=
github.com/klauspost/cpuid/v2 v2.2.6/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
github.com/mattn/go-sqlite3 v1.14.19 h1:fhGleo2h1p8tVChob4I9HpmVFIAkKGpiukdrgQbWfGI=
github.com/mattn/go-sqlite3 v1.14.19/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
github.com/zhangyiming748/GetAllFolder v0.0.20 h1:1HR+wKCP6lYIUXXpxcmp4ba1U8n6uz5QSTgvVVqZkEE=
github.com/zhangyiming748/GetAllFolder v0.0.20/go.mod h1:uhdqD8XPoOOVj9ywdbAh0CkGaM7kJpfQEiwPjk9NSD4=
github.com/zhangyiming748/GetFileInfo v0.0.39 h1:8JN5QC7dJGJ9QQUiGri7eo5c5FiwTg1wShtrSVkSDQE=
github.com/zhangyiming748/GetFileInfo v0.0.39/go.mod h1:D76EP151kuBY59SWz0nU3XdyDEPPUyFZxHq0cJCgvj8=
github.com/zhangyiming748/filetype v0.0.1 h1:C7a49LHKzqiYAiw/u2lTmPU6gP6Nwb6/sSDBmBMoJ/k=
github.com/zhangyiming748/filetype v0.0.1/go.mod h1:DFFw06VgsQVSriUKe95IC+HKaY4u6hCCbXJE1L1HNUk=
golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU=
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
gorm.io/driver/sqlite v1.5.4 h1:IqXwXi8M/ZlPzH/947tn5uik3aYQslP9BVveoax0nV0=
gorm.io/driver/sqlite v1.5.4/go.mod h1:qxAuCol+2r6PannQDpOP1FP6ag3mKi4esLnB/jHed+4=
gorm.io/gorm v1.25.5 h1:zR9lOiiYf09VNh5Q1gphfyia1JpiClIWG9hQaxB/mls=
gorm.io/gorm v1.25.5/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
86 changes: 86 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package main

import (
"fmt"
"github.com/zhangyiming748/AVmerger/merge"
"github.com/zhangyiming748/AVmerger/sql"
"github.com/zhangyiming748/AVmerger/util"
"io"
"log/slog"
"os"
)

func init() {
setLog()
sql.SetEngine()
}
func main() {
src := util.GetVal("merge", "src")
bilibilihd := "/sdcard/Android/data/tv.danmaku.bilibilihd"
bilibili := "/sdcard/Android/data/tv.danmaku.bili"
if existFolder(bilibilihd) {
src = bilibilihd
} else if existFolder(bilibili) {
src = bilibili
}
merge.Merge(src)
}

/*
设置程序运行的日志等级
*/
func setLog() {
var opt slog.HandlerOptions
level := util.GetVal("log", "level")
switch level {
case "Debug":
opt = slog.HandlerOptions{ // 自定义option
AddSource: true,
Level: slog.LevelDebug, // slog 默认日志级别是 info
}
case "Info":
opt = slog.HandlerOptions{ // 自定义option
AddSource: true,
Level: slog.LevelInfo, // slog 默认日志级别是 info
}
case "Warn":
opt = slog.HandlerOptions{ // 自定义option
AddSource: true,
Level: slog.LevelWarn, // slog 默认日志级别是 info
}
case "Err":
opt = slog.HandlerOptions{ // 自定义option
AddSource: true,
Level: slog.LevelError, // slog 默认日志级别是 info
}
default:
slog.Warn("需要正确设置环境变量 Debug,Info,Warn or Err")
slog.Debug("默认使用Debug等级")
opt = slog.HandlerOptions{ // 自定义option
AddSource: true,
Level: slog.LevelDebug, // slog 默认日志级别是 info
}
}
file := "AVmerge.log"
logf, err := os.OpenFile(file, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0770)
if err != nil {
panic(err)
}
logger := slog.New(slog.NewJSONHandler(io.MultiWriter(logf, os.Stdout), &opt))
slog.SetDefault(logger)
}

func existFolder(f string) bool {
_, err := os.Stat(f)

if os.IsNotExist(err) {
fmt.Println("文件夹不存在")
return false
} else if err == nil {
fmt.Println("文件夹存在")
return true
} else {
fmt.Println("发生错误:", err)
return false
}
}
Loading

0 comments on commit c52f320

Please sign in to comment.