Skip to content

Commit

Permalink
Support for multiple blacklists
Browse files Browse the repository at this point in the history
  • Loading branch information
UltimaHoarder committed Jul 19, 2021
1 parent 63ea203 commit 3493142
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 24 deletions.
6 changes: 4 additions & 2 deletions classes/make_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ def update_site_settings(options) -> dict:
new_options["filename_format"] = value.replace("{username}","{model_username}")
if "metadata_directory_format" == key:
new_options["metadata_directory_format"] = value.replace("{username}","{model_username}")
if "blacklist_name" == key:
new_options["blacklists"] = [value]
return new_options

class Supported(object):
Expand Down Expand Up @@ -172,8 +174,8 @@ def __init__(self, option={}) -> None:
'ignored_keywords', [])
self.ignore_type = option.get(
'ignore_type', "")
self.blacklist_name = option.get(
'blacklist_name', "")
self.blacklists = option.get(
'blacklists', "")
self.webhook = option.get(
'webhook', True)

Expand Down
44 changes: 22 additions & 22 deletions modules/onlyfans.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@
date_format = None
ignored_keywords = []
ignore_type = None
blacklist_name = None
blacklists = []
webhook = None
text_length = None


def assign_vars(json_auth: auth_details, config, site_settings, site_name):
global json_config, json_global_settings, json_settings, auto_media_choice, profile_directory, download_directory, metadata_directory, metadata_directory_format, delete_legacy_metadata, overwrite_files, date_format, file_directory_format, filename_format, ignored_keywords, ignore_type, blacklist_name, webhook, text_length
global json_config, json_global_settings, json_settings, auto_media_choice, profile_directory, download_directory, metadata_directory, metadata_directory_format, delete_legacy_metadata, overwrite_files, date_format, file_directory_format, filename_format, ignored_keywords, ignore_type, blacklists, webhook, text_length

json_config = config
json_global_settings = json_config["settings"]
Expand All @@ -75,7 +75,7 @@ def assign_vars(json_auth: auth_details, config, site_settings, site_name):
date_format = json_settings["date_format"]
ignored_keywords = json_settings["ignored_keywords"]
ignore_type = json_settings["ignore_type"]
blacklist_name = json_settings["blacklist_name"]
blacklists = json_settings["blacklists"]
webhook = json_settings["webhook"]
text_length = json_settings["text_length"]

Expand Down Expand Up @@ -1261,26 +1261,26 @@ async def manage_subscriptions(
authed: create_auth, auth_count=0, identifiers: list = [], refresh: bool = True
):
results = await authed.get_subscriptions(identifiers=identifiers, refresh=refresh)
if blacklist_name:
if blacklists:
response = await authed.get_lists()
if not response:
return [False, []]
new_results = [c for c in response if blacklist_name == c["name"]]
if new_results:
item = new_results[0]
list_users = item["users"]
if int(item["usersCount"]) > 2:
list_id = str(item["id"])
list_users = await authed.get_lists_users(list_id)
if list_users:
users = list_users
bl_ids = [x["username"] for x in users]
results2 = results.copy()
for result in results2:
identifier = result.username
if identifier in bl_ids:
print("Blacklisted: " + identifier)
results.remove(result)
if response:
for blacklist in blacklists:
new_results = [c for c in response if response and blacklist == c["name"]]
if new_results:
item = new_results[0]
list_users = item["users"]
if int(item["usersCount"]) > 2:
list_id = str(item["id"])
list_users = await authed.get_lists_users(list_id)
if list_users:
users = list_users
bl_ids = [x["username"] for x in users]
results2 = results.copy()
for result in results2:
identifier = result.username
if identifier in bl_ids:
print("Blacklisted: " + identifier)
results.remove(result)
results.sort(key=lambda x: x.subscribedByData["expiredAt"])
results.sort(key=lambda x: x.is_me(), reverse=True)
results2 = []
Expand Down

0 comments on commit 3493142

Please sign in to comment.