File size: 4,239 Bytes
6ea0901 9df76f2 6ea0901 9df76f2 6ea0901 9df76f2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
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 -----------------------')
|