mirror of
https://github.com/anonymousx97/social-dl.git
synced 2025-02-20 11:13:19 +08:00
New Banner. Added Credits and Disclaimer. Refactored the bot into modules. switched to Latest Pyrogram. Switched to Custom Client Object. switched to Custom Message Object. Switched to Custom decorators. Switched to Custom filters. Switched to Classes for media extractors. Droped Wget Switched to native In_Memory_DL Added Gallery-dl Library. Added Twitter Image support. Added Threads Support. Added YouTube Videos up to 5 Minutes. Added Tiktok Pics Support. Added .help command. Added .shell command with Live shell output. Added Add-Del Sudo commands. Added Add-Del Chat commands. Added Block-Unblock Commands. Added Banner In About message. Added .reply as Echo command. Added restart confirmation. Catch Exceptions and log in the Log Channel.
31 lines
972 B
Python
31 lines
972 B
Python
import os
|
|
from urllib.parse import urlparse
|
|
|
|
from bs4 import BeautifulSoup
|
|
|
|
from app.core import aiohttp_tools
|
|
from app.core.scraper_config import ScraperConfig
|
|
|
|
|
|
class Threads(ScraperConfig):
|
|
def __init__(self, url):
|
|
super().__init__()
|
|
self.url = url
|
|
self.set_sauce(url)
|
|
|
|
async def download_or_extract(self):
|
|
shortcode = os.path.basename(urlparse(self.url).path.rstrip("/"))
|
|
|
|
response = await (await aiohttp_tools.SESSION.get(f"https://www.threads.net/t/{shortcode}/embed/")).text()
|
|
|
|
soup = BeautifulSoup(response, "html.parser")
|
|
|
|
if div := soup.find("div", {"class": "SingleInnerMediaContainer"}):
|
|
if video := div.find("video"):
|
|
self.link = video.find("source").get("src")
|
|
self.video = self.success = True
|
|
|
|
elif image := div.find("img", {"class": "img"}):
|
|
self.link = image.get("src")
|
|
self.photo = self.success = True
|