From 323620b1689f1fff9dd110f765f31569a83aedb4 Mon Sep 17 00:00:00 2001 From: datawhores Date: Thu, 25 Jan 2024 11:41:32 -0600 Subject: [PATCH] fix manual mode --- ofscraper/classes/placeholder.py | 2 +- ofscraper/commands/manual.py | 5 +++-- ofscraper/commands/scraper.py | 2 +- ofscraper/{filters => }/models/retriver.py | 0 ofscraper/{filters => }/models/selector.py | 6 ++++-- ofscraper/prompts/prompt_groups/model.py | 2 +- ofscraper/utils/context/run_async.py | 5 ++++- pyproject.toml | 2 +- 8 files changed, 15 insertions(+), 9 deletions(-) rename ofscraper/{filters => }/models/retriver.py (100%) rename ofscraper/{filters => }/models/selector.py (96%) diff --git a/ofscraper/classes/placeholder.py b/ofscraper/classes/placeholder.py index a93e9e87d..cff098400 100644 --- a/ofscraper/classes/placeholder.py +++ b/ofscraper/classes/placeholder.py @@ -6,7 +6,7 @@ import arrow import ofscraper.api.me as me -import ofscraper.filters.models.selector as selector +import ofscraper.models.selector as selector import ofscraper.utils.args.read as read_args import ofscraper.utils.cache as cache import ofscraper.utils.config.custom as custom_ diff --git a/ofscraper/commands/manual.py b/ofscraper/commands/manual.py index 0851334fc..8e5bfe98c 100644 --- a/ofscraper/commands/manual.py +++ b/ofscraper/commands/manual.py @@ -11,6 +11,7 @@ import ofscraper.classes.sessionbuilder as sessionbuilder import ofscraper.db.operations as operations import ofscraper.download.download as download +import ofscraper.models.selector as selector import ofscraper.utils.args.read as read_args import ofscraper.utils.args.write as write_args import ofscraper.utils.constants as constants @@ -21,11 +22,11 @@ def manual_download(urls=None): log = logging.getLogger("shared") network.check_cdm() media_dict = get_media_from_urls(urls) - log.debug(f"Media dict length {len(list(media_dict.values()))}") + log.debug(f"Number of values from media dict {len(list(media_dict.values()))}") args = read_args.retriveArgs() args.dupe = True write_args.setArgs(args) - + selector.all_subs_helper() for value in media_dict.values(): if len(value) == 0: continue diff --git a/ofscraper/commands/scraper.py b/ofscraper/commands/scraper.py index cef7cb5d9..b506714f5 100755 --- a/ofscraper/commands/scraper.py +++ b/ofscraper/commands/scraper.py @@ -33,7 +33,7 @@ import ofscraper.db.operations as operations import ofscraper.download.download as download import ofscraper.filters.media.main as filters -import ofscraper.filters.models.selector as userselector +import ofscraper.models.selector as userselector import ofscraper.prompts.prompts as prompts import ofscraper.utils.actions as actions import ofscraper.utils.args.areas as areas diff --git a/ofscraper/filters/models/retriver.py b/ofscraper/models/retriver.py similarity index 100% rename from ofscraper/filters/models/retriver.py rename to ofscraper/models/retriver.py diff --git a/ofscraper/filters/models/selector.py b/ofscraper/models/selector.py similarity index 96% rename from ofscraper/filters/models/selector.py rename to ofscraper/models/selector.py index fc881743a..852d41332 100644 --- a/ofscraper/filters/models/selector.py +++ b/ofscraper/models/selector.py @@ -5,9 +5,9 @@ import ofscraper.filters.models.flags as flags import ofscraper.filters.models.other as other import ofscraper.filters.models.price as price -import ofscraper.filters.models.retriver as retriver import ofscraper.filters.models.sort as sort import ofscraper.filters.models.subtype as subtype +import ofscraper.models.retriver as retriver import ofscraper.prompts.prompts as prompts import ofscraper.utils.args.read as read_args import ofscraper.utils.args.write as write_args @@ -19,7 +19,9 @@ def get_model_fromParsed(name): - modelObjs = list(filter(lambda x: x.name == name, PARSED_SUBS)) + if not ALL_SUBS: + all_subs_helper() + modelObjs = list(filter(lambda x: x.name == name, ALL_SUBS)) return modelObjs[0] if len(modelObjs) > 0 else None diff --git a/ofscraper/prompts/prompt_groups/model.py b/ofscraper/prompts/prompt_groups/model.py index 982b235a4..f3c1357fe 100644 --- a/ofscraper/prompts/prompt_groups/model.py +++ b/ofscraper/prompts/prompt_groups/model.py @@ -17,7 +17,7 @@ from prompt_toolkit.shortcuts import prompt as prompt from rich.console import Console -import ofscraper.filters.models.selector as userselector +import ofscraper.models.selector as userselector import ofscraper.prompts.model_helpers as modelHelpers import ofscraper.prompts.prompt_strings as prompt_strings import ofscraper.prompts.prompt_validators as prompt_validators diff --git a/ofscraper/utils/context/run_async.py b/ofscraper/utils/context/run_async.py index feb486a78..068e30baf 100644 --- a/ofscraper/utils/context/run_async.py +++ b/ofscraper/utils/context/run_async.py @@ -5,7 +5,10 @@ def run(coro): def inner(*args, **kwargs): - loop = asyncio.new_event_loop() + try: + loop = asyncio.get_running_loop() + except RuntimeError: + loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) try: tasks = loop.run_until_complete(coro(*args, **kwargs)) diff --git a/pyproject.toml b/pyproject.toml index adcd56019..fea4545da 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,7 +6,7 @@ authors = ["datawhores "] readme = "README.md" [tool.poetry.dependencies] -python = ">=3.11,<=3.13" +python = ">=3.11,<3.13" httpx = { extras = ["http2"], version = "^0.23.3" }