|
|
import re |
|
|
import requests |
|
|
from bs4 import BeautifulSoup |
|
|
from deep_translator import GoogleTranslator |
|
|
import glob |
|
|
import os |
|
|
import shutil |
|
|
import string |
|
|
import random |
|
|
import sys |
|
|
import time |
|
|
import json |
|
|
|
|
|
loginPageCount = 0 |
|
|
membershipCount = 0 |
|
|
noMembershipCount = 0 |
|
|
def parseCookieFile(cookiefile): |
|
|
x = "" |
|
|
"""Parse a cookies.txt file and return a dictionary of key value pairs |
|
|
compatible with requests.""" |
|
|
|
|
|
cookies = {} |
|
|
with open(cookiefile, 'r') as fp: |
|
|
for line in fp: |
|
|
if not re.match(r'^\#', line): |
|
|
lineFields = line.strip().split('\t') |
|
|
try: |
|
|
cookies[lineFields[5]] = lineFields[6] |
|
|
|
|
|
except: |
|
|
|
|
|
pass |
|
|
|
|
|
if x == "fail": |
|
|
return "fail" |
|
|
else: |
|
|
return cookies |
|
|
|
|
|
|
|
|
def getNetflixInfo(cookiefile): |
|
|
global loginPageCount |
|
|
global membershipCount |
|
|
global noMembershipCount |
|
|
cookies = parseCookieFile(cookiefile) |
|
|
|
|
|
if cookies != "fail": |
|
|
|
|
|
print("a") |
|
|
r = requests.get("https://www.netflix.com/BillingActivity", |
|
|
cookies=cookies) |
|
|
print(r.url) |
|
|
if "login" in r.url: |
|
|
loginPageCount = loginPageCount+1 |
|
|
print("Login Page") |
|
|
os.remove(cookiefile) |
|
|
else: |
|
|
soup = BeautifulSoup(r.content, "html.parser") |
|
|
try: |
|
|
billingDate = soup.find("div", { |
|
|
"data-uia": "streaming-next-cycle" |
|
|
}).get_text() |
|
|
|
|
|
planName = soup.find("div", {"data-uia": "plan-name"}).get_text() |
|
|
|
|
|
billingDate = GoogleTranslator(source='auto', |
|
|
target='en').translate(billingDate) |
|
|
try: |
|
|
lang = soup.find("html", {"lang": 'en'}).get_text() |
|
|
lang = "English" |
|
|
except: |
|
|
lang = "" |
|
|
pass |
|
|
planName = GoogleTranslator(source='auto', |
|
|
target='en').translate(planName) |
|
|
|
|
|
print(billingDate + " " + planName + " " + lang) |
|
|
S = 3 |
|
|
ran = ''.join( |
|
|
random.choices(string.ascii_uppercase + string.digits, k=S)) |
|
|
try: |
|
|
os.makedirs("../Membership") |
|
|
except: |
|
|
pass |
|
|
shutil.move( |
|
|
cookiefile, "../Membership/" + billingDate + " " + planName + " " + |
|
|
lang + " (" + str(ran) + ").txt") |
|
|
membershipCount = membershipCount+1 |
|
|
|
|
|
except: |
|
|
S = 10 |
|
|
ran = ''.join( |
|
|
random.choices(string.ascii_uppercase + string.digits, k=S)) |
|
|
try: |
|
|
os.makedirs("../NoMembership") |
|
|
except: |
|
|
pass |
|
|
shutil.move(cookiefile, '../NoMembership/NoMember' + str(ran) + ".txt") |
|
|
noMembershipCount=noMembershipCount+1 |
|
|
else: |
|
|
|
|
|
os.remove(cookiefile) |
|
|
|
|
|
|
|
|
n = 0 |
|
|
try: |
|
|
os.chdir('./cookies') |
|
|
except: |
|
|
print("Cookies folder not found!\nThe name of cookie folder should me 'cookies'.\nClosing in 5 seconds...") |
|
|
time.sleep(5) |
|
|
sys.exit() |
|
|
for fileName in glob.glob("*.txt"): |
|
|
n += 1 |
|
|
|
|
|
|
|
|
getNetflixInfo(fileName) |
|
|
|
|
|
if n==0: |
|
|
print("Cookie folder is empty") |
|
|
os.chdir('../') |
|
|
|
|
|
|
|
|
print("========================\nInvalid cookies: "+str(loginPageCount)+"\nMembership Cookies: "+str(membershipCount)+"\nValid cookies (no membership): "+str(noMembershipCount)) |