First mvp ready
This commit is contained in:
parent
6edb6c0c77
commit
e84bc20086
@ -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)
|
||||
}
|
||||
|
@ -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
10
main.go
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user