Documentation ¶
Index ¶
- Constants
- Variables
- func GetFileIdAndTypeFromUrl(url string) (string, string)
- func ProcessPostText(postBodyStr, postFolderPath string, downloadGdrive bool, logUrls bool) []*httpfuncs.ToDownload
- type GDrive
- func (gdrive *GDrive) DownloadFile(fileInfo *GdriveFileToDl, filePath string, config *configs.Config, ...) error
- func (gdrive *GDrive) DownloadGdriveUrls(gdriveUrls []*httpfuncs.ToDownload, config *configs.Config, ...) error
- func (gdrive *GDrive) DownloadMultipleFiles(files []*GdriveFileToDl, config *configs.Config, prog progress.Progress)
- func (gdrive *GDrive) GDriveKeyIsValid(userAgent string) (bool, error)
- func (gdrive *GDrive) GetFileDetails(gdriveInfo *GDriveToDl, config *configs.Config) (*GdriveFileToDl, error)
- func (gdrive *GDrive) GetFolderContents(folderId, logPath string, config *configs.Config) ([]*GdriveFileToDl, error)
- func (gdrive *GDrive) GetNestedFolderContents(folderId, logPath string, config *configs.Config) ([]*GdriveFileToDl, error)
- func (gdrive *GDrive) SetApiKey(apiKey string)
- func (gdrive *GDrive) SetApiUrl(apiUrl string)
- func (gdrive *GDrive) SetClient(client *drive.Service)
- func (gdrive *GDrive) SetContext(ctx context.Context)
- func (gdrive *GDrive) SetDownloadTimeout(downloadTimeout int)
- func (gdrive *GDrive) SetMaxDownloadWorkers(maxDownloadWorkers int)
- func (gdrive *GDrive) SetTimeout(timeout int)
- type GDriveFile
- type GDriveFolder
- type GDriveToDl
- type GdriveError
- type GdriveFileToDl
Constants ¶
const ( HTTP3_SUPPORTED = true GDRIVE_ERROR_FILENAME = "gdrive_download.log" BASE_API_KEY_REGEX_STR = `AIza[\w-]{35}` // file fields to fetch from GDrive API: // https://developers.google.com/drive/api/v3/reference/files GDRIVE_FILE_FIELDS = "id,name,size,mimeType,md5Checksum" GDRIVE_FOLDER_FIELDS = "nextPageToken,files(id,name,size,mimeType,md5Checksum)" )
Variables ¶
var ( API_KEY_REGEX = regexp.MustCompile(fmt.Sprintf(`^%s$`, BASE_API_KEY_REGEX_STR)) API_KEY_PARAM_REGEX = regexp.MustCompile(fmt.Sprintf(`key=%s`, BASE_API_KEY_REGEX_STR)) )
Functions ¶
func GetFileIdAndTypeFromUrl ¶
Uses regex to extract the file ID and the file type (type: file, folder) from the given URL
func ProcessPostText ¶
func ProcessPostText(postBodyStr, postFolderPath string, downloadGdrive bool, logUrls bool) []*httpfuncs.ToDownload
Process and detects for any external download links from the post's text content
Types ¶
type GDrive ¶
func (*GDrive) DownloadFile ¶
func (gdrive *GDrive) DownloadFile(fileInfo *GdriveFileToDl, filePath string, config *configs.Config, queue chan struct{}) error
Downloads the given GDrive file using GDrive API v3
If the md5Checksum has a mismatch, the file will be overwritten and downloaded again Downloads the given GDrive file using GDrive API v3
If the md5Checksum has a mismatch, the file will be overwritten and downloaded again
func (*GDrive) DownloadGdriveUrls ¶
func (gdrive *GDrive) DownloadGdriveUrls(gdriveUrls []*httpfuncs.ToDownload, config *configs.Config, apiProg progress.Progress, dlProg progress.Progress) error
Downloads multiple GDrive files based on a slice of GDrive URL strings in parallel
func (*GDrive) DownloadMultipleFiles ¶
func (gdrive *GDrive) DownloadMultipleFiles(files []*GdriveFileToDl, config *configs.Config, prog progress.Progress)
Downloads the multiple GDrive file in parallel using GDrive API v3
func (*GDrive) GDriveKeyIsValid ¶
Checks if the given Google Drive API key is valid
Will return true if the given Google Drive API key is valid
func (*GDrive) GetFileDetails ¶
func (gdrive *GDrive) GetFileDetails(gdriveInfo *GDriveToDl, config *configs.Config) (*GdriveFileToDl, error)
Retrieves the file details of the given GDrive file using GDrive API v3
func (*GDrive) GetFolderContents ¶
func (gdrive *GDrive) GetFolderContents(folderId, logPath string, config *configs.Config) ([]*GdriveFileToDl, error)
Returns the contents of the given GDrive folder
func (*GDrive) GetNestedFolderContents ¶
func (gdrive *GDrive) GetNestedFolderContents(folderId, logPath string, config *configs.Config) ([]*GdriveFileToDl, error)
Retrieves the content of a GDrive folder and its subfolders recursively using GDrive API v3
func (*GDrive) SetContext ¶
func (*GDrive) SetDownloadTimeout ¶
func (*GDrive) SetMaxDownloadWorkers ¶
func (*GDrive) SetTimeout ¶
type GDriveFile ¶
type GDriveFolder ¶
type GDriveFolder struct { Kind string `json:"kind"` IncompleteSearch bool `json:"incompleteSearch"` Files []GDriveFile `json:"files"` NextPageToken string `json:"nextPageToken"` }