fix: better slices allocation
pre-allocate slices' size when possible when extracting media
This commit is contained in:
parent
0d986d4573
commit
b5c5801ec2
8 changed files with 65 additions and 71 deletions
|
@ -87,9 +87,9 @@ var Extractor = &models.Extractor{
|
|||
func ExtractPinMedia(ctx *models.DownloadContext) ([]*models.Media, error) {
|
||||
pinID := ctx.MatchedContentID
|
||||
contentURL := ctx.MatchedContentURL
|
||||
client := util.GetHTTPClient(ctx.Extractor.CodeName)
|
||||
session := util.GetHTTPClient(ctx.Extractor.CodeName)
|
||||
|
||||
pinData, err := GetPinData(client, pinID)
|
||||
pinData, err := GetPinData(session, pinID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ func ExtractPinMedia(ctx *models.DownloadContext) ([]*models.Media, error) {
|
|||
}
|
||||
|
||||
func GetPinData(
|
||||
client models.HTTPClient,
|
||||
session models.HTTPClient,
|
||||
pinID string,
|
||||
) (*PinData, error) {
|
||||
params := BuildPinRequestParams(pinID)
|
||||
|
@ -179,7 +179,7 @@ func GetPinData(
|
|||
// fix 403 error
|
||||
req.Header.Set("X-Pinterest-PWS-Handler", "www/[username].js")
|
||||
|
||||
resp, err := client.Do(req)
|
||||
resp, err := session.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to send request: %w", err)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue