main: changes, fixes

- refactors http session usage across modules
- adjusts video info extraction
- improves temporary directory, concurrency limits, buffering, and error handling in download routines
This commit is contained in:
stefanodvx 2025-04-14 23:45:54 +02:00
parent 10c113f400
commit 58bd5827b3
12 changed files with 171 additions and 51 deletions

View file

@ -16,6 +16,8 @@ import (
// feel free to open PR, if you want to
// add support for the official Instagram API
var httpSession = util.GetHTTPSession()
const (
apiHostname = "api.igram.world"
apiKey = "aaeaf2805cea6abef3f9d2b6a666fce62fd9d612a43ab772bb50ce81455112e0"
@ -42,8 +44,6 @@ var igHeaders = map[string]string{
"User-Agent": util.ChromeUA,
}
var HTTPSession = util.NewHTTPSession()
var Extractor = &models.Extractor{
Name: "Instagram",
CodeName: "instagram",
@ -96,7 +96,7 @@ var ShareURLExtractor = &models.Extractor{
for k, v := range igHeaders {
req.Header.Set(k, v)
}
resp, err := HTTPSession.Do(req)
resp, err := httpSession.Do(req)
if err != nil {
return nil, fmt.Errorf("failed to send request: %w", err)
}
@ -183,7 +183,7 @@ func GetVideoAPI(contentURL string) (*IGramResponse, error) {
req.Header.Set("Content-Type", "application/json")
req.Header.Set("User-Agent", util.ChromeUA)
resp, err := HTTPSession.Do(req)
resp, err := httpSession.Do(req)
if err != nil {
return nil, fmt.Errorf("failed to send request: %w", err)
}