First mvp ready
This commit is contained in:
parent
6edb6c0c77
commit
e84bc20086
@ -6,6 +6,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
_ "github.com/mattn/go-sqlite3"
|
_ "github.com/mattn/go-sqlite3"
|
||||||
"log"
|
"log"
|
||||||
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
@ -14,8 +15,14 @@ import (
|
|||||||
var embeddedMigrations embed.FS
|
var embeddedMigrations embed.FS
|
||||||
|
|
||||||
func openDatabase() *sql.DB {
|
func openDatabase() *sql.DB {
|
||||||
|
// Get database directory
|
||||||
|
databaseSource := os.Getenv("VIVAPLUS_DATABASE")
|
||||||
|
if databaseSource == "" {
|
||||||
|
databaseSource = "videos.db3"
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize the database connection
|
// Initialize the database connection
|
||||||
db, err := sql.Open("sqlite3", "videos.db3")
|
db, err := sql.Open("sqlite3", databaseSource)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("error opening database: %v", err)
|
log.Fatalf("error opening database: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ import (
|
|||||||
|
|
||||||
func DownloadAllVideos(db *sql.DB) error {
|
func DownloadAllVideos(db *sql.DB) error {
|
||||||
// Ensure no partial videos exist
|
// Ensure no partial videos exist
|
||||||
tempDir := os.Getenv("TMP_DOWNLOAD")
|
tempDir := os.Getenv("VIVAPLUS_DOWNLOAD")
|
||||||
if tempDir == "" {
|
if tempDir == "" {
|
||||||
tempDir = "./temp" // Replace with your desired default path
|
tempDir = "./temp" // Replace with your desired default path
|
||||||
}
|
}
|
||||||
@ -30,7 +30,7 @@ func DownloadAllVideos(db *sql.DB) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Find the target directory
|
// Find the target directory
|
||||||
downloadDir := os.Getenv("DESTINATION")
|
downloadDir := os.Getenv("VIVAPLUS_DESTINATION")
|
||||||
if downloadDir == "" {
|
if downloadDir == "" {
|
||||||
downloadDir = "./downloads"
|
downloadDir = "./downloads"
|
||||||
}
|
}
|
||||||
|
10
main.go
10
main.go
@ -37,12 +37,12 @@ func main() {
|
|||||||
log.Fatalf("error decoding password: %v", err)
|
log.Fatalf("error decoding password: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
for {
|
err = w.Login(username, string(password))
|
||||||
err = w.Login(username, string(password))
|
if err != nil {
|
||||||
if err != nil {
|
log.Fatalf("error login in: %v", err)
|
||||||
log.Fatalf("error login in: %v", err)
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
for {
|
||||||
err = w.DiscoverAllVideos(db)
|
err = w.DiscoverAllVideos(db)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user