First mvp ready

This commit is contained in:
Sebastiaan de Schaetzen 2025-02-06 17:07:57 +01:00
parent 6edb6c0c77
commit e84bc20086
3 changed files with 15 additions and 8 deletions

View File

@ -6,6 +6,7 @@ import (
"fmt"
_ "github.com/mattn/go-sqlite3"
"log"
"os"
"strconv"
"strings"
)
@ -14,8 +15,14 @@ import (
var embeddedMigrations embed.FS
func openDatabase() *sql.DB {
// Get database directory
databaseSource := os.Getenv("VIVAPLUS_DATABASE")
if databaseSource == "" {
databaseSource = "videos.db3"
}
// Initialize the database connection
db, err := sql.Open("sqlite3", "videos.db3")
db, err := sql.Open("sqlite3", databaseSource)
if err != nil {
log.Fatalf("error opening database: %v", err)
}

View File

@ -16,7 +16,7 @@ import (
func DownloadAllVideos(db *sql.DB) error {
// Ensure no partial videos exist
tempDir := os.Getenv("TMP_DOWNLOAD")
tempDir := os.Getenv("VIVAPLUS_DOWNLOAD")
if tempDir == "" {
tempDir = "./temp" // Replace with your desired default path
}
@ -30,7 +30,7 @@ func DownloadAllVideos(db *sql.DB) error {
}
// Find the target directory
downloadDir := os.Getenv("DESTINATION")
downloadDir := os.Getenv("VIVAPLUS_DESTINATION")
if downloadDir == "" {
downloadDir = "./downloads"
}

10
main.go
View File

@ -37,12 +37,12 @@ func main() {
log.Fatalf("error decoding password: %v", err)
}
for {
err = w.Login(username, string(password))
if err != nil {
log.Fatalf("error login in: %v", err)
}
err = w.Login(username, string(password))
if err != nil {
log.Fatalf("error login in: %v", err)
}
for {
err = w.DiscoverAllVideos(db)
if err != nil {
panic(err)