instagram: fixes

This commit is contained in:
stefanodvx 2025-04-20 13:17:30 +02:00
parent 7dab9207b7
commit 34219a848e
5 changed files with 15 additions and 19 deletions

View file

@ -74,22 +74,12 @@ var ShareURLExtractor = &models.Extractor{
Run: func(ctx *models.DownloadContext) (*models.ExtractorResponse, error) {
client := util.GetHTTPClient(ctx.Extractor.CodeName)
req, err := http.NewRequest(
http.MethodGet,
ctx.MatchedContentURL,
nil,
)
redirectURL, err := util.GetLocationURL(client, ctx.MatchedContentURL, "")
if err != nil {
return nil, fmt.Errorf("failed to create request: %w", err)
return nil, fmt.Errorf("failed to get url location: %w", err)
}
resp, err := client.Do(req)
if err != nil {
return nil, fmt.Errorf("failed to send request: %w", err)
}
defer resp.Body.Close()
return &models.ExtractorResponse{
URL: resp.Request.URL.String(),
URL: redirectURL,
}, nil
},
}

View file

@ -46,8 +46,9 @@ var ShortExtractor = &models.Extractor{
IsRedirect: true,
Run: func(ctx *models.DownloadContext) (*models.ExtractorResponse, error) {
client := util.GetHTTPClient(ctx.Extractor.CodeName)
shortURL := fmt.Sprintf(shortenerAPIFormat, ctx.MatchedContentID)
location, err := util.GetLocationURL(shortURL, "")
location, err := util.GetLocationURL(client, shortURL, "")
if err != nil {
return nil, fmt.Errorf("failed to get real url: %w", err)
}

View file

@ -46,12 +46,13 @@ var VMExtractor = &models.Extractor{
IsRedirect: true,
Run: func(ctx *models.DownloadContext) (*models.ExtractorResponse, error) {
location, err := util.GetLocationURL(ctx.MatchedContentURL, "")
client := util.GetHTTPClient(ctx.Extractor.CodeName)
redirectURL, err := util.GetLocationURL(client, ctx.MatchedContentURL, "")
if err != nil {
return nil, fmt.Errorf("failed to get url location: %w", err)
}
return &models.ExtractorResponse{
URL: location,
URL: redirectURL,
}, nil
},
}