diff --git a/StartDatascraper.py b/StartDatascraper.py index 6eb0143c3..229349d0f 100644 --- a/StartDatascraper.py +++ b/StartDatascraper.py @@ -1,16 +1,16 @@ import os path = os.path.dirname(os.path.realpath(__file__)) os.chdir(path) -import inspect -import traceback -import logging -import json -import timeit -import modules.helpers as helpers -import modules.bbwchan as bbwchan -import modules.four_chan as four_chan -import modules.justforfans as justforfans import modules.onlyfans as onlyfans +import modules.justforfans as justforfans +import modules.four_chan as four_chan +import modules.bbwchan as bbwchan +import modules.helpers as helpers +import timeit +import json +import logging +import traceback +import inspect # Configure logging to the console and file system at INFO level and above logging.basicConfig(handlers=[logging.FileHandler('application.log', 'w', 'utf-8')], level=logging.INFO, @@ -70,7 +70,7 @@ me_api = session[3] array = x.get_subscriptions(session[0], app_token, session[2]) if me_api["isPerformer"]: - array = [{"user": {"username":me_api["username"]}}] + array + array = [{"username": me_api["username"]}] + array array = x.format_options(array) elif site_name == "justforfans": auth_id = json_auth['phpsessid'] diff --git a/modules/onlyfans.py b/modules/onlyfans.py index 1af7bad67..38abb1310 100644 --- a/modules/onlyfans.py +++ b/modules/onlyfans.py @@ -7,7 +7,7 @@ from itertools import chain import multiprocessing from multiprocessing.dummy import Pool as ThreadPool -from datetime import datetime +from datetime import datetime, timezone import logging import inspect import math @@ -83,11 +83,13 @@ def link_check(session, app_token, username): temp_user_id2[0] = False temp_user_id2[1] = y["error"]["message"] return temp_user_id2 - + if y["subscribedBy"]: subbed = True elif y["subscribedOn"]: subbed = True + elif y["subscribedIsExpiredNow"] == False: + subbed = True else: subbed = False if not subbed: @@ -375,13 +377,17 @@ def create_session(user_agent, auth_id, auth_hash, app_token, sess="None"): else: print("Welcome "+response["name"]) option_string = "username or profile link" - return [session, option_string, response["subscribesCount"], response] + r = session.get( + "https://onlyfans.com/api2/v2/subscriptions/count/all?app-token="+app_token) + r = json.loads(r.text) + subscriber_count = r["subscriptions"]["all"] + return [session, option_string, subscriber_count, response] return [False, response] def get_subscriptions(session, app_token, subscriber_count): - link = "https://onlyfans.com/api2/v2/subscriptions/subscribes?limit=99&offset=0&type=active&app-token="+app_token + link = "https://onlyfans.com/api2/v2/subscriptions/subscribes?limit=99&offset=0&app-token="+app_token pool = ThreadPool() ceil = math.ceil(subscriber_count / 99) a = list(range(ceil)) @@ -395,24 +401,32 @@ def multi(link, session): results = pool.starmap(multi, product( offset_array, [session])) results = list(chain(*results)) - results = list(reversed(results)) + results.sort(key=lambda x: x["subscribedByData"]['expiredAt']) if any("error" in result for result in results): print("Invalid App Token") return [] else: - return results + results2 = [] + for result in results: + now = datetime.utcnow() + result_date = result["subscribedByData"]["expiredAt"] + result_date = datetime.fromisoformat( + result_date).replace(tzinfo=None) + if result_date > now: + results2.append(result) + return results2 def format_options(array): string = "" names = [] - array = [{"user": {"username": "All"}}]+array + array = [{"username": "All"}]+array name_count = len(array) if name_count > 1: count = 0 for x in array: - name = x["user"]["username"] + name = x["username"] string += str(count)+" = "+name names.append(name) if count+1 != name_count: