Documentation ¶
Index ¶
- Constants
- Variables
- func ArchiveExtract(f string) []string
- func CheckDeps() []string
- func FCompress(f string, flist []string) error
- func FCompressVol(f string, flist []string) []string
- func FFToAnimatedWebpLQ(f string) error
- func FFToAnimatedWebpWA(f string) error
- func FFToGif(f string) (string, error)
- func FFToWebmSafe(f string, isCustomEmoji bool) (string, error)
- func FFToWebmTGVideo(f string, isCustomEmoji bool) (string, error)
- func FFtoPNG(f string, pathOut string) error
- func IMStackToWebp(base string, overlay string) (string, error)
- func IMToAnimatedWebpLQ(f string) error
- func IMToApng(f string) (string, error)
- func IMToPNGThumb(f string) error
- func IMToPng(f string) (string, error)
- func IMToWebpTGStatic(f string, isCustomEmoji bool) (string, error)
- func IMToWebpWA(f string) error
- func InitConvert()
- func LsFiles(dir string, mustHave []string, mustNotHave []string) []string
- func LsFilesR(dir string, mustHave []string, mustNotHave []string) []string
- func ParseImportLink(link string, ld *LineData) (string, error)
- func PrepareImportStickers(ctx context.Context, ld *LineData, workDir string, convertToTGFormat bool, ...) error
- func RlottieToGIF(f string) (string, error)
- func SecHex(n int) string
- func SetImageTime(f string, t time.Time) error
- type Author
- type KakaoJson
- type KakaoJsonResult
- type LineData
- type LineFile
- type LineJson
- type LineProductInfo
- type Price
- type Sticker
- type Title
Constants ¶
const ( FORMAT_TG_REGULAR_STATIC = "tg_reg_static" FORMAT_TG_EMOJI_STATIC = "tg_emoji_static" FORMAT_TG_REGULAR_ANIMATED = "tg_reg_ani" FORMAT_TG_EMOJI_ANIMATED = "tg_emoji_ani" )
const ( // Decimal KB = 1000 MB = 1000 * KB GB = 1000 * MB TB = 1000 * GB PB = 1000 * TB // Binary KiB = 1024 MiB = 1024 * KiB GiB = 1024 * MiB TiB = 1024 * GiB PiB = 1024 * TiB )
See: http://en.wikipedia.org/wiki/Binary_prefix
const ( LINE_STICKER_STATIC = "line_s" //普通貼圖 LINE_STICKER_ANIMATION = "line_a" //動態貼圖 LINE_STICKER_POPUP = "line_p" //全螢幕 LINE_STICKER_POPUP_EFFECT = "line_f" //特效 LINE_EMOJI_STATIC = "line_e" //表情貼 LINE_EMOJI_ANIMATION = "line_i" //動態表情貼 LINE_STICKER_MESSAGE = "line_m" //訊息 LINE_STICKER_NAME = "line_n" //隨你填 KAKAO_EMOTICON = "kakao_e" //KAKAOTALK普通貼圖 LINE_SRC_PER_STICKER_TEXT = "PER_STICKER_TEXT" LINE_SRC_ANIMATION = "ANIMATION" LINE_SRC_STATIC = "STATIC" LINE_SRC_POPUP = "POPUP" LINE_SRC_NAME_TEXT = "NAME_TEXT" //Indicates popup effect, bot popup APNG and static PNG should be kept. LINE_POPUP_LAYER_BACKGROUND = "BACKGROUND" //Indicates popup, only popup APNG needed. LINE_POPUP_LAYER_FOREGROUND = "FOREGROUND" StoreLine = "line" StoreKakao = "kakao" WARN_KAKAO_PREFER_SHARE_LINK = "prefer share link for kakao" )
Line sticker types
Variables ¶
var BSDTAR_BIN = "bsdtar"
var CONVERT_ARGS []string
var CONVERT_BIN = "convert"
var FFMPEG_BIN = "ffmpeg"
Functions ¶
func ArchiveExtract ¶
func CheckDeps ¶
func CheckDeps() []string
Check if required dependencies exist and return a string slice containing binaries that are not found in PATH.
func FCompressVol ¶
func FFToAnimatedWebpWA ¶
// animated webp has a pretty bad compression ratio comparing to VP9, // shrink down quality as much as possible.
func FFToWebmSafe ¶
This function will be called if Telegram's API rejected our webm. It is normally due to overlength or bad FPS rate.
func IMToWebpTGStatic ¶
Convert any image to static WEBP image, for Telegram use. `format` takes either FORMAT_TG_REGULAR_STATIC or FORMAT_TG_EMOJI_STATIC
func IMToWebpWA ¶
Convert image to static Webp for Whatsapp, size limit is 100KiB.
func InitConvert ¶
func InitConvert()
Should call before using functions in this package. Otherwise, defaults to Linux environment. This function also call CheckDeps to check if executables.
func ParseImportLink ¶
This function serves as an entrypoint for this package. Parse a LINE or Kakao link and fetch metadata. The metadata (which means the LineData struct) can be used to call prepareImportStickers. Returns a string and an error. String act as a warning message, empty string means no warning yield.
Attention: After this function returns, ld.Amount, ld.Files will NOT be available!
func PrepareImportStickers ¶
func PrepareImportStickers(ctx context.Context, ld *LineData, workDir string, convertToTGFormat bool, convertToTGEmoji bool) error
Prepare stickers files. Should be called after calling ParseImportLink(). A context is provided, which can be used to interrupt the process. Even if this function returns, file preparation might still in progress. LineData.Amount, LineData.Files will be produced after return. wg.Wait() is required for individual LineData.Files
convertToTGFormat: Convert original stickers to Telegram sticker format. convertToTGEmoji: If present sticker set is Emoji(LINE), convert to 100x100 Telegram CustomEmoji.
Types ¶
type KakaoJson ¶
type KakaoJson struct {
Result KakaoJsonResult
}
type KakaoJsonResult ¶
type LineData ¶
type LineData struct { //Waitgroup for when linedata become available. Wg sync.WaitGroup //Store type, defined in const. Store string //Store link Link string //Store links for different langs I18nLinks []string //Sticker download link, typically ZIP. DLink string //Sticker download links. DLinks []string //Sticker file paths. Files []*LineFile //Sticker category, defined in const. Category string //Sticker pack ID. Id string //Sticker title appeared in store. Title string //I18n titles for LINE sticker packs, TitleWg must be waited before using this field. I18nTitles []string //WaitGroup for I18nTitles TitleWg sync.WaitGroup //Is Animated line sticker. IsAnimated bool //Is line emoji(emoticon). IsEmoji bool Amount int }
This is called linedata due to historical reason, instead, it handles "import" data, which includes kakao and line by far.
type LineProductInfo ¶
type LineProductInfo struct { PackageID int64 `json:"packageId"` OnSale bool `json:"onSale"` ValidDays int64 `json:"validDays"` Title Title `json:"title"` Author Author `json:"author"` Price []Price `json:"price"` Stickers []Sticker `json:"stickers"` HasAnimation bool `json:"hasAnimation"` HasSound bool `json:"hasSound"` StickerResourceType string `json:"stickerResourceType"` }