constants

package
v0.1.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 24, 2025 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

golang do NOT allow non-primitive constants so some values are defined as variables. However, all variables in this package never change in runtime.

Index

Constants

View Source
const BIG_FILE_SIZE = 10 * 1024 * 1024 // 10MiB
View Source
const CLIENT_DEFAULT_DOWNLOADING_SPEED_LIMIT = 300 * 1024 * 1024 / 8 // BT客户端默认下载速度上限:300Mbps
View Source
const ENV_PROXY = "env"

a special proxy value to indicate force use proxy from HTTP(S)_PROXY env.

View Source
const FILENAME_INVALID_CHARS_REGEX = `[<>:"/\|\?\*]+`

Invalid characters of file name / file path in Windows + NTFS. Most of theses chars (except '/') are valid in Linux.

View Source
const FILENAME_SUFFIX_ADDED = ".added"
View Source
const FILENAME_SUFFIX_BACKUP = ".bak"
View Source
const FILENAME_SUFFIX_FAIL = ".fail"
View Source
const FILENAME_SUFFIX_OK = ".ok"
View Source
const FILEPATH_INVALID_CHARS_REGEX = `[<>:"|\?\*]+`
View Source
const FILE_HEADER_CHUNK_SIZE = 512
View Source
const HELP_ARG_CATEGORY = `Filter torrents by category. Use "` + NONE + `" to select uncategoried torrents`
View Source
const HELP_ARG_CATEGORY_XSEED = `Only xseed torrents that belongs to this category. Use "` +
	NONE + `" to select uncategoried torrents`
View Source
const HELP_ARG_FILTER_TORRENT = "Filter torrents by name"
View Source
const HELP_ARG_PATH_MAPPERS = `E.g. ` +
	`"/root/Downloads|/var/Downloads" will map "/root/Downloads" or "/root/Downloads/..." path to ` +
	`"/var/Downloads" or "/var/Downloads/...". You can also use ":" instead of "|" as the separator ` +
	`if both pathes do not contain ":" char`
View Source
const HELP_ARG_TAG = `Filter torrents by tag. Comma-separated list. ` +
	`Torrent which tags contain any one in the list matches. Use "` + NONE + `" to select untagged torrents`
View Source
const HELP_ARG_TAG_XSEED = `Comma-separated tag list. Only xseed torrents which tags ` +
	`contain any one in the list. Use "` + NONE + `" to select untagged torrents`
View Source
const HELP_ARG_TEMPLATE = `The Go text template contents string (See https://pkg.go.dev/text/template ). ` +
	`If it starts with "@" char, it (the rest part after @) is treated as a file name and template contents ` +
	`will be read from it instead. You can use all Sprig ( https://github.com/Masterminds/sprig ) functions in template`
View Source
const HELP_ARG_TIMES = `Time string (local timezone). ` +
	`Supported formats: "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd", a unix timestamp integer (seconds), ` +
	`or a time duration (e.g. "5d") which references to a past time point from now`
View Source
const HELP_ARG_TRACKER = `Filter torrents by tracker url or domain. Use "` +
	NONE + `" to select torrents without tracker`
View Source
const HELP_INFOHASH_ARGS = `` /* 749-byte string literal not displayed */
View Source
const HELP_TIP_TTY_BINARY_OUTPUT = "binary .torrent file will mess up the terminal. Use pipe to redirect stdout"
View Source
const HELP_TORRENT_ARGS = `` /* 674-byte string literal not displayed */
View Source
const INFINITE_SIZE = 1024 * 1024 * 1024 * 1024 * 1024 * 1024 // 1EiB
View Source
const INFINITE_TIMEOUT = 86400 * 365 * 100

Some funcs require a (positive) timeout parameter. Use a very long value to emulate infinite. (Seconds)

View Source
const METADATA_FILE = "metadata.nfo"
View Source
const METADATA_KEY_ARRAY_KEYS = "_array_keys"
View Source
const METADATA_KEY_COVER = "_cover"
View Source
const METADATA_KEY_DRY_RUN = "_dryrun"
View Source
const METADATA_KEY_IMAGES = "_images"
View Source
const METADATA_KEY_NO_COVER = "_no_cover" // If set to "1", do not upload cover.* image.
View Source
const META_TORRENT_FILE = ".torrent"
View Source
const NONE = "none"

如果 ptool.toml 配置文件里字符串类型配置项值为空,使用系统默认值;使用 NONE 值显式设置该配置项为空值。 部分 flag 参数使用 NONE 值显式指定为空值。

View Source
const PERM = 0600 // 程序创建的所有文件的 PERM
View Source
const PERM_DIR = 0700 // 程序创建的所有文件夹的 PERM
View Source
const STATUS_FMT = "%-6s  %-15s  %-27s  %-27s  %-s\n"

type, name, ↑info, ↓info, others

View Source
const TEST_FILE = ".ptool-test"

file created for testing dir permissions & accessibility

View Source
const TORRENT_CONTENT_FILENAME_LENGTH_LIMIT = 240

Longer names in torrent will be truncated by libtorrent / qBottorrent, which could cause problems. See: https://github.com/qbittorrent/qBittorrent/issues/7038 .

View Source
const TORRENT_DEFAULT_PIECE_LENGTH = "16MiB"

Variables

View Source
var DefaultIgnorePatterns = []string{
	".*",
	"$*",
	"~$*",
	"*.aria2",
	"*.bak",
	"*.lnk",
	"*.swp",
	"*.tmp",
	"*.temp",
	"*.!qB",
	"*.xltd",
	"*.downloading",
	"*.dropbox",
	"*.torrent",
	"node_modules/",
	"lost+found/",
	"__MACOSX/",
	"System Volume Information/",
	"desktop.ini",
	"Thumbs.db",
	"@eaDir",
}

Ignored file patterns in .gitignore style. Several cmds skip handling these files.

View Source
var ErrDryRun = fmt.Errorf("dry run")

Returned if the action is not processed due to in dry run mode It must be returned as is (Do not wrap it).

View Source
var FilenameInvalidCharsRegex = regexp.MustCompile(FILENAME_INVALID_CHARS_REGEX)
View Source
var FilenameRestrictedCharacterReplacement = map[rune]rune{
	'/':  '/',
	'\\': '\',
}
View Source
var FilenameRestrictedCharacterReplacer *strings.Replacer

Replace invalid Windows filename chars to alternatives. E.g. '/' => '/', '?' => '?'

View Source
var FilepathInvalidCharsRegex = regexp.MustCompile(FILEPATH_INVALID_CHARS_REGEX)
View Source
var FilepathRestrictedCharacterReplacement = map[rune]rune{
	'*': '*',
	':': ':',
	'<': '<',
	'>': '>',
	'|': '|',
	'?': '?',
	'"': '"',
}

It's a subset of https://rclone.org/overview/#restricted-filenames-caveats . Only include invalid filename characters in Windows (NTFS).

View Source
var FilepathRestrictedCharacterReplacer *strings.Replacer

Replace invalid Windows file path chars to alternatives. Similar to FilenameRestrictedCharacterReplacer, but do not replace '/' or '\'.

View Source
var ImgExts = []string{".webp", ".png", ".jpg", ".jpeg"}
View Source
var OpenTrackers = []string{
	"udp://open.stealth.si:80/announce",
	"udp://tracker.opentrackr.org:1337/announce",
	"udp://exodus.desync.com:6969/announce",
	"udp://open.demonii.com:1337/announce",
	"udp://tracker.torrent.eu.org:451/announce",

	"http://sukebei.tracker.wf:8888/announce",
	"http://nyaa.tracker.wf:7777/announce",
}

Sources: https://github.com/nyaadevs/nyaa/blob/master/trackers.txt , https://github.com/ngosang/trackerslist/blob/master/trackers_best.txt . Only include most popular & stable trackers in this list.

Some ptool cmds could add a suffix to processed (torrent) filenames. Current Values: [".added", ".ok", ".fail", ".bak"].

View Source
var TorrentFileMagicNumbers = []string{"d8:announce", "d13:announce-list", "d10:created by", "d13:creation date"}

.torrent file magic number. See: https://en.wikipedia.org/wiki/Torrent_file , https://en.wikipedia.org/wiki/Bencode . 大部分 .torrent 文件第一个字段是 announce, 个别种子没有 announce / announce-list 字段,第一个字段是 created by / creation date 等, 这类种子可以通过 DHT 下载成功。 values: ["d8:announce", "d10:created by", "d13:creation date"]

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL