Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: format code with Black #23

Merged
merged 1 commit into from
Dec 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions cookie_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,17 @@
else:
break


def maximum():
count = 0
for files in os.walk(folder_path):
count += len(files)
return count


rand_number = random.randint(1, 99999)

progress = 0
pbar = progressbar.ProgressBar(max_value=maximum())


def convert_netscape_cookie_to_json(cookie_file_content):
cookies = []
for line in cookie_file_content.splitlines():
Expand All @@ -58,7 +55,6 @@ def convert_netscape_cookie_to_json(cookie_file_content):
json_content = json.dumps(cookies, indent=4)
return json_content


path = "json_cookies"
try:
os.mkdir(path)
Expand Down Expand Up @@ -122,7 +118,9 @@ def convert_netscape_cookie_to_json(cookie_file_content):

json_data = convert_netscape_cookie_to_json(content)

with open(f"temp {rand_number}/{filename}", "w", encoding="utf-8") as f:
with open(
f"temp {rand_number}/{filename}", "w", encoding="utf-8"
) as f:
f.write(json_data)
print(f"{filename} - DONE!")
if 0 <= progress <= maximum():
Expand Down
8 changes: 1 addition & 7 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
)
sys.exit()


else:
import tkinter
from tkinter import filedialog
Expand All @@ -35,24 +34,20 @@
else:
print(f"Using path: {folder_path}")


def maximum():
count = 0
for root_dir, cur_dir, files in os.walk(r"json_cookies"):
count += len(files)
return count


progress = 0
pbar = progressbar.ProgressBar(max_value=maximum())


def load_cookies_from_json(json_cookies_path):
with open(json_cookies_path, "r", encoding="utf-8") as cookie_file:
cookie = json.load(cookie_file)
return cookie


def open_webpage_with_cookies(link, json_cookies):
global progress
global working_cookies
Expand All @@ -70,7 +65,7 @@ def open_webpage_with_cookies(link, json_cookies):
progress += 1

if driver.find_elements(By.CSS_SELECTOR, ".btn") or driver.find_elements(
By.CSS_SELECTOR, ".e1ax5wel1"
By.CSS_SELECTOR, ".e1ax5wel1"
):
print(f"Cookie Not working - {filename}")
driver.quit()
Expand All @@ -90,7 +85,6 @@ def open_webpage_with_cookies(link, json_cookies):
driver.quit()
working_cookies += 1


for filename in os.listdir("json_cookies"):
filepath = os.path.join("json_cookies", filename)
if os.path.isfile(filepath):
Expand Down