Skip to content

Commit

Permalink
Updater Script
Browse files Browse the repository at this point in the history
It will overwrite everything
  • Loading branch information
UltimaHoarder committed Jun 16, 2021
1 parent 2ca95be commit 5db4e16
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 5 deletions.
11 changes: 6 additions & 5 deletions classes/make_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@
current_version = None
def fix(config={}):
global current_version
info = config.get("info")
if not info:
print("If you're not using >= v7 release, please download said release so the script can properly update your config. \nIf you're using >= v7 release or you don't care about your current config settings, press enter to continue. If script crashes, delete config.")
input()
current_version = info["version"]
if config:
info = config.get("info")
if not info:
print("If you're not using >= v7 release, please download said release so the script can properly update your config. \nIf you're using >= v7 release or you don't care about your current config settings, press enter to continue. If script crashes, delete config.")
input()
current_version = info["version"]
return config


Expand Down
42 changes: 42 additions & 0 deletions updater.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import io
import requests
from zipfile import ZipFile
import os
from pathlib import Path
import shutil
import time

# API request limit is around 30, so it fails
# local_commit = "2ca95beec5dd526b9b825497dc6227aafbaf67ad"
# response = requests.get("https://api.github.com/repos/digitalcriminal/onlyfans/branches/master")
# response_json = response.json()
# commit_id = response_json["commit"]["sha"]
# downloaded = requests.get(f"https://github.com/DIGITALCRIMINAL/OnlyFans/archive/{commit_id}.zip")
downloaded = requests.get(
f"https://github.com/DIGITALCRIMINAL/OnlyFans/archive/refs/heads/master.zip"
)
content = io.BytesIO(downloaded.content)
# Zip download for manual extraction
# download_path = "OnlyFans DataScraper.zip"
# with open(download_path, "wb") as f:
# f.write(downloaded.content)
with ZipFile(content, "r") as zipObject:
listOfFileNames = zipObject.namelist()
root = listOfFileNames[0]
zipObject.extractall()
all_files = []
for root, subdirs, files in os.walk(root):
x = [os.path.join(root, x) for x in files]
all_files.extend(x)
for filepath in all_files:
filepath = os.path.normpath(filepath)
parents = Path(filepath).parents
p = Path(filepath).parts[0]
renamed = os.path.relpath(filepath, p)
folder = os.path.dirname(renamed)
if folder:
os.makedirs(os.path.dirname(renamed), exist_ok=True)
q = shutil.move(filepath, renamed)
print
print(f"Script has been updated, exiting in 5 seconds")
time.sleep(5)

1 comment on commit 5db4e16

@crek1423
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

superb

Please sign in to comment.