Add main business logic of this program
Now we can download torrents like old Python version does.
This commit is contained in:
@@ -15,12 +15,16 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
c *context.Context
|
||||
dclient http.Client
|
||||
dlog zerolog.Logger
|
||||
forumPages map[int]*goquery.Document
|
||||
forumPagesLinks map[string]string
|
||||
uberDebug bool
|
||||
c *context.Context
|
||||
dclient http.Client
|
||||
dlog zerolog.Logger
|
||||
forumPages map[int]*goquery.Document
|
||||
forumPagesLinks map[string]string
|
||||
forumTopics map[int]*forumTopic
|
||||
forumTopicInProgress int
|
||||
outputDirPath string
|
||||
totalLength int64
|
||||
uberDebug bool
|
||||
)
|
||||
|
||||
// New initializes package
|
||||
@@ -42,8 +46,16 @@ func New(cc *context.Context) {
|
||||
DefaultValue: false,
|
||||
})
|
||||
|
||||
_ = c.Flagger.AddFlag(&flagger.Flag{
|
||||
Name: "outputDir",
|
||||
Description: "Директория, в которую будут помещены скачанные торрент-файлы",
|
||||
Type: "string",
|
||||
DefaultValue: "./",
|
||||
})
|
||||
|
||||
forumPages = make(map[int]*goquery.Document)
|
||||
forumPagesLinks = make(map[string]string)
|
||||
forumTopics = make(map[int]*forumTopic)
|
||||
|
||||
dlog.Info().Msg("Модуль инициализирован")
|
||||
}
|
||||
@@ -55,8 +67,11 @@ func Process() {
|
||||
if forumID == 0 {
|
||||
dlog.Fatal().Msg("Номер форума не указан. Используйте ключ -forum XXX, чтобы указать номер форума")
|
||||
}
|
||||
outputDirPathPrefix, _ := c.Flagger.GetStringValue("outputDir")
|
||||
|
||||
dlog.Info().Int("forum ID", forumID).Msg("Получен ID форума, начинаем работу...")
|
||||
|
||||
createOutputDir(outputDirPathPrefix, forumID)
|
||||
fetch(forumID)
|
||||
printStats()
|
||||
}
|
||||
|
Reference in New Issue
Block a user