Documentation
¶
Overview ¶
Package telegram provides Telegram media extraction and download functionality.
Index ¶
- Constants
- func ExtFromMime(mime string) string
- func FindLargestPhotoSize(sizes []tg.PhotoSizeClass) *tg.PhotoSize
- func MatchURL(urlStr string) bool
- func SessionExists() bool
- func SessionFile() string
- func SessionPath() string
- type ChannelInfo
- type DownloadOptions
- type DownloadResult
- type ExtractedMedia
- type Extractor
- type MediaInfo
- type Message
- type TakeoutSession
Constants ¶
const ( // Telegram Desktop's public API credentials // Safe to use - already public and used by many tools DesktopAppID = 2040 DesktopAppHash = "b18441a1ff607e10a989891a5462e627" )
Variables ¶
This section is empty.
Functions ¶
func ExtFromMime ¶
ExtFromMime returns file extension from MIME type
func FindLargestPhotoSize ¶
func FindLargestPhotoSize(sizes []tg.PhotoSizeClass) *tg.PhotoSize
FindLargestPhotoSize finds the largest photo size from available sizes
func SessionFile ¶
func SessionFile() string
SessionFile returns the full path to the desktop session file
func SessionPath ¶
func SessionPath() string
SessionPath returns the path where Telegram session is stored Uses ~/.config/vget/telegram/ to match vget's standard config directory
Types ¶
type ChannelInfo ¶
ChannelInfo holds basic channel information for display
type DownloadOptions ¶ added in v0.11.2
type DownloadOptions struct {
URL string
OutputPath string
Takeout bool // Use takeout session for lower rate limits
ProgressFn func(downloaded, total int64)
}
DownloadOptions configures the download behavior
type DownloadResult ¶
DownloadResult contains the result of a Telegram download
func Download ¶
func Download(urlStr string, outputPath string, progressFn func(downloaded, total int64)) (*DownloadResult, error)
Download downloads media from a Telegram URL directly. This combines extraction and download because Telegram requires the download to happen within the authenticated client context.
func DownloadWithOptions ¶ added in v0.11.2
func DownloadWithOptions(opts DownloadOptions) (*DownloadResult, error)
DownloadWithOptions downloads media with configurable options including takeout mode
type ExtractedMedia ¶
type ExtractedMedia struct {
Title string
Filename string
Ext string
Size int64
Width int
Height int
IsVideo bool
IsAudio bool
IsPhoto bool
}
ExtractedMedia contains extracted media information
func ExtractDocumentInfo ¶
func ExtractDocumentInfo(doc *tg.Document, messageText string, msgID int) *ExtractedMedia
ExtractDocumentInfo extracts metadata from a Telegram document
type Extractor ¶
type Extractor struct{}
Extractor handles Telegram media extraction
type MediaInfo ¶
type MediaInfo struct {
ID string
Title string
Uploader string
URL string
Ext string
Width int
Height int
Size int64
IsVideo bool
IsAudio bool
IsPhoto bool
}
MediaInfo contains extracted media information for the extractor interface
type Message ¶
type Message struct {
ChannelUsername string // For public channels/users
ChannelID int64 // For private channels (from /c/ URLs)
MessageID int
IsPrivate bool
}
Message represents a parsed Telegram message URL
type TakeoutSession ¶ added in v0.11.2
type TakeoutSession struct {
// contains filtered or unexported fields
}
TakeoutSession manages a Telegram takeout session for bulk downloads with lower rate limits. Takeout is Telegram's official data export feature.
func NewTakeoutSession ¶ added in v0.11.2
func NewTakeoutSession(api *tg.Client) *TakeoutSession
NewTakeoutSession creates a new takeout session manager
func (*TakeoutSession) Active ¶ added in v0.11.2
func (t *TakeoutSession) Active() bool
Active returns true if a takeout session is active
func (*TakeoutSession) Finish ¶ added in v0.11.2
func (t *TakeoutSession) Finish(ctx context.Context) error
Finish closes the takeout session
func (*TakeoutSession) ID ¶ added in v0.11.2
func (t *TakeoutSession) ID() int64
ID returns the current takeout session ID
func (*TakeoutSession) Middleware ¶ added in v0.11.2
func (t *TakeoutSession) Middleware() telegram.Middleware
Middleware returns a telegram.Middleware that wraps all requests with takeout