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

View File

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