2024-05-07 22:03:15 +00:00
|
|
|
package main
|
|
|
|
|
2024-05-10 20:01:05 +00:00
|
|
|
import (
|
2024-05-19 21:00:33 +00:00
|
|
|
"database/sql"
|
2024-05-16 16:26:59 +00:00
|
|
|
"federated.computer/wp-sync-slowtwitch/services/migration"
|
2024-05-17 18:49:55 +00:00
|
|
|
"federated.computer/wp-sync-slowtwitch/services/slowtwitch"
|
2024-05-10 20:01:05 +00:00
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
2024-05-16 18:50:53 +00:00
|
|
|
const baseUrl = "https://slowtwitch.cloud/"
|
2024-05-16 16:26:59 +00:00
|
|
|
const wordpressKey = "admin@slowtwitch.cloud"
|
|
|
|
const wordpressSecret = "6zY7 xsKZ dGIt l1Lp ypIK 6TWh"
|
2024-05-07 22:03:15 +00:00
|
|
|
|
2024-05-14 21:59:04 +00:00
|
|
|
const slowtwitchAdminUser = "admin"
|
|
|
|
const slowtwitchAdminPass = "yxnh93Ybbz2Nm8#mp28zCVv"
|
|
|
|
const slowtwitchDbName = "slowtwitch"
|
2024-05-15 23:37:42 +00:00
|
|
|
const migrationDbName = "slowtwitch_transfer"
|
|
|
|
const federatedDbUrl = "slowtwitch.northend.network"
|
|
|
|
const federatedDbPort = "3306"
|
2024-05-14 21:59:04 +00:00
|
|
|
|
2024-05-07 22:03:15 +00:00
|
|
|
var appCache AppCache
|
2024-05-19 21:00:33 +00:00
|
|
|
var slowtwitchDB *sql.DB
|
|
|
|
var resultsDB *sql.DB
|
2024-05-07 22:03:15 +00:00
|
|
|
|
|
|
|
func main() {
|
2024-05-19 21:00:33 +00:00
|
|
|
//Connect to databases
|
|
|
|
slowtwitchDatabase, slowtwitchDbErr := migration.Connect(slowtwitchAdminUser, slowtwitchAdminPass, federatedDbUrl, federatedDbPort, slowtwitchDbName+"?parseTime=true")
|
2024-05-16 16:26:59 +00:00
|
|
|
if slowtwitchDbErr != nil {
|
2024-05-19 21:00:33 +00:00
|
|
|
panic("Could not connect to slowtwitch database.")
|
|
|
|
} else {
|
|
|
|
slowtwitchDB = slowtwitchDatabase
|
2024-05-16 16:26:59 +00:00
|
|
|
}
|
2024-05-19 21:00:33 +00:00
|
|
|
resultsDatabase, resultsDBerr := migration.Connect(slowtwitchAdminUser, slowtwitchAdminPass, federatedDbUrl, federatedDbPort, migrationDbName)
|
2024-05-16 16:26:59 +00:00
|
|
|
if resultsDBerr != nil {
|
2024-05-19 21:00:33 +00:00
|
|
|
panic("Could not connect to results database.")
|
|
|
|
} else {
|
|
|
|
resultsDB = resultsDatabase
|
2024-05-17 18:49:55 +00:00
|
|
|
}
|
2024-05-17 19:52:38 +00:00
|
|
|
|
2024-05-19 21:00:33 +00:00
|
|
|
// TODO Article migration
|
|
|
|
//EXPERIMENT AREA START
|
|
|
|
imageUrls, html, err := slowtwitch.GetImagesAndPostHtml("https://www.slowtwitch.com/Products/Components/SRAM_Drops_New_RED_AXS_Groupset_8950.html")
|
2024-05-17 18:49:55 +00:00
|
|
|
if err != nil {
|
2024-05-17 19:52:38 +00:00
|
|
|
fmt.Println(err)
|
2024-05-17 18:49:55 +00:00
|
|
|
}
|
2024-05-19 21:00:33 +00:00
|
|
|
for i, imageUrl := range imageUrls {
|
|
|
|
fmt.Println(i, imageUrl)
|
|
|
|
}
|
|
|
|
fmt.Println(html)
|
2024-05-17 18:49:55 +00:00
|
|
|
//EXPERIMENT END
|
2024-05-16 19:48:39 +00:00
|
|
|
editorMigration := migration.MigrateAuthors{
|
|
|
|
SlowtwitchDatabase: slowtwitchDB,
|
|
|
|
ResultsDatabase: resultsDB,
|
|
|
|
WordpressBaseUrl: baseUrl,
|
|
|
|
WordpressUser: wordpressKey,
|
|
|
|
WordpressPassword: wordpressSecret,
|
|
|
|
}
|
|
|
|
editorMigration.Execute()
|
2024-05-16 16:26:59 +00:00
|
|
|
categoryMigration := migration.MigrateCategories{
|
|
|
|
SlowtwitchDatabase: slowtwitchDB,
|
|
|
|
ResultsDatabase: resultsDB,
|
|
|
|
WordpressBaseUrl: baseUrl,
|
|
|
|
WordpressUser: wordpressKey,
|
|
|
|
WordpressPassword: wordpressSecret,
|
2024-05-14 21:59:04 +00:00
|
|
|
}
|
2024-05-16 16:26:59 +00:00
|
|
|
categoryMigration.Execute()
|
2024-05-10 20:01:05 +00:00
|
|
|
}
|