diff --git a/docs/configuration.rst b/docs/configuration.rst index e595fb4c..f806298b 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -1468,6 +1468,20 @@ Description for details) +extractor.instagram.api +----------------------- +Type + ``string`` +Default + ``"auto"`` +Description + Selects which API endpoints to use. + + * ``"rest"``: REST API - higher-resolution media, only usable when logged in + * ``"graphql"``: GraphQL API - lower-resolution media, partially accessible when not logged in + * ``"auto"``: Use REST API when logged in, GraphQL API otherwise + + extractor.instagram.include --------------------------- Type diff --git a/docs/gallery-dl.conf b/docs/gallery-dl.conf index 346945f0..497fa4a8 100644 --- a/docs/gallery-dl.conf +++ b/docs/gallery-dl.conf @@ -156,8 +156,9 @@ { "username": null, "password": null, + "api": "auto", "include": "posts", - "sleep-request": 8.0, + "sleep-request": [6.0, 12.0], "videos": true }, "khinsider": diff --git a/gallery_dl/extractor/instagram.py b/gallery_dl/extractor/instagram.py index 7000a944..04c06bf4 100644 --- a/gallery_dl/extractor/instagram.py +++ b/gallery_dl/extractor/instagram.py @@ -43,8 +43,15 @@ class InstagramExtractor(Extractor): def items(self): self.login() - self.api = (InstagramRestAPI(self) if self._logged_in else - InstagramGraphqlAPI(self)) + + api = self.config("api") + if api is None or api == "auto": + api = InstagramRestAPI if self._logged_in else InstagramGraphqlAPI + elif api == "graphql": + api = InstagramGraphqlAPI + else: + api = InstagramRestAPI + self.api = api(self) data = self.metadata() videos = self.config("videos", True)