Skip to content

Commit

Permalink
Fixed ExpiredAt Error
Browse files Browse the repository at this point in the history
OnlyFans updated their API again :)))))
  • Loading branch information
SecretShell committed Dec 23, 2019
1 parent 7abf981 commit d646e46
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 18 deletions.
20 changes: 10 additions & 10 deletions StartDatascraper.py
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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']
Expand Down
30 changes: 22 additions & 8 deletions modules/onlyfans.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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))
Expand All @@ -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:
Expand Down

0 comments on commit d646e46

Please sign in to comment.