ewftrhyjk commited on
Commit
725c615
β€’
1 Parent(s): e3a5707

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -130
app.py CHANGED
@@ -1,136 +1,23 @@
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
- ydl_opts = {
56
- 'outtmpl': path,
57
- 'live_stop_duration': 180,
58
- 'quiet': True,
59
- 'format': 'best',
60
- 'nocheckcertificate': True,
61
- 'proxy': '154.12.253.232:47522',
62
- }
63
- with YoutubeDL(ydl_opts) as ydl:
64
- download_thread = threading.Thread(target=ydl.download, args=([url],))
65
- download_thread.start()
66
- time.sleep(300)
67
- ydl.cancel_download()
68
- except Exception as e:
69
- print(e)
70
- try:
71
- os.system(f"ffmpeg -i {path}.part -c copy {path}")
72
- os.remove(f"{path}.part")
73
- except Exception as e:
74
- print(e)
75
- send_thread = threading.Thread(target=appsendvideo, args=(path,name,width,height,views,))
76
- send_thread.start()
77
 
78
- def appsendvideo(path,name,width,height,views):
79
- try:
80
- duration_seconds = get_video_duration(path)
81
- thum_path = f'{name}.jpeg'
82
- dt = generate_thumbnail(path,thum_path)
83
- url = f"https://api.telegram.org/bot{BOT_TOKEN_M}/sendVideo"
84
- caption = f"𝐍𝐚𝐦𝐞: {name}\nπ•π’πžπ°π¬: {views}"
85
- files = {'video': open(path, 'rb'),'thumbnail': open(thum_path,'rb')}
86
- payload = {
87
- 'chat_id': CHAT_ID,
88
- 'width':width,
89
- 'height':height,
90
- 'caption':caption,
91
- 'duration': duration_seconds,
92
- 'supports_streaming': True
93
- }
94
- response = requests.post(url, data=payload,files=files,proxies=proxies)
95
- print(response.content)
96
- print(response.status_code)
97
- os.remove(path)
98
- os.remove(thum_path)
99
- except Exception as e:
100
- print(e)
101
-
102
- async def start_services():
103
- while True:
104
- wapp = web.AppRunner(await web_server())
105
- await wapp.setup()
106
- await web.TCPSite(wapp, "0.0.0.0", 7860).start()
107
- 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")
108
- data = data.json()
109
- models = data["models"]
110
- for i in models:
111
- name = i["username"]
112
- url = i["hlsPlaylist"]
113
- bd = i["broadcastSettings"]
114
- width = bd["width"]
115
- height = bd["height"]
116
- views = i["viewersCount"]
117
- status = i["status"]
118
- path = f'./Videos/{name}.mp4'
119
- ydl_opts = {
120
- 'outtmpl': path,
121
- 'live_stop_duration': 180,
122
- 'quiet': True,
123
- 'format': 'best',
124
- 'nocheckcertificate': True,
125
- }
126
- if status=="public":
127
- download_thread = threading.Thread(target=yt_download, args=(url,path,name,width,height,views,))
128
- download_thread.start()
129
- time.sleep(20)
130
 
 
 
131
 
132
  if __name__ == '__main__':
133
- try:
134
- loop.run_until_complete(start_services())
135
- except KeyboardInterrupt:
136
- print('----------------------- Service Stopped -----------------------')
 
1
+ import aiohttp
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  from aiohttp import web
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
 
4
+ async def proxy_handler(request):
5
+ # Extract request parameters from user's request
6
+ method = request.method
7
+ url = "https://api.telegram.org" + request.path_qs
8
+ headers = request.headers
9
+ data = await request.read()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
 
11
+ async with aiohttp.ClientSession() as session:
12
+ # Make a request to the Telegram API
13
+ async with session.request(method, url, headers=headers, data=data) as response:
14
+ # Get response content
15
+ content = await response.read()
16
+ # Forward response from Telegram API to user
17
+ return web.Response(body=content, status=response.status, headers=response.headers)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
 
19
+ app = web.Application()
20
+ app.router.add_route('*', '/{path:.*}', proxy_handler)
21
 
22
  if __name__ == '__main__':
23
+ web.run_app(app,port=7860)