Spaces:
Running
Running
Hashir Kashif
commited on
Commit
·
684e38a
1
Parent(s):
06761b2
asdasdasdasd
Browse files
app.py
CHANGED
@@ -7,7 +7,7 @@ import os
|
|
7 |
import shutil
|
8 |
import string
|
9 |
import random
|
10 |
-
from flask import Flask, abort, send_file, render_template
|
11 |
from flask_autoindex import AutoIndex
|
12 |
from threading import Thread
|
13 |
import time
|
@@ -198,6 +198,110 @@ def getNetflixInfo(cookiefile):
|
|
198 |
os.remove(cookiefile)
|
199 |
print("cookie removed")
|
200 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
201 |
|
202 |
def mainTask():
|
203 |
print("running cookie retriever")
|
@@ -281,6 +385,14 @@ def main():
|
|
281 |
thr.start()
|
282 |
# mainTask()
|
283 |
return 'Hello from Flask!'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
284 |
@app.route('/test')
|
285 |
def test():
|
286 |
thr = Thread(target=testTask)
|
@@ -330,5 +442,4 @@ def sftp_test():
|
|
330 |
ppath = "/"
|
331 |
|
332 |
AutoIndex(app, browse_root=ppath,)
|
333 |
-
# app.run()
|
334 |
|
|
|
7 |
import shutil
|
8 |
import string
|
9 |
import random
|
10 |
+
from flask import Flask, abort, send_file, render_template, request
|
11 |
from flask_autoindex import AutoIndex
|
12 |
from threading import Thread
|
13 |
import time
|
|
|
198 |
os.remove(cookiefile)
|
199 |
print("cookie removed")
|
200 |
|
201 |
+
def getNetflixInfoWithApi(cookiefile):
|
202 |
+
url = "https://hashir672.serv00.net/Membership/"+str(cookiefile)
|
203 |
+
response = requests.get(url)
|
204 |
+
if response.status_code == 200:
|
205 |
+
with open(cookiefile, "wb") as file:
|
206 |
+
file.write(response.content)
|
207 |
+
print("File downloaded successfully!")
|
208 |
+
else:
|
209 |
+
print("Failed to download the file.")
|
210 |
+
return "Invalid Link"
|
211 |
+
cookies = parseCookieFile(cookiefile)
|
212 |
+
ftp,ssh_client = sftp_connect()
|
213 |
+
ftp.remove("./domains/hashir672.serv00.net/public_html/Membership/"+cookiefile)
|
214 |
+
ssh_client.close()
|
215 |
+
# print(cookies)
|
216 |
+
if cookies != "fail":
|
217 |
+
|
218 |
+
r = requests.get("https://www.netflix.com/BillingActivity",
|
219 |
+
cookies=cookies)
|
220 |
+
print(r.url)
|
221 |
+
if "login" in r.url:
|
222 |
+
print("Login Page")
|
223 |
+
os.remove(cookiefile)
|
224 |
+
return "Not working"
|
225 |
+
else:
|
226 |
+
soup = BeautifulSoup(r.content, "html.parser")
|
227 |
+
try:
|
228 |
+
print(r.url)
|
229 |
+
billingDate = soup.find("div", {
|
230 |
+
"data-uia": "streaming-next-cycle"
|
231 |
+
})
|
232 |
+
NetflixLocation = soup.find("div", {
|
233 |
+
"data-uia": "loc"
|
234 |
+
})['lang']
|
235 |
+
print(NetflixLocation)
|
236 |
+
print(billingDate)
|
237 |
+
try:
|
238 |
+
billingDate = billingDate.get_text()
|
239 |
+
except:
|
240 |
+
billingDate = " "
|
241 |
+
planName = soup.find("div", {"data-uia": "plan-name"})
|
242 |
+
print(planName)
|
243 |
+
planName = planName.get_text()
|
244 |
+
billingDate = GoogleTranslator(source='auto',
|
245 |
+
target='en').translate(billingDate)
|
246 |
+
try:
|
247 |
+
lang = soup.find("html", {"lang": 'en'}).get_text()
|
248 |
+
lang = "English"
|
249 |
+
except:
|
250 |
+
lang = ""
|
251 |
+
pass
|
252 |
+
planName = GoogleTranslator(source='auto',
|
253 |
+
target='en').translate(planName)
|
254 |
+
|
255 |
+
print(billingDate + " " + planName + " " + lang + " " +str(NetflixLocation))
|
256 |
+
try:
|
257 |
+
x = requests.get("https://help.netflix.com/en/node/123279/" +str(NetflixLocation[NetflixLocation.find("-")+1:]))
|
258 |
+
soup = BeautifulSoup(x.content, "html.parser")
|
259 |
+
extraMembebr = soup.findAll('p')
|
260 |
+
try:
|
261 |
+
for i in extraMembebr:
|
262 |
+
if("unavailable" in i.string):
|
263 |
+
# print(i)
|
264 |
+
extraMembebr = ""
|
265 |
+
|
266 |
+
except:
|
267 |
+
extraMembebr = "EM Available"
|
268 |
+
except:
|
269 |
+
pass
|
270 |
+
S = 3
|
271 |
+
ran = ''.join(
|
272 |
+
random.choices(string.ascii_uppercase + string.digits, k=S))
|
273 |
+
cookieFileName = billingDate + " " + planName + " " + lang + " "+str(NetflixLocation)+" "+extraMembebr+ " (" + str(ran) + ").txt"
|
274 |
+
newCookieFile = "./Membership/" + cookieFileName
|
275 |
+
shutil.move(
|
276 |
+
cookiefile, newCookieFile)
|
277 |
+
fixCookie(newCookieFile)
|
278 |
+
ftp,ssh_client = sftp_connect()
|
279 |
+
files = ftp.put(newCookieFile,"./domains/hashir672.serv00.net/public_html/Membership/"+cookieFileName)
|
280 |
+
|
281 |
+
|
282 |
+
print("uploaded ",files)
|
283 |
+
# print('connection established successfully')
|
284 |
+
|
285 |
+
ssh_client.close()
|
286 |
+
os.remove(newCookieFile)
|
287 |
+
return "Working"
|
288 |
+
|
289 |
+
except Exception as e:
|
290 |
+
print(e)
|
291 |
+
f = open("../Membership/error.txt", "a")
|
292 |
+
f.write(str(e) + "\n\n")
|
293 |
+
f.close()
|
294 |
+
print("\n Moving in noMember")
|
295 |
+
S = 10
|
296 |
+
ran = ''.join(
|
297 |
+
random.choices(string.ascii_uppercase + string.digits, k=S))
|
298 |
+
shutil.move(cookiefile, '../NoMembership/NoMember' + str(ran) + ".txt")
|
299 |
+
return "Error occured"
|
300 |
+
else:
|
301 |
+
os.remove(cookiefile)
|
302 |
+
print("cookie removed")
|
303 |
+
return "invalid cookie"
|
304 |
+
|
305 |
|
306 |
def mainTask():
|
307 |
print("running cookie retriever")
|
|
|
385 |
thr.start()
|
386 |
# mainTask()
|
387 |
return 'Hello from Flask!'
|
388 |
+
@app.route('/check')
|
389 |
+
def check():
|
390 |
+
cookieFile = request.args.get('cookie')
|
391 |
+
if(cookieFile==""):
|
392 |
+
cookieFile="hello"
|
393 |
+
print(cookieFile)
|
394 |
+
checkCookie = getNetflixInfoWithApi(cookieFile)
|
395 |
+
return str(checkCookie)
|
396 |
@app.route('/test')
|
397 |
def test():
|
398 |
thr = Thread(target=testTask)
|
|
|
442 |
ppath = "/"
|
443 |
|
444 |
AutoIndex(app, browse_root=ppath,)
|
|
|
445 |
|