Documentation
¶
Overview ¶
Package remote provides the remote download and update of artifact data from third-party sources such as API's.
Index ¶
- Constants
- Variables
- func FixSceneOrg(rawURL string) string
- type DemozooLink
- func (got *DemozooLink) ArchiveContent(c echo.Context, db *sql.DB, src string) error
- func (got *DemozooLink) Download(c echo.Context, db *sql.DB, download dir.Directory) error
- func (got *DemozooLink) Stat(c echo.Context, db *sql.DB, download dir.Directory) error
- func (got *DemozooLink) Update(c echo.Context, db *sql.DB) error
- type DownloadResponse
- type PouetLink
- func (got *PouetLink) ArchiveContent(c echo.Context, db *sql.DB, src string) error
- func (got *PouetLink) Download(c echo.Context, db *sql.DB, download dir.Directory) error
- func (got *PouetLink) Stat(c echo.Context, db *sql.DB, download dir.Directory) error
- func (got *PouetLink) Update(c echo.Context, db *sql.DB) error
Constants ¶
const (
// User-Agent to send with the HTTP request.
UserAgent = "Defacto2 Uploader form submission, thanks!"
)
Variables ¶
var ( ErrDB = errors.New("database connection is nil") ErrExist = errors.New("file already exists") ErrNF = errors.New("could not get record from demozoo api") )
var ( ErrBodyNil = errors.New("body is nil") ErrStatus = errors.New("wrong status code") )
Functions ¶
func FixSceneOrg ¶ added in v0.14.0
FixSceneOrg returns a working URL if the provided rawURL is a known, broken link to a scene.org file. Otherwise it returns the original URL.
For example, the following rawURL:
`http://files.scene.org/view/demos/groups/trsi/ms-dos/trsiscxt.zip`
will return:
`https://files.scene.org/get/demos/groups/trsi/ms-dos/trsiscxt.zip`
Types ¶
type DemozooLink ¶
type DemozooLink struct { UUID string `json:"uuid"` // UUID is the file production UUID. Github string `json:"github_repo"` // GitHub is the GitHub repository URI. YouTube string `json:"youtube_video"` // YouTube is the YouTube watch video URI. Releaser1 string `json:"releaser1"` // Releaser1 is the first releaser of the file. Releaser2 string `json:"releaser2"` // Releaser2 is the second releaser of the file. Title string `json:"title"` // Title is the file title. Filename string `json:"filename"` // Filename is the file name of the download. Content string `json:"content"` // Content is the file archive content. FileType string `json:"file_type"` // Type is the file type. FileHash string `json:"file_hash"` // Hash is the file integrity hash. Platform string `json:"platform"` // Platform is the file platform. Section string `json:"section"` // Section is the file section. Error string `json:"error"` // Error is the error message if the download or record update failed. CreditText []string `json:"credit_text"` // credit_text, writer CreditCode []string `json:"credit_code"` // credit_program, programmer/coder CreditArt []string `json:"credit_art"` // credit_illustration, artist/graphics CreditAudio []string `json:"credit_audio"` // credit_audio, musician/sound ID int `json:"id"` // ID is the Demozoo production ID. Pouet int `json:"pouet_prod"` // Pouet is the Pouet production ID. FileSize int `json:"file_size"` // Size is the file size in bytes. IssuedYear int16 `json:"issued_year"` // Year is the year the file was issued. IssuedMonth int16 `json:"issued_month"` // Month is the month the file was issued. IssuedDay int16 `json:"issued_day"` // Day is the day the file was issued. }
DemozooLink is the response from the task of GetDemozooFile.
func (*DemozooLink) ArchiveContent ¶
func (got *DemozooLink) ArchiveContent(c echo.Context, db *sql.DB, src string) error
ArchiveContent sets the archive content and readme text of the source file.
func (*DemozooLink) Download ¶
Download fetches the download link from Demozoo and saves it to the download directory. It then runs Update to modify the database record with various metadata from the file and Demozoo record API data.
type DownloadResponse ¶ added in v0.14.0
type DownloadResponse struct { ContentLength string // ContentLength is the size of the file in bytes. ContentType string // ContentType is the MIME type of the file. LastModified string // LastModified is the last modified date of the file. Path string // Path is the path to the downloaded file. }
DownloadResponse contains the details of a downloaded file.
func GetFile ¶ added in v0.14.0
func GetFile(rawURL string, client http.Client) (DownloadResponse, error)
GetFile downloads a file from a remote URL and saves it to the default temp directory. It returns the path to the downloaded file and it should be removed after use.
func GetFile10sec ¶ added in v1.5.6
func GetFile10sec(rawURL string) (DownloadResponse, error)
GetFile10sec downloads a file from a remote URL and saves it to the default temp directory. It uses a timeout of 10 seconds. It returns the path to the downloaded file and it should be removed after use.
func GetFile5sec ¶ added in v1.5.6
func GetFile5sec(rawURL string) (DownloadResponse, error)
GetFile5sec downloads a file from a remote URL and saves it to the default temp directory. It uses a timeout of 5 seconds. It returns the path to the downloaded file and it should be removed after use.
type PouetLink ¶
type PouetLink struct { UUID string `json:"uuid"` // UUID is the file production UUID. Releaser1 string `json:"releaser1"` // Releaser1 is the first releaser of the file. Releaser2 string `json:"releaser2"` // Releaser2 is the second releaser of the file. Title string `json:"title"` // Title is the file title. Filename string `json:"filename"` // Filename is the file name of the download. Content string `json:"content"` // Content is the file archive content. FileType string `json:"file_type"` // Type is the file type. FileHash string `json:"file_hash"` // Hash is the file integrity hash. Platform string `json:"platform"` // Platform is the file platform. Section string `json:"section"` // Section is the file section. Error string `json:"error"` // Error is the error message if the download or record update failed. ID int `json:"id"` // ID is the Demozoo production ID. Demozoo int `json:"demozoo_prod"` // Demozoo production ID. FileSize int `json:"file_size"` // Size is the file size in bytes. IssuedYear int16 `json:"issued_year"` // Year is the year the file was issued. IssuedMonth int16 `json:"issued_month"` // Month is the month the file was issued. IssuedDay int16 `json:"issued_day"` // Day is the day the file was issued. }
PouetLink is the response from the task of GetDemozooFile.
func (*PouetLink) ArchiveContent ¶
ArchiveContent sets the archive content and readme text of the source file.