diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
new file mode 100644
index 0000000..e9d7e83
--- /dev/null
+++ b/CODE_OF_CONDUCT.md
@@ -0,0 +1,3 @@
+# Code of Conduct
+
+We adhere to the [Go Community Code of Conduct](https://go.dev/conduct).
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index a8b2427..05a693f 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -31,3 +31,7 @@ Contributions are always welcome and appreciated.
## Miscellaneous
- Run `make help` to see all available commands to manage different tasks.
+
+## Code of Conduct
+
+We adhere to the [Go Community Code of Conduct](https://go.dev/conduct).
diff --git a/README.md b/README.md
index a95f072..1f56b3d 100644
--- a/README.md
+++ b/README.md
@@ -24,9 +24,6 @@
-
-
-
@@ -67,6 +64,7 @@ Additionally, it allows users to perform the following actions:
- Download files using multiple threads to speed up the process
- Resume interrupted downloads and only download missing or newer files
- Verify the integrity of downloaded files by calculating their hashes
+- Calculate the total size of the files to be downloaded (for storage planning)
## Getting Started
@@ -76,7 +74,7 @@ Run `gogg -h` to see the available commands and options.
### Examples
-For more detailed examples, see the content of the [examples](docs/examples/) directory.
+**For more detailed examples, see the content of the [examples](docs/examples/) directory.**
#### Login to GOG
@@ -119,6 +117,14 @@ gogg download 1207658924 ./games --platform=windows --lang=en --dlcs=true --extr
gogg file hash ./games/the-witcher-enhanced-edition --algo=sha1
```
+#### Storage Size Calculation
+
+```bash
+# Will show the total size of the files to be downloaded for `The Witcher: Enhanced Edition`
+DEBUG_GOGG=false gogg file size 1207658924 --platform=windows --lang=en --dlcs=true \
+ --extras=false --unit=GB
+```
+
## Demo
[](https://asciinema.org/a/kXMGRUUV149R37IEmZKtTH7nI)
diff --git a/client/login.go b/client/login.go
index 3aaca63..ecb9ba6 100644
--- a/client/login.go
+++ b/client/login.go
@@ -11,7 +11,6 @@ import (
"io"
"net/http"
"net/url"
- "os"
"os/exec"
"strings"
"time"
@@ -71,11 +70,10 @@ func Login(loginURL string, username string, password string, headless bool) err
}
// Print the access token, refresh token, and expiration if debug mode is enabled
- if os.Getenv("DEBUG_GOGG") != "" {
- log.Info().Msgf("Access token: %s", token[:10])
- log.Info().Msgf("Refresh token: %s", refreshToken[:10])
- log.Info().Msgf("Expires at: %s", expiresAt)
- }
+
+ log.Info().Msgf("Access token: %s", token[:10])
+ log.Info().Msgf("Refresh token: %s", refreshToken[:10])
+ log.Info().Msgf("Expires at: %s", expiresAt)
// Save the token record in the database
return db.UpsertTokenRecord(&db.Token{AccessToken: token, RefreshToken: refreshToken, ExpiresAt: expiresAt})
diff --git a/cmd/download.go b/cmd/download.go
index 9a45071..032337b 100644
--- a/cmd/download.go
+++ b/cmd/download.go
@@ -9,23 +9,9 @@ import (
"os"
"path/filepath"
"strconv"
+ "strings"
)
-// Map of supported game languages and their native names
-var gameLanguages = map[string]string{
- "en": "English",
- "fr": "Français", // French
- "de": "Deutsch", // German
- "es": "Español", // Spanish
- "it": "Italiano", // Italian
- "ru": "Русский", // Russian
- "pl": "Polski", // Polish
- "pt-BR": "Português do Brasil", // Portuguese (Brazil)
- "zh-Hans": "简体中文", // Simplified Chinese
- "ja": "日本語", // Japanese
- "ko": "한국어", // Korean
-}
-
// downloadCmd creates a new cobra.Command for downloading a selected game from GOG.
// It returns a pointer to the created cobra.Command.
func downloadCmd() *cobra.Command {
@@ -49,7 +35,8 @@ func downloadCmd() *cobra.Command {
return
}
downloadDir := args[1]
- executeDownload(gameID, downloadDir, language, platformName, extrasFlag, dlcFlag, resumeFlag, flattenFlag, numThreads)
+ executeDownload(gameID, downloadDir, strings.ToLower(language), platformName, extrasFlag, dlcFlag,
+ resumeFlag, flattenFlag, numThreads)
},
}
@@ -78,6 +65,17 @@ func executeDownload(gameID int, downloadPath, language, platformName string, ex
return
}
+ // Check if the language is valid
+ if !isValidLanguage(language) {
+ fmt.Println("Invalid language code. Supported languages are:")
+ for langCode, langName := range gameLanguages {
+ fmt.Printf("'%s' for %s\n", langCode, langName)
+ }
+ return
+ } else {
+ language = gameLanguages[language]
+ }
+
// Try to refresh the access token
if _, err := client.RefreshToken(); err != nil {
fmt.Println("Failed to find or refresh the access token. Did you login?")
@@ -122,7 +120,7 @@ func executeDownload(gameID int, downloadPath, language, platformName string, ex
flattenFlag, numThreads)
// Download the game files
- err = client.DownloadGameFiles(user.AccessToken, parsedGameData, downloadPath, gameLanguages[language],
+ err = client.DownloadGameFiles(user.AccessToken, parsedGameData, downloadPath, language,
platformName, extrasFlag, dlcFlag, resumeFlag, flattenFlag, numThreads)
if err != nil {
log.Error().Err(err).Msg("Failed to download game files.")
@@ -137,7 +135,7 @@ func logDownloadParameters(game client.Game, gameID int, downloadPath, language,
extrasFlag, dlcFlag, resumeFlag bool, flattenFlag bool, numThreads int) {
fmt.Println("================================= Download Parameters =====================================")
fmt.Printf("Downloading \"%v\" (with game ID=\"%d\") to \"%v\"\n", game.Title, gameID, downloadPath)
- fmt.Printf("Platform: \"%v\", Language: '%v'\n", platformName, gameLanguages[language])
+ fmt.Printf("Platform: \"%v\", Language: '%v'\n", platformName, language)
fmt.Printf("Include Extras: \"%v, Include DLCs: \"%v\", Resume enabled: \"%v\"\n", extrasFlag, dlcFlag, resumeFlag)
fmt.Printf("Number of worker threads for download: \"%d\"\n", numThreads)
fmt.Printf("Flatten directory structure: \"%v\"\n", flattenFlag)
diff --git a/cmd/file.go b/cmd/file.go
index 897c582..d179913 100644
--- a/cmd/file.go
+++ b/cmd/file.go
@@ -6,7 +6,10 @@ import (
"crypto/sha256"
"crypto/sha512"
"encoding/hex"
+ "encoding/json"
"fmt"
+ "github.com/habedi/gogg/client"
+ "github.com/habedi/gogg/db"
"github.com/rs/zerolog/log"
"github.com/spf13/cobra"
"hash"
@@ -14,10 +17,12 @@ import (
"os"
"path/filepath"
"runtime"
+ "strconv"
"strings"
"sync"
)
+// List of supported hash algorithms
var hashAlgorithms = []string{"md5", "sha1", "sha256", "sha512"}
// fileCmd represents the file command
@@ -29,7 +34,7 @@ func fileCmd() *cobra.Command {
}
// Add subcommands to the file command
- cmd.AddCommand(hashCmd())
+ cmd.AddCommand(hashCmd(), sizeCmd())
return cmd
}
@@ -234,3 +239,220 @@ func generateHash(filePath string, algo string) (string, error) {
return hex.EncodeToString(hashAlgo.Sum(nil)), nil
}
+
+// sizeCmd represents the size command
+// It returns a cobra.Command that shows the total storage size needed to download game files.
+func sizeCmd() *cobra.Command {
+ var language string
+ var platformName string
+ var extrasFlag bool
+ var dlcFlag bool
+ var sizeUnit string
+
+ cmd := &cobra.Command{
+ Use: "size [gameID]",
+ Short: "Show the total storage size needed to download game files",
+ Long: "Show the total storage size needed to download game files for game with the specified ID and options in MB or GB",
+ Args: cobra.ExactArgs(1),
+ Run: func(cmd *cobra.Command, args []string) {
+ err := estimateStorageSize(args[0], strings.ToLower(language), platformName, extrasFlag, dlcFlag, sizeUnit)
+ if err != nil {
+ log.Fatal().Err(err).Msg("Error estimating storage size for game files to be downloaded")
+ }
+ },
+ }
+
+ // Add flags for size options
+ cmd.Flags().StringVarP(&language, "lang", "l", "en", "Game language [en, fr, de, es, it, ru, pl, pt-BR, zh-Hans, ja, ko]")
+ cmd.Flags().StringVarP(&platformName, "platform", "p", "windows", "Platform name [all, windows, mac, linux]; all means all platforms")
+ cmd.Flags().BoolVarP(&extrasFlag, "extras", "e", true, "Include extra content files? [true, false]")
+ cmd.Flags().BoolVarP(&dlcFlag, "dlcs", "d", true, "Include DLC files? [true, false]")
+ cmd.Flags().StringVarP(&sizeUnit, "unit", "u", "mb", "Size unit to display [mb, gb]")
+
+ return cmd
+}
+
+// estimateStorageSize estimates the total storage size needed to download game files.
+// It takes the game ID, language, platform name, flags for including extras and DLCs, and the size unit (MB or GB).
+func estimateStorageSize(gameID string, language string, platformName string, extrasFlag bool, dlcFlag bool, sizeUnit string) error {
+
+ // Check if the sizeUnit is valid
+ sizeUnit = strings.ToLower(sizeUnit)
+ if sizeUnit != "mb" && sizeUnit != "gb" {
+ fmt.Printf("Invalid size unit: \"%s\". Unit must be mb or gb\n", sizeUnit)
+ return fmt.Errorf("invalid size unit")
+ }
+
+ // Check if the language is valid
+ if !isValidLanguage(language) {
+ fmt.Println("Invalid language code. Supported languages are:")
+ for langCode, langName := range gameLanguages {
+ fmt.Printf("'%s' for %s\n", langCode, langName)
+ }
+ return fmt.Errorf("invalid language code")
+ } else {
+ language = gameLanguages[language]
+ }
+
+ // Try to convert the game ID to an integer
+ gameIDInt, err := strconv.Atoi(gameID)
+ if err != nil {
+ log.Error().Msgf("Invalid game ID: %s", gameID)
+ return err
+ }
+
+ // Retrieve the game data based on the game ID
+ game, err := db.GetGameByID(gameIDInt)
+ if err != nil {
+ log.Error().Msgf("Failed to retrieve game data for ID %d: %v", gameIDInt, err)
+ return err
+ }
+
+ // Check the game data is not nil
+ if game == nil {
+ log.Error().Msgf("Game not found for ID %d", gameIDInt)
+ fmt.Printf("Game with ID %d not found in the catalogue.\n", gameIDInt)
+ return err
+ }
+
+ // Unmarshal the nested JSON data
+ var nestedData client.Game
+ if err := json.Unmarshal([]byte(game.Data), &nestedData); err != nil {
+ log.Error().Msgf("Failed to unmarshal game data for ID %d: %v", gameIDInt, err)
+ return err
+ }
+
+ // Variable to store the total size of downloads
+ var totalSizeMB float64
+
+ // Function to parse size strings
+ parseSize := func(sizeStr string) (float64, error) {
+ sizeStr = strings.TrimSpace(strings.ToLower(sizeStr))
+ if strings.HasSuffix(sizeStr, " gb") {
+ sizeStr = strings.TrimSuffix(sizeStr, " gb")
+ size, err := strconv.ParseFloat(sizeStr, 64)
+ if err != nil {
+ return 0, err
+ }
+ return size * 1024, nil // Convert GB to MB
+ } else if strings.HasSuffix(sizeStr, " mb") {
+ sizeStr = strings.TrimSuffix(sizeStr, " mb")
+ return strconv.ParseFloat(sizeStr, 64)
+ }
+ return 0, fmt.Errorf("unknown size unit")
+ }
+
+ // Calculate the size of downloads
+ for _, download := range nestedData.Downloads {
+ if strings.ToLower(download.Language) != strings.ToLower(language) {
+ log.Info().Msgf("Skipping language %s", download.Language)
+ continue
+ }
+
+ for _, platformFiles := range []struct {
+ files []client.PlatformFile
+ subDir string
+ }{
+ {files: download.Platforms.Windows, subDir: "windows"},
+ {files: download.Platforms.Mac, subDir: "mac"},
+ {files: download.Platforms.Linux, subDir: "linux"},
+ } {
+ if platformName != "all" && platformName != platformFiles.subDir {
+ log.Info().Msgf("Skipping platform %s", platformFiles.subDir)
+ continue
+ }
+
+ for _, file := range platformFiles.files {
+ size, err := parseSize(file.Size)
+ if err != nil {
+ log.Error().Err(err).Msg("Failed to parse file size")
+ return err
+ }
+ if size > 0 {
+ log.Info().Msgf("File: %s, Size: %s", *file.ManualURL, file.Size)
+ totalSizeMB += size
+ }
+ }
+ }
+ }
+
+ // Calculate the size of extras if included
+ if extrasFlag {
+ for _, extra := range nestedData.Extras {
+ size, err := parseSize(extra.Size)
+ if err != nil {
+ log.Error().Err(err).Msg("Failed to parse extra size")
+ return err
+ }
+ if size > 0 {
+ log.Info().Msgf("Extra: %v, Size: %s", extra.ManualURL, extra.Size)
+ totalSizeMB += size
+ }
+ }
+ }
+
+ // Calculate the size of DLCs if included
+ if dlcFlag {
+ for _, dlc := range nestedData.DLCs {
+ for _, download := range dlc.ParsedDownloads {
+ if strings.ToLower(download.Language) != strings.ToLower(language) {
+ log.Info().Msgf("DLC %s: Skipping language %s", dlc.Title, download.Language)
+ continue
+ }
+
+ for _, platformFiles := range []struct {
+ files []client.PlatformFile
+ subDir string
+ }{
+ {files: download.Platforms.Windows, subDir: "windows"},
+ {files: download.Platforms.Mac, subDir: "mac"},
+ {files: download.Platforms.Linux, subDir: "linux"},
+ } {
+ if platformName != "all" && platformName != platformFiles.subDir {
+ log.Info().Msgf("DLC %s: Skipping platform %s", dlc.Title, platformFiles.subDir)
+ continue
+ }
+
+ for _, file := range platformFiles.files {
+ size, err := parseSize(file.Size)
+ if err != nil {
+ log.Error().Err(err).Msg("Failed to parse file size")
+ return err
+ }
+ if size > 0 {
+ log.Info().Msgf("DLC File: %s, Size: %s", *file.ManualURL, file.Size)
+ totalSizeMB += size
+ }
+ }
+ }
+ }
+
+ // Calculate the size of DLC extras if included
+ if extrasFlag {
+ for _, extra := range dlc.Extras {
+ size, err := parseSize(extra.Size)
+ if err != nil {
+ log.Error().Err(err).Msg("Failed to parse extra size")
+ return err
+ }
+ if size > 0 {
+ log.Info().Msgf("DLC Extra: %v, Size: %s", extra.ManualURL, extra.Size)
+ totalSizeMB += size
+ }
+ }
+ }
+ }
+ }
+
+ // Display the total size in the specified unit
+ log.Info().Msgf("Game title: \"%s\"\n", nestedData.Title)
+ log.Info().Msgf("Download parameters: Language=%s; Platform=%s; Extras=%t; DLCs=%t\n", language, platformName, extrasFlag, dlcFlag)
+ if strings.ToLower(sizeUnit) == "gb" {
+ totalSizeGB := totalSizeMB / 1024
+ fmt.Printf("Total download size: %.2f GB\n", totalSizeGB)
+ } else {
+ fmt.Printf("Total download size: %.0f MB\n", totalSizeMB)
+ }
+
+ return nil
+}
diff --git a/cmd/shared.go b/cmd/shared.go
new file mode 100644
index 0000000..5ecdfc0
--- /dev/null
+++ b/cmd/shared.go
@@ -0,0 +1,27 @@
+package cmd
+
+import "strings"
+
+// gameLanguages is a map that associates language codes with their native names.
+// The keys are language codes (e.g., "en" for English) and the values are the native names of the languages.
+var gameLanguages = map[string]string{
+ "en": "English",
+ "fr": "Français", // French
+ "de": "Deutsch", // German
+ "es": "Español", // Spanish
+ "it": "Italiano", // Italian
+ "ru": "Русский", // Russian
+ "pl": "Polski", // Polish
+ "pt-BR": "Português do Brasil", // Portuguese (Brazil)
+ "zh-Hans": "简体中文", // Simplified Chinese
+ "ja": "日本語", // Japanese
+ "ko": "한국어", // Korean
+}
+
+// isValidLanguage checks if a given language code is valid.
+// It returns true if the language code exists in the gameLanguages map, otherwise false.
+func isValidLanguage(lang string) bool {
+ lang = strings.ToLower(lang)
+ _, ok := gameLanguages[lang]
+ return ok
+}
diff --git a/cmd/version.go b/cmd/version.go
index f5f6591..6b35749 100644
--- a/cmd/version.go
+++ b/cmd/version.go
@@ -6,7 +6,7 @@ import (
var (
// version holds the current version of the Gogg.
- version = "0.3.1"
+ version = "0.4.0"
)
// versionCmd creates a new cobra.Command that shows the version of Gogg.
diff --git a/db/db.go b/db/db.go
index aaa223a..1c3c382 100644
--- a/db/db.go
+++ b/db/db.go
@@ -1,6 +1,7 @@
package db
import (
+ "github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
@@ -78,7 +79,8 @@ func migrateTables() error {
// configureLogger configures the GORM logger based on the environment variable.
// It sets the logger to silent mode if the DEBUG_GOGG environment variable is not set, otherwise it sets it to debug mode.
func configureLogger() {
- if os.Getenv("DEBUG_GOGG") == "" {
+
+ if zerolog.GlobalLevel() == zerolog.Disabled {
Db.Logger = Db.Logger.LogMode(0) // Silent mode
} else {
Db.Logger = Db.Logger.LogMode(4) // Debug mode
@@ -95,5 +97,3 @@ func CloseDB() error {
}
return sqlDB.Close()
}
-
-//
diff --git a/docs/README.md b/docs/README.md
index 07bfaa4..0461297 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -10,6 +10,20 @@ You can download the binary builds of Gogg for your operating system
from the [releases page](https://github.com/habedi/gogg/releases).
You might want to add the binary to your system's PATH to use it from anywhere on your system.
+### Installation from Source
+
+Alternatively, you can install Gogg from source using Go toolchain.
+To do that, you need to have [Go](https://golang.org/) installed on your machine.
+
+```bash
+go install github.com/habedi/gogg@latest # Replace `latest` with the desired version (e.g., v0.4.0)
+```
+
+```bash
+# Running Gogg
+$GOPATH/bin/gogg
+```
+
## Usage
### Login to GOG
diff --git a/docs/examples/calculate_storage_for_all_games.ps1 b/docs/examples/calculate_storage_for_all_games.ps1
new file mode 100644
index 0000000..87d4255
--- /dev/null
+++ b/docs/examples/calculate_storage_for_all_games.ps1
@@ -0,0 +1,83 @@
+# To run the script, open PowerShell and execute the following command:
+# Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass; .\calculate_storage_all_games.ps1
+
+# Install PowerShell on Linux
+# sudo apt-get install -y powershell # Debian-based distros
+# sudo yum install -y powershell # Fedora
+# sudo zypper install -y powershell # openSUSE
+# sudo pacman -S powershell # Arch Linux
+# sudo snap install powershell --classic # Ubuntu
+
+# Colors
+$RED = "`e[31m"
+$GREEN = "`e[32m"
+$YELLOW = "`e[33m"
+$NC = "`e[0m" # No Color
+
+Write-Host "${GREEN}========================== Download All Games (Powershell Script) ===================================${NC}"
+Write-Host "${GREEN}Calculate the storage size for downloading all games owned by the user on GOG.com with given options.${NC}"
+Write-Host "${GREEN}=====================================================================================================${NC}"
+
+$env:DEBUG_GOGG = 0 # Debug mode disabled
+$GOGG = ".\bin/gogg" # Path to Gogg's executable file (for example, ".\bin\gogg")
+
+# Download options
+$LANG = "en" # Language English
+$PLATFORM = "windows" # Platform Windows
+$INCLUDE_DLC = 1 # Include DLCs
+$INCLUDE_EXTRA_CONTENT = 1 # Include extra content
+$STORAGE_UNIT = "GB" # Storage unit (MB or GB)
+
+# Function to clean up the CSV file
+function Cleanup
+{
+ if ($latest_csv)
+ {
+ Remove-Item -Force $latest_csv
+ if ($?)
+ {
+ Write-Host "${RED}Cleanup: removed $latest_csv${NC}"
+ }
+ }
+}
+
+# Update game catalogue and export it to a CSV file
+& $GOGG catalogue refresh
+& $GOGG catalogue export ./ --format=csv
+
+# Find the newest catalogue file
+$latest_csv = Get-ChildItem -Path . -Filter "gogg_catalogue_*.csv" | Sort-Object LastWriteTime -Descending | Select-Object -First 1
+
+# Check if the catalogue file exists
+if (-not $latest_csv)
+{
+ Write-Host "${RED}No CSV file found.${NC}"
+ exit 1
+}
+
+Write-Host "${GREEN}Using catalogue file: $( $latest_csv.Name )${NC}"
+
+# Initialize counter and total size
+$counter = 0
+$totalSize = 0.0
+
+# Download each game listed in catalogue file, skipping the first line
+Get-Content $latest_csv.FullName | Select-Object -Skip 1 | ForEach-Object {
+ $fields = $_ -split ","
+ $game_id = $fields[0]
+ $game_title = $fields[1]
+ $counter++
+ Write-Host "${YELLOW}${counter}: Game ID: $game_id, Title: $game_title${NC}"
+ $sizeOutput = & $GOGG file size $game_id --platform=$PLATFORM --lang=$LANG --dlcs=$INCLUDE_DLC `
+ --extras=$INCLUDE_EXTRA_CONTENT --unit=$STORAGE_UNIT
+ $size = [double]($sizeOutput -replace '[^\d.]', '')
+ $totalSize += $size
+ Write-Host "${YELLOW}Total download size: $size $STORAGE_UNIT${NC}"
+ Start-Sleep -Seconds 0.0
+}
+
+# Print total download size
+Write-Host "${GREEN}Total download size for all games: $totalSize $STORAGE_UNIT${NC}"
+
+# Clean up
+Cleanup
diff --git a/docs/examples/download_all_games.ps1 b/docs/examples/download_all_games.ps1
index 11255f6..4541095 100644
--- a/docs/examples/download_all_games.ps1
+++ b/docs/examples/download_all_games.ps1
@@ -11,9 +11,10 @@ Write-Host "${GREEN}===================== Download All Games (Windows Powershell
Write-Host "${GREEN}The code in this script downloads all games owned by the user on GOG.com with given options.${NC}"
Write-Host "${GREEN}============================================================================================${NC}"
-$DEBUG_MODE = 1 # Debug mode enabled
+$env:DEBUG_GOGG = 1 # Debug mode enabled
$GOGG = ".\bin/gogg" # Path to Gogg's executable file (for example, ".\bin\gogg")
+# Download options
$LANG = "en" # Language English
$PLATFORM = "windows" # Platform Windows
$INCLUDE_DLC = 1 # Include DLCs
@@ -58,7 +59,6 @@ Get-Content $latest_csv.FullName | Select-Object -Skip 1 | ForEach-Object {
$game_id = $fields[0]
$game_title = $fields[1]
Write-Host "${YELLOW}Game ID: $game_id, Title: $game_title${NC}"
- $env:DEBUG_GOGG = $DEBUG_MODE
& $GOGG download $game_id $OUTPUT_DIR --platform=$PLATFORM --lang=$LANG `
--dlcs=$INCLUDE_DLC --extras=$INCLUDE_EXTRA_CONTENT --resume=$RESUME_DOWNLOAD --threads=$NUM_THREADS `
--flatten=$FLATTEN
diff --git a/docs/examples/download_all_games.sh b/docs/examples/download_all_games.sh
index af65f4d..8be4676 100644
--- a/docs/examples/download_all_games.sh
+++ b/docs/examples/download_all_games.sh
@@ -13,6 +13,7 @@ echo -e "${GREEN}===============================================================
DEBUG_MODE=1 # Debug mode enabled
GOGG=$(command -v bin/gogg || command -v gogg)
+# Download options
LANG=en # Language English
PLATFORM=windows # Platform Windows
INCLUDE_DLC=1 # Include DLCs
diff --git a/docs/examples/simple_example.sh b/docs/examples/simple_example.sh
index 447d516..a9508de 100644
--- a/docs/examples/simple_example.sh
+++ b/docs/examples/simple_example.sh
@@ -35,3 +35,6 @@ tree ./games
echo "Display hash values of the downloaded game files"
$GOGG file hash ./games --algo=md5
+
+echo "Calculate the total size of (\"The Messenger\") game files in MB"
+$GOGG file size 1433116924 --platform=windows --lang=en --dlcs=true --extras=false
diff --git a/main.go b/main.go
index ecdd522..862aa41 100644
--- a/main.go
+++ b/main.go
@@ -5,6 +5,7 @@ import (
"github.com/rs/zerolog"
"os"
"os/signal"
+ "strings"
"github.com/rs/zerolog/log"
)
@@ -14,11 +15,12 @@ import (
// starts a goroutine to listen for interrupt signals, and executes the main command.
func main() {
- // If the DEBUG_GOGG environment variable is set, enable debug logging to stdout, otherwise disable logging
- if os.Getenv("DEBUG_GOGG") != "" {
- zerolog.SetGlobalLevel(zerolog.DebugLevel)
- } else {
+ // If the DEBUG_GOGG environment variable is set to false or 0, or not set at all, disable logging, otherwise enable it.
+ debugMode := strings.TrimSpace(strings.ToLower(os.Getenv("DEBUG_GOGG")))
+ if debugMode == "false" || debugMode == "0" || debugMode == "" {
zerolog.SetGlobalLevel(zerolog.Disabled)
+ } else {
+ zerolog.SetGlobalLevel(zerolog.DebugLevel)
}
// This block sets up a go routine to listen for an interrupt signal which will immediately exit the program