import requests, time, threading,os,asyncio from yt_dlp import YoutubeDL from moviepy.editor import VideoFileClip from PIL import Image BOT_TOKEN_M = "7151983413:AAFmhbH0A_mkhxcKFxLCYNuxxW42f1lMsJU" API_ID = int(15037283) API_HASH = "7af9d761267bf6b81ed07f942d87127f" #client = TelegramClient("STARK", api_id=API_ID, api_hash=API_HASH,bot_token=BOT_TOKEN_M) #client.start() from aiohttp import web loop = asyncio.get_event_loop() routes = web.RouteTableDef() @routes.get("/", allow_head=True) async def root_route_handler(request): return web.json_response({"status": "running"}) async def web_server(): web_app = web.Application(client_max_size=30000000) web_app.add_routes(routes) return web_app CHAT_ID=int(1823266291) proxies = { 'http': 'socks5://166.62.121.127:45248', 'https': 'socks5://108.179.219.56:1520' } def get_video_duration(video_path): clip = VideoFileClip(video_path) duration = clip.duration clip.close() return duration def generate_thumbnail(video_path, output_path, time=5): clip = VideoFileClip(video_path) thumbnail = clip.get_frame(time) clip.close() thumbnail_image = Image.fromarray(thumbnail) thumbnail_image.save(output_path) return output_path def yt_download(url,path,name,width,height,views): try: with YoutubeDL(ydl_opts) as ydl: download_thread = threading.Thread(target=ydl.download, args=([url],)) download_thread.start() time.sleep(300) ydl.cancel_download() except Exception as e: print(e) try: os.system(f"ffmpeg -i {path}.part -c copy {path}") os.remove(f"{path}.part") except Exception as e: print(e) send_thread = threading.Thread(target=appsendvideo, args=(path,name,width,height,views,)) send_thread.start() def appsendvideo(path,name,width,height,views): try: duration_seconds = get_video_duration(path) thum_path = f'{name}.jpeg' dt = generate_thumbnail(path,thum_path) url = f"https://api.telegram.org/bot{BOT_TOKEN_M}/sendVideo" caption = f"šššš¦šž: {name}\nš•š¢šžš°š¬: {views}" files = {'video': open(path, 'rb'),'thumbnail': open(thum_path,'rb')} payload = { 'chat_id': CHAT_ID, 'width':width, 'height':height, 'caption':caption, 'duration': duration_seconds, 'supports_streaming': True } response = requests.post(url, data=payload,files=files,proxies=proxies) print(response.content) print(response.status_code) os.remove(path) os.remove(thum_path) except Exception as e: print(e) async def start_services(): while True: wapp = web.AppRunner(await web_server()) await wapp.setup() await web.TCPSite(wapp, "0.0.0.0", 7860).start() data = requests.get("https://stripchat.global/api/front/models?limit=15&offset=0&primaryTag=girls&filterGroupTags=%5B%5B%22ethnicityIndian%22%5D%5D&sortBy=stripRanking&parentTag=ethnicityIndian&userRole=guest&groupId=1") data = data.json() models = data["models"] for i in models: name = i["username"] url = i["hlsPlaylist"] bd = i["broadcastSettings"] width = bd["width"] height = bd["height"] views = i["viewersCount"] status = i["status"] path = f'./Videos/{name}.mp4' ydl_opts = { 'outtmpl': path, 'live_stop_duration': 180, 'quiet': True, 'format': 'best', 'nocheckcertificate': True, } if status=="public": download_thread = threading.Thread(target=yt_download, args=(url,path,name,width,height,views,)) download_thread.start() time.sleep(20) if __name__ == '__main__': try: loop.run_until_complete(start_services()) except KeyboardInterrupt: print('----------------------- Service Stopped -----------------------')