ewftrhyjk commited on
Commit
6ea0901
β€’
1 Parent(s): 15435fe

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +124 -0
app.py ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests, time, threading,os,asyncio
2
+ from yt_dlp import YoutubeDL
3
+ from moviepy.editor import VideoFileClip
4
+ from PIL import Image
5
+
6
+
7
+ BOT_TOKEN_M = "7151983413:AAFmhbH0A_mkhxcKFxLCYNuxxW42f1lMsJU"
8
+
9
+ API_ID = int(15037283)
10
+ API_HASH = "7af9d761267bf6b81ed07f942d87127f"
11
+
12
+ #client = TelegramClient("STARK", api_id=API_ID, api_hash=API_HASH,bot_token=BOT_TOKEN_M)
13
+ #client.start()
14
+
15
+ from aiohttp import web
16
+ loop = asyncio.get_event_loop()
17
+
18
+ routes = web.RouteTableDef()
19
+
20
+ @routes.get("/", allow_head=True)
21
+ async def root_route_handler(request):
22
+ return web.json_response({"status": "running"})
23
+
24
+ async def web_server():
25
+ web_app = web.Application(client_max_size=30000000)
26
+ web_app.add_routes(routes)
27
+ return web_app
28
+
29
+
30
+ CHAT_ID=int(1823266291)
31
+
32
+ proxies = {
33
+ 'http': 'socks5://166.62.121.127:45248',
34
+ 'https': 'socks5://108.179.219.56:1520'
35
+ }
36
+
37
+
38
+ def get_video_duration(video_path):
39
+ clip = VideoFileClip(video_path)
40
+ duration = clip.duration
41
+ clip.close()
42
+ return duration
43
+
44
+ def generate_thumbnail(video_path, output_path, time=5):
45
+ clip = VideoFileClip(video_path)
46
+ thumbnail = clip.get_frame(time)
47
+ clip.close()
48
+ thumbnail_image = Image.fromarray(thumbnail)
49
+ thumbnail_image.save(output_path)
50
+ return output_path
51
+
52
+
53
+ def yt_download(url,path,name,width,height,views):
54
+ try:
55
+ with YoutubeDL(ydl_opts) as ydl:
56
+ download_thread = threading.Thread(target=ydl.download, args=([url],))
57
+ download_thread.start()
58
+ time.sleep(10)
59
+ ydl.cancel_download()
60
+ except Exception as e:
61
+ print(e)
62
+ try:
63
+ os.system(f"ffmpeg -i {path}.part -c copy {path}")
64
+ os.remove(f"{path}.part")
65
+ except Exception as e:
66
+ print(e)
67
+ send_thread = threading.Thread(target=appsendvideo, args=(path,name,width,height,views,))
68
+ send_thread.start()
69
+
70
+ def appsendvideo(path,name,width,height,views):
71
+ try:
72
+ duration_seconds = get_video_duration(path)
73
+ thum_path = f'{name}.jpeg'
74
+ dt = generate_thumbnail(path,thum_path)
75
+ url = f"https://api.telegram.org/bot{BOT_TOKEN_M}/sendVideo"
76
+ caption = f"𝐍𝐚𝐦𝐞: {name}\nπ•π’πžπ°π¬: {views}"
77
+ files = {'video': open(path, 'rb'),'thumbnail': open(thum_path,'rb')}
78
+ payload = {
79
+ 'chat_id': CHAT_ID,
80
+ 'width':width,
81
+ 'height':height,
82
+ 'caption':caption,
83
+ 'duration': duration_seconds,
84
+ 'supports_streaming': True
85
+ }
86
+ response = requests.post(url, data=payload,files=files,proxies=proxies)
87
+ print(response.content)
88
+ print(response.status_code)
89
+ os.remove(path)
90
+ os.remove(thum_path)
91
+ except Exception as e:
92
+ print(e)
93
+
94
+
95
+ while True:
96
+ wapp = web.AppRunner(await web_server())
97
+ await wapp.setup()
98
+ await web.TCPSite(wapp, "0.0.0.0", 7860).start()
99
+ 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")
100
+ data = data.json()
101
+ models = data["models"]
102
+ for i in models:
103
+ name = i["username"]
104
+ url = i["hlsPlaylist"]
105
+ bd = i["broadcastSettings"]
106
+ width = bd["width"]
107
+ height = bd["height"]
108
+ views = i["viewersCount"]
109
+ status = i["status"]
110
+ path = f'./Videos/{name}.mp4'
111
+ ydl_opts = {
112
+ 'outtmpl': path,
113
+ 'live_stop_duration': 180,
114
+ 'quiet': True,
115
+ 'format': 'best',
116
+ 'nocheckcertificate': True,
117
+ }
118
+ if status=="public":
119
+ download_thread = threading.Thread(target=yt_download, args=(url,path,name,width,height,views,))
120
+ download_thread.start()
121
+ time.sleep(10)
122
+
123
+
124
+