v2.5.1: drop unsupported third party insta api.

This commit is contained in:
anonymousx97 2024-01-09 16:19:06 +05:30
parent 31d19bc48b
commit 04a4484b9d
4 changed files with 54 additions and 61 deletions

View File

@ -60,7 +60,6 @@
> It will ask you to choose pyrogram version. Select 2.
* LOG_CHAT: Create A Log Channel and add it's id along with -100 at the beginning.
* API_KEYS: Optional Instagram scrapping keys from <a href=https://webscraping.ai/>API. </a> recommended to add if you wanna reduce Instagram dl failures.
* <details>
<summary>Tap here for The Message IDs : </summary>

View File

@ -6,29 +6,28 @@ from app.social_dl.scraper_config import ScraperConfig
from app.utils import aiohttp_tools as aio
from app.utils.media_helper import MediaType, get_type
class ApiKeys:
def __init__(self):
self.API2_KEYS: list = Config.API_KEYS
self.api_2 = 0
# Rotating Key function to avoid hitting limit on single Key
def get_key(self, func: str) -> str:
keys = self.API2_KEYS
count = getattr(self, func) + 1
if count >= len(keys):
count = 0
setattr(self, func, count)
return keys[count]
# def switch(self) -> int:
# self.switch_val += 1
# if self.switch_val >= 3:
# self.switch_val = 0
# return self.switch_val
api_keys: ApiKeys = ApiKeys()
# class ApiKeys:
# def __init__(self):
# self.API2_KEYS: list = Config.API_KEYS
# self.api_2 = 0
#
# # Rotating Key function to avoid hitting limit on single Key
# def get_key(self, func: str) -> str:
# keys = self.API2_KEYS
# count = getattr(self, func) + 1
# if count >= len(keys):
# count = 0
# setattr(self, func, count)
# return keys[count]
#
# def switch(self) -> int:
# self.switch_val += 1
# if self.switch_val >= 3:
# self.switch_val = 0
# return self.switch_val
#
#
# api_keys: ApiKeys = ApiKeys()
class Instagram(ScraperConfig):
@ -36,7 +35,6 @@ class Instagram(ScraperConfig):
self.APIS = (
"check_dump",
"no_api_dl",
"api_2",
)
super().__init__(url=url)
@ -72,29 +70,29 @@ class Instagram(ScraperConfig):
return
return await self.parse_ghraphql(response["data"]["shortcode_media"])
async def api_2(self) -> bool | None:
if not Config.API_KEYS:
return
# "/?__a=1&__d=1"
response: dict | None = await aio.get_json(
url="https://api.webscraping.ai/html",
timeout=30,
params={
"api_key": api_keys.get_key("api_2"),
"url": self.api_url,
"proxy": "residential",
"js": "false",
},
)
if (
not response
or "data" not in response.keys()
or not response["data"]["shortcode_media"]
):
LOGGER.error(response)
return
self.caption = ".."
return await self.parse_ghraphql(response["data"]["shortcode_media"])
# async def api_2(self) -> bool | None:
# if not Config.API_KEYS:
# return
# # "/?__a=1&__d=1"
# response: dict | None = await aio.get_json(
# url="https://api.webscraping.ai/html",
# timeout=30,
# params={
# "api_key": api_keys.get_key("api_2"),
# "url": self.api_url,
# "proxy": "residential",
# "js": "false",
# },
# )
# if (
# not response
# or "data" not in response.keys()
# or not response["data"]["shortcode_media"]
# ):
# LOGGER.error(response)
# return
# self.caption = ".."
# return await self.parse_ghraphql(response["data"]["shortcode_media"])
async def parse_ghraphql(self, json_: dict) -> str | list | None:
type_check: str | None = json_.get("__typename", None)

View File

@ -22,7 +22,6 @@ from app.social_dl.api.gallery_dl import GalleryDL
from app.social_dl.api.instagram import Instagram
from app.social_dl.api.reddit import Reddit
from app.social_dl.api.threads import Threads
from app.social_dl.api.tiktok import Tiktok
from app.social_dl.api.ytdl import YouTubeDL
from app.utils import aiohttp_tools, shell

View File

@ -1,13 +1,15 @@
API_ID=12345678
# You API ID
API_HASH="abf12395nskfns"
API_HASH=abf12395nskfns
# HASH
API_KEYS=[]
# Your https://api.webscraping.ai/ Keys
# Multiple values are separated by ,
# so [122456, 78990]
#STRING_SESSION=
#BOT_TOKEN=
# Uncomment the mode you wanna use it on and add value.
# Only a Single Mode is supported at a time so dont add both.
BLOCKED_USERS_MESSAGE_ID = 0
@ -16,7 +18,6 @@ BLOCKED_USERS_MESSAGE_ID = 0
# 69 in the end of the list so Value is 69
# Blocked users list
DEV_MODE=0
# Change to 1 if you want exec, sh, shell commands
@ -38,11 +39,7 @@ AUTO_DL_MESSAGE_ID=0
# For Auto DL chat List
TRIGGER="."
STRING_SESSION="Aq0dj......"
# Your session
TRIGGER=.
USERS_MESSAGE_ID = 0