-
Notifications
You must be signed in to change notification settings - Fork 0
/
classes.py
151 lines (126 loc) · 5.47 KB
/
classes.py
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
import requests
import json
import glob, os, os.path
myDir = os.getcwd().replace('\\', '\\\\')
def clearStr(string):
string2 = string.replace("📍 @JafarAbad 📍", "")
string2 = string2.replace("🇯🇴🇮🇳 ↯", "")
string2 = string2.replace("#ترفند", "")
string2 = string2.replace("@RedLineTel 🚩", "")
string2 = string2.replace("Join 🔜 ", "")
string2 = string2.replace("@khandbazar20💯", "")
string2 = string2.replace("🌐 @KHANDBAZAR20 🔚", "")
return string2
string2 = str(string).split(" ")
for a in string2:
if "@" in a:
string2 = str(string).replace(a, "@TimRstun")
break
def ReadNumber():
with open("Number.txt", 'r') as file:
number = int(file.read())
with open("Number.txt", 'w') as file:
file.write(str(number + 1))
return str(number)
def ChangeUrlMode():
with open("UrlMode.txt", 'r') as file:
number = int(file.read())
number = 1 - number
with open("UrlMode.txt", 'w') as file:
file.write(str(number))
return str(number)
def ChangeHashatgMode():
with open("HashtagMode.txt", 'r') as file:
number = int(file.read())
if number == 2:
number = 0
else:
number += 1
with open("HashtagMode.txt", 'w') as file:
file.write(str(number))
return str(number)
def ChangeCategoryMode():
with open("CategoryMode.txt", 'r') as file:
number = int(file.read())
number = 1 - number
with open("CategoryMode.txt", 'w') as file:
file.write(str(number))
return str(number)
def ChangeUploadMode():
with open("UploadMode.txt", 'r') as file:
number = int(file.read())
number = 1 - number
with open("UploadMode.txt", 'w') as file:
file.write(str(number))
return str(number)
def ReadUrlMode():
with open("UrlMode.txt", 'r') as file:
number = int(file.read())
return str(number)
def ReadUploadMode():
with open("UploadMode.txt", 'r') as file:
number = int(file.read())
return str(number)
def ReadHashtagMode():
with open("HashtagMode.txt", 'r') as file:
number = int(file.read())
return str(number)
def ReadCategoryMode():
with open("CategoryMode.txt", 'r') as file:
number = int(file.read())
return str(number)
def GetUrl(url, number):
a = requests.get(url)
geted = json.loads(a.text)
geted2 = geted['uploadform']
# file = open ("send.html" , 'r+')
# readall = file.read()
# readall2 = readall.split()
# a = readall.replace(readall2[3] , "action=\"" + geted2['formAction'] + "\"")
# file.close()
# file = open(f"{str(number)}send.html" , 'w')
# file.write(a)
# file.close()
return (geted2)
def OpenDriver(UploadUrl, caption, number, hashtagMode , category):
url = UploadUrl['formAction']
if hashtagMode == "0":
hashtag = "طنز-خنده دار-بخند-خنده-کمدی"
elif hashtagMode == "1":
hashtag = "طنز-خنده دار-بخند-امیرکلیپر-amircliepr"
elif hashtagMode == "2":
hashtag = "موسیقی-آهنگ-سینا محمدی-sina mohammadi-موزیک"
if category == "0":
category = "2"
elif category == "1":
category = "7"
payload = {'data[category]': category,
'data[title]': caption,
'data[tags]': hashtag,
# 'data[tags]': 'گوشی موبایل-موبایل-آریا مارکت-آریامارکت-سامسونگ',
'data[descr]': "ببین چه کلیپای باحالی میزارم ، فالو کن دیگه :(",
# 'data[descr]': '✅ فروش انواع گوشی و تبلت با بهترین قیمت ✅ فروشگاه آریامارکت پیج اینستاگرام ما : @www_aria_store سایت ما : https://www.ariamarket.ir تلفن ما : 021-91311913',
'frm-id': UploadUrl['frm-id']}
files = [
(
'video', (f'{number}.mp4', open(f'{myDir}\\{number}.mp4', 'rb'),
'application/octet-stream'))
]
response = requests.request("POST", url, data=payload, files=files)
print(response.text)
return response.text
# driver = webdriver.Firefox()
# driver.get(f"file:///D:/AparatTelegramBot/{str(number)}send.html")
# print(UploadUrl['frm-id'])
# print(UploadUrl['formAction'])
# driver.find_element_by_xpath('/html/body/form/input[1]').send_keys(
# f"D:\\AparatTelegramBot\\{number}.mp4")
# driver.find_element_by_xpath('/html/body/form/input[2]').send_keys(UploadUrl['frm-id']) # frmid
# driver.find_element_by_xpath('/html/body/form/input[3]').send_keys(caption) # title
# driver.find_element_by_xpath('/html/body/form/input[4]').send_keys(2) # IdTabagheBandi
# # driver.find_element_by_xpath('/html/body/form/input[5]').send_keys("amircliper - امیرکلیپر - امیر کلیپر - amir cliper - خنده دار") # tags
# # driver.find_element_by_xpath('/html/body/form/input[5]').send_keys("موزیک - اهنگ - موسیقی - آهنگ جدید - موزیک جدید") # tags
# driver.find_element_by_xpath('/html/body/form/input[5]').send_keys("خنده - خنده دار - بخند - طنز - کمدی") # tags
# driver.find_element_by_xpath('/html/body/form/input[6]').send_keys(
# "ببین چه کلیپای باحالی میزارم دنبالمون کن دیگه :(") # tozihat
# driver.find_element_by_xpath('/html/body/form/input[7]').send_keys(Keys.ENTER)