68 lines
2.1 KiB
Go
68 lines
2.1 KiB
Go
package main
|
|
|
|
import (
|
|
"database/sql"
|
|
"federated.computer/wp-sync-slowtwitch/services/migration"
|
|
"federated.computer/wp-sync-slowtwitch/services/slowtwitch"
|
|
"fmt"
|
|
)
|
|
|
|
const baseUrl = "https://slowtwitch.cloud/"
|
|
const wordpressKey = "admin@slowtwitch.cloud"
|
|
const wordpressSecret = "6zY7 xsKZ dGIt l1Lp ypIK 6TWh"
|
|
|
|
const slowtwitchAdminUser = "admin"
|
|
const slowtwitchAdminPass = "yxnh93Ybbz2Nm8#mp28zCVv"
|
|
const slowtwitchDbName = "slowtwitch"
|
|
const migrationDbName = "slowtwitch_transfer"
|
|
const federatedDbUrl = "slowtwitch.northend.network"
|
|
const federatedDbPort = "3306"
|
|
|
|
var appCache AppCache
|
|
var slowtwitchDB *sql.DB
|
|
var resultsDB *sql.DB
|
|
|
|
func main() {
|
|
//Connect to databases
|
|
slowtwitchDatabase, slowtwitchDbErr := migration.Connect(slowtwitchAdminUser, slowtwitchAdminPass, federatedDbUrl, federatedDbPort, slowtwitchDbName+"?parseTime=true")
|
|
if slowtwitchDbErr != nil {
|
|
panic("Could not connect to slowtwitch database.")
|
|
} else {
|
|
slowtwitchDB = slowtwitchDatabase
|
|
}
|
|
resultsDatabase, resultsDBerr := migration.Connect(slowtwitchAdminUser, slowtwitchAdminPass, federatedDbUrl, federatedDbPort, migrationDbName)
|
|
if resultsDBerr != nil {
|
|
panic("Could not connect to results database.")
|
|
} else {
|
|
resultsDB = resultsDatabase
|
|
}
|
|
|
|
// 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")
|
|
if err != nil {
|
|
fmt.Println(err)
|
|
}
|
|
for i, imageUrl := range imageUrls {
|
|
fmt.Println(i, imageUrl)
|
|
}
|
|
fmt.Println(html)
|
|
//EXPERIMENT END
|
|
editorMigration := migration.MigrateAuthors{
|
|
SlowtwitchDatabase: slowtwitchDB,
|
|
ResultsDatabase: resultsDB,
|
|
WordpressBaseUrl: baseUrl,
|
|
WordpressUser: wordpressKey,
|
|
WordpressPassword: wordpressSecret,
|
|
}
|
|
editorMigration.Execute()
|
|
categoryMigration := migration.MigrateCategories{
|
|
SlowtwitchDatabase: slowtwitchDB,
|
|
ResultsDatabase: resultsDB,
|
|
WordpressBaseUrl: baseUrl,
|
|
WordpressUser: wordpressKey,
|
|
WordpressPassword: wordpressSecret,
|
|
}
|
|
categoryMigration.Execute()
|
|
}
|