ofscraper-community 3.16.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ofscraper/__main__.py +9 -0
- ofscraper/__version__.py +13 -0
- ofscraper/classes/labels.py +40 -0
- ofscraper/classes/of/base.py +54 -0
- ofscraper/classes/of/media.py +742 -0
- ofscraper/classes/of/models.py +230 -0
- ofscraper/classes/of/posts.py +347 -0
- ofscraper/classes/placeholder.py +556 -0
- ofscraper/classes/table/app.py +854 -0
- ofscraper/classes/table/compose.py +188 -0
- ofscraper/classes/table/const.py +1 -0
- ofscraper/classes/table/css.py +178 -0
- ofscraper/classes/table/fields/boolfield.py +36 -0
- ofscraper/classes/table/fields/datefield.py +94 -0
- ofscraper/classes/table/fields/downloadfield.py +65 -0
- ofscraper/classes/table/fields/mediafield.py +60 -0
- ofscraper/classes/table/fields/numfield.py +60 -0
- ofscraper/classes/table/fields/pricefield.py +47 -0
- ofscraper/classes/table/fields/responsefield.py +100 -0
- ofscraper/classes/table/fields/selectfield.py +69 -0
- ofscraper/classes/table/fields/sizefield.py +32 -0
- ofscraper/classes/table/fields/textsearch.py +45 -0
- ofscraper/classes/table/fields/timefield.py +129 -0
- ofscraper/classes/table/inputs/filterinput.py +16 -0
- ofscraper/classes/table/inputs/intergerinput.py +13 -0
- ofscraper/classes/table/inputs/strinput.py +10 -0
- ofscraper/classes/table/sections/sidebar.py +10 -0
- ofscraper/classes/table/sections/table.py +139 -0
- ofscraper/classes/table/sections/table_console.py +6 -0
- ofscraper/classes/table/utils/lock.py +2 -0
- ofscraper/classes/table/utils/names.py +30 -0
- ofscraper/commands/check.py +874 -0
- ofscraper/commands/db.py +370 -0
- ofscraper/commands/manual.py +322 -0
- ofscraper/commands/metadata/consumer.py +93 -0
- ofscraper/commands/metadata/desc.py +1 -0
- ofscraper/commands/metadata/manager.py +228 -0
- ofscraper/commands/metadata/metadata.py +295 -0
- ofscraper/commands/recover_collisions.py +156 -0
- ofscraper/commands/scraper/actions/download/download.py +147 -0
- ofscraper/commands/scraper/actions/download/managers/alt_download.py +580 -0
- ofscraper/commands/scraper/actions/download/managers/downloadmanager.py +283 -0
- ofscraper/commands/scraper/actions/download/managers/fansly_stream_download.py +311 -0
- ofscraper/commands/scraper/actions/download/managers/main_download.py +427 -0
- ofscraper/commands/scraper/actions/download/run.py +140 -0
- ofscraper/commands/scraper/actions/download/utils/chunk.py +29 -0
- ofscraper/commands/scraper/actions/download/utils/desc.py +1 -0
- ofscraper/commands/scraper/actions/download/utils/keyhelpers.py +242 -0
- ofscraper/commands/scraper/actions/download/utils/leaky.py +20 -0
- ofscraper/commands/scraper/actions/download/utils/retries.py +40 -0
- ofscraper/commands/scraper/actions/download/utils/text.py +32 -0
- ofscraper/commands/scraper/actions/like/like.py +180 -0
- ofscraper/commands/scraper/actions/utils/buffer.py +0 -0
- ofscraper/commands/scraper/actions/utils/chunk.py +14 -0
- ofscraper/commands/scraper/actions/utils/general.py +51 -0
- ofscraper/commands/scraper/actions/utils/globals.py +80 -0
- ofscraper/commands/scraper/actions/utils/log.py +64 -0
- ofscraper/commands/scraper/actions/utils/params.py +14 -0
- ofscraper/commands/scraper/actions/utils/paths.py +252 -0
- ofscraper/commands/scraper/actions/utils/progress/convert.py +14 -0
- ofscraper/commands/scraper/actions/utils/progress/update.py +6 -0
- ofscraper/commands/scraper/actions/utils/retries.py +31 -0
- ofscraper/commands/scraper/actions/utils/threads.py +52 -0
- ofscraper/commands/scraper/actions/utils/workers.py +8 -0
- ofscraper/commands/scraper/scraper.py +326 -0
- ofscraper/commands/scraper/utils/daemon.py +0 -0
- ofscraper/commands/scraper/utils/jobqueue.py +2 -0
- ofscraper/commands/scraper/utils/prepare.py +59 -0
- ofscraper/commands/scraper/utils/print.py +4 -0
- ofscraper/commands/scraper/utils/schedule.py +86 -0
- ofscraper/commands/utils/command.py +142 -0
- ofscraper/commands/utils/scrape_context.py +42 -0
- ofscraper/commands/utils/strings.py +25 -0
- ofscraper/data/api/archive.py +362 -0
- ofscraper/data/api/common/after.py +26 -0
- ofscraper/data/api/common/cache/read.py +20 -0
- ofscraper/data/api/common/cache/write.py +40 -0
- ofscraper/data/api/common/check.py +27 -0
- ofscraper/data/api/common/logs/logs.py +44 -0
- ofscraper/data/api/common/logs/strings.py +14 -0
- ofscraper/data/api/common/old.py +36 -0
- ofscraper/data/api/common/page.py +38 -0
- ofscraper/data/api/common/timeline.py +39 -0
- ofscraper/data/api/highlights.py +311 -0
- ofscraper/data/api/init.py +99 -0
- ofscraper/data/api/labels.py +464 -0
- ofscraper/data/api/me.py +82 -0
- ofscraper/data/api/messages.py +430 -0
- ofscraper/data/api/paid.py +318 -0
- ofscraper/data/api/pinned.py +149 -0
- ofscraper/data/api/profile.py +173 -0
- ofscraper/data/api/streams.py +355 -0
- ofscraper/data/api/subscriptions/common.py +48 -0
- ofscraper/data/api/subscriptions/individual.py +81 -0
- ofscraper/data/api/subscriptions/lists.py +272 -0
- ofscraper/data/api/subscriptions/subscriptions.py +237 -0
- ofscraper/data/api/tasks.py +67 -0
- ofscraper/data/api/timeline.py +411 -0
- ofscraper/data/models/utils/retriver.py +117 -0
- ofscraper/data/posts/post.py +660 -0
- ofscraper/data/posts/scrape_paid.py +141 -0
- ofscraper/db/__init__.py +1 -0
- ofscraper/db/backup.py +103 -0
- ofscraper/db/difference.py +37 -0
- ofscraper/db/merge.py +358 -0
- ofscraper/db/operations.py +105 -0
- ofscraper/db/operations_/empty.py +62 -0
- ofscraper/db/operations_/labels.py +253 -0
- ofscraper/db/operations_/media.py +801 -0
- ofscraper/db/operations_/messages.py +308 -0
- ofscraper/db/operations_/others.py +312 -0
- ofscraper/db/operations_/posts.py +456 -0
- ofscraper/db/operations_/profile.py +219 -0
- ofscraper/db/operations_/stories.py +227 -0
- ofscraper/db/operations_/wrapper.py +131 -0
- ofscraper/db/transition.py +280 -0
- ofscraper/db/utils/convert.py +7 -0
- ofscraper/db/utils/rebuild.py +55 -0
- ofscraper/filters/media/filters.py +352 -0
- ofscraper/filters/models/date.py +88 -0
- ofscraper/filters/models/flags.py +76 -0
- ofscraper/filters/models/other.py +35 -0
- ofscraper/filters/models/price.py +185 -0
- ofscraper/filters/models/sort.py +55 -0
- ofscraper/filters/models/subtype.py +31 -0
- ofscraper/filters/models/utils/logs.py +13 -0
- ofscraper/main/close/exit.py +34 -0
- ofscraper/main/close/final/final.py +23 -0
- ofscraper/main/close/final/final_log.py +43 -0
- ofscraper/main/open/load.py +62 -0
- ofscraper/main/open/run.py +32 -0
- ofscraper/managers/manager.py +135 -0
- ofscraper/managers/model.py +580 -0
- ofscraper/managers/postcollection.py +330 -0
- ofscraper/managers/profile.py +129 -0
- ofscraper/managers/sessionHandler.py +60 -0
- ofscraper/managers/sessionmanager/cert.py +152 -0
- ofscraper/managers/sessionmanager/ofsession.py +316 -0
- ofscraper/managers/sessionmanager/sessionmanager.py +772 -0
- ofscraper/managers/sessionmanager/sleepers.py +127 -0
- ofscraper/managers/stats.py +588 -0
- ofscraper/managers/utils/state.py +275 -0
- ofscraper/prompts/keybindings.py +38 -0
- ofscraper/prompts/promptConvert.py +272 -0
- ofscraper/prompts/prompt_groups/actions.py +41 -0
- ofscraper/prompts/prompt_groups/area.py +301 -0
- ofscraper/prompts/prompt_groups/auth.py +275 -0
- ofscraper/prompts/prompt_groups/config.py +854 -0
- ofscraper/prompts/prompt_groups/menu.py +46 -0
- ofscraper/prompts/prompt_groups/merge.py +129 -0
- ofscraper/prompts/prompt_groups/misc.py +18 -0
- ofscraper/prompts/prompt_groups/model.py +451 -0
- ofscraper/prompts/prompt_groups/profile.py +141 -0
- ofscraper/prompts/prompt_strings.py +273 -0
- ofscraper/prompts/prompt_validators.py +362 -0
- ofscraper/prompts/prompts.py +22 -0
- ofscraper/prompts/utils/model_helpers.py +85 -0
- ofscraper/prompts/utils/prompt_helpers.py +284 -0
- ofscraper/scripts/after_download_action_script.py +105 -0
- ofscraper/scripts/after_download_script.py +73 -0
- ofscraper/scripts/after_like_action_script.py +101 -0
- ofscraper/scripts/final_script.py +85 -0
- ofscraper/scripts/naming_script.py +101 -0
- ofscraper/scripts/skip_download_script.py +95 -0
- ofscraper/sites/__init__.py +88 -0
- ofscraper/sites/fansly/__init__.py +0 -0
- ofscraper/sites/fansly/api.py +208 -0
- ofscraper/sites/fansly/auth.py +200 -0
- ofscraper/sites/fansly/constants.py +27 -0
- ofscraper/sites/fansly/headers.py +58 -0
- ofscraper/sites/fansly/live.py +702 -0
- ofscraper/sites/fansly/live_api.py +73 -0
- ofscraper/sites/fansly/live_chat.py +174 -0
- ofscraper/sites/fansly/me.py +73 -0
- ofscraper/sites/fansly/normalize.py +355 -0
- ofscraper/sites/fansly/scrape.py +83 -0
- ofscraper/sites/fansly/signing.py +60 -0
- ofscraper/sites/fansly/video.py +346 -0
- ofscraper/utils/__init__.py +1 -0
- ofscraper/utils/actions.py +129 -0
- ofscraper/utils/ads.py +2 -0
- ofscraper/utils/args/accessors/actions.py +0 -0
- ofscraper/utils/args/accessors/areas.py +72 -0
- ofscraper/utils/args/accessors/output.py +9 -0
- ofscraper/utils/args/accessors/quality.py +22 -0
- ofscraper/utils/args/accessors/read.py +18 -0
- ofscraper/utils/args/accessors/time.py +53 -0
- ofscraper/utils/args/callbacks/arguments/post.py +6 -0
- ofscraper/utils/args/callbacks/arguments/username.py +9 -0
- ofscraper/utils/args/callbacks/parse/choice.py +14 -0
- ofscraper/utils/args/callbacks/parse/file.py +22 -0
- ofscraper/utils/args/callbacks/parse/string.py +38 -0
- ofscraper/utils/args/callbacks/parse/username.py +6 -0
- ofscraper/utils/args/globals.py +1 -0
- ofscraper/utils/args/helpers/hide_args.py +15 -0
- ofscraper/utils/args/main.py +70 -0
- ofscraper/utils/args/mutators/before.py +11 -0
- ofscraper/utils/args/mutators/user.py +29 -0
- ofscraper/utils/args/mutators/write.py +10 -0
- ofscraper/utils/args/parse/arguments/advanced_processing.py +33 -0
- ofscraper/utils/args/parse/arguments/advanced_program.py +73 -0
- ofscraper/utils/args/parse/arguments/advanced_user_filter.py +129 -0
- ofscraper/utils/args/parse/arguments/automatic.py +68 -0
- ofscraper/utils/args/parse/arguments/check.py +133 -0
- ofscraper/utils/args/parse/arguments/download.py +48 -0
- ofscraper/utils/args/parse/arguments/file.py +25 -0
- ofscraper/utils/args/parse/arguments/logging.py +50 -0
- ofscraper/utils/args/parse/arguments/media_content.py +166 -0
- ofscraper/utils/args/parse/arguments/metadata_filters.py +90 -0
- ofscraper/utils/args/parse/arguments/post_content.py +346 -0
- ofscraper/utils/args/parse/arguments/program.py +48 -0
- ofscraper/utils/args/parse/arguments/scripts.py +53 -0
- ofscraper/utils/args/parse/arguments/shared.py +1 -0
- ofscraper/utils/args/parse/arguments/user_list.py +120 -0
- ofscraper/utils/args/parse/arguments/user_select.py +81 -0
- ofscraper/utils/args/parse/arguments/user_sort.py +30 -0
- ofscraper/utils/args/parse/arguments/utils/date.py +13 -0
- ofscraper/utils/args/parse/arguments/utils/retry.py +22 -0
- ofscraper/utils/args/parse/commands/db.py +13 -0
- ofscraper/utils/args/parse/commands/main.py +19 -0
- ofscraper/utils/args/parse/commands/manual.py +9 -0
- ofscraper/utils/args/parse/commands/message.py +9 -0
- ofscraper/utils/args/parse/commands/metadata.py +11 -0
- ofscraper/utils/args/parse/commands/paid.py +9 -0
- ofscraper/utils/args/parse/commands/post.py +10 -0
- ofscraper/utils/args/parse/commands/story.py +9 -0
- ofscraper/utils/args/parse/group_bundles/advanced_common.py +17 -0
- ofscraper/utils/args/parse/group_bundles/check.py +89 -0
- ofscraper/utils/args/parse/group_bundles/common.py +23 -0
- ofscraper/utils/args/parse/group_bundles/db.py +111 -0
- ofscraper/utils/args/parse/group_bundles/main.py +35 -0
- ofscraper/utils/args/parse/group_bundles/manual.py +26 -0
- ofscraper/utils/args/parse/group_bundles/message_check.py +33 -0
- ofscraper/utils/args/parse/group_bundles/metadata.py +155 -0
- ofscraper/utils/args/parse/group_bundles/paid_check.py +32 -0
- ofscraper/utils/args/parse/group_bundles/post_check.py +33 -0
- ofscraper/utils/args/parse/group_bundles/story_check.py +35 -0
- ofscraper/utils/args/parse/group_bundles/utils/check.py +16 -0
- ofscraper/utils/args/parse/groups/advanced_processing.py +17 -0
- ofscraper/utils/args/parse/groups/advanced_program.py +29 -0
- ofscraper/utils/args/parse/groups/advanced_user_filter.py +43 -0
- ofscraper/utils/args/parse/groups/automatic.py +31 -0
- ofscraper/utils/args/parse/groups/check_content.py +28 -0
- ofscraper/utils/args/parse/groups/download.py +22 -0
- ofscraper/utils/args/parse/groups/file.py +26 -0
- ofscraper/utils/args/parse/groups/logging.py +24 -0
- ofscraper/utils/args/parse/groups/media_filter.py +47 -0
- ofscraper/utils/args/parse/groups/post_filter.py +49 -0
- ofscraper/utils/args/parse/groups/program.py +25 -0
- ofscraper/utils/args/parse/groups/scripts.py +23 -0
- ofscraper/utils/args/parse/groups/user_list.py +35 -0
- ofscraper/utils/args/parse/groups/user_select.py +26 -0
- ofscraper/utils/args/parse/groups/user_sort.py +16 -0
- ofscraper/utils/args/types/arrow.py +49 -0
- ofscraper/utils/args/types/choice.py +139 -0
- ofscraper/utils/async_cached_property.py +66 -0
- ofscraper/utils/auth/data.py +67 -0
- ofscraper/utils/auth/file.py +113 -0
- ofscraper/utils/auth/make.py +59 -0
- ofscraper/utils/auth/request.py +370 -0
- ofscraper/utils/auth/schema.py +34 -0
- ofscraper/utils/auth/utils/dict.py +43 -0
- ofscraper/utils/auth/utils/error.py +77 -0
- ofscraper/utils/auth/utils/prompt.py +42 -0
- ofscraper/utils/auth/utils/warning/check.py +7 -0
- ofscraper/utils/auth/utils/warning/print.py +39 -0
- ofscraper/utils/auth/utils/warning/warning.py +14 -0
- ofscraper/utils/cache/cache.py +82 -0
- ofscraper/utils/cache/profile.py +32 -0
- ofscraper/utils/checkers.py +46 -0
- ofscraper/utils/config/config.py +61 -0
- ofscraper/utils/config/data.py +738 -0
- ofscraper/utils/config/file.py +86 -0
- ofscraper/utils/config/menu.py +89 -0
- ofscraper/utils/config/schema.py +124 -0
- ofscraper/utils/config/utils/context.py +43 -0
- ofscraper/utils/config/utils/wrapper.py +16 -0
- ofscraper/utils/console.py +88 -0
- ofscraper/utils/const.py +34 -0
- ofscraper/utils/context/exit.py +113 -0
- ofscraper/utils/context/run_async.py +73 -0
- ofscraper/utils/context/stdout.py +30 -0
- ofscraper/utils/dates.py +107 -0
- ofscraper/utils/encoding.py +18 -0
- ofscraper/utils/hash.py +58 -0
- ofscraper/utils/live/classes/progress.py +109 -0
- ofscraper/utils/live/classes/task.py +53 -0
- ofscraper/utils/live/classes/transfercol.py +41 -0
- ofscraper/utils/live/clear.py +109 -0
- ofscraper/utils/live/empty.py +21 -0
- ofscraper/utils/live/groups.py +86 -0
- ofscraper/utils/live/live.py +39 -0
- ofscraper/utils/live/panel.py +5 -0
- ofscraper/utils/live/progress.py +106 -0
- ofscraper/utils/live/screens.py +284 -0
- ofscraper/utils/live/tasks.py +47 -0
- ofscraper/utils/live/updater.py +109 -0
- ofscraper/utils/logs/classes/classes.py +132 -0
- ofscraper/utils/logs/classes/handlers/discord.py +133 -0
- ofscraper/utils/logs/classes/handlers/text.py +23 -0
- ofscraper/utils/logs/close.py +32 -0
- ofscraper/utils/logs/logger.py +49 -0
- ofscraper/utils/logs/logs.py +132 -0
- ofscraper/utils/logs/other.py +56 -0
- ofscraper/utils/logs/stdout.py +51 -0
- ofscraper/utils/logs/utils/level.py +68 -0
- ofscraper/utils/logs/utils/sensitive.py +62 -0
- ofscraper/utils/logs/utils/trace.py +9 -0
- ofscraper/utils/markup.py +14 -0
- ofscraper/utils/me.py +25 -0
- ofscraper/utils/menu.py +140 -0
- ofscraper/utils/merge.py +44 -0
- ofscraper/utils/of_env/__init__.py +124 -0
- ofscraper/utils/of_env/load.py +97 -0
- ofscraper/utils/of_env/of_env.py +98 -0
- ofscraper/utils/of_env/values/action/download.py +126 -0
- ofscraper/utils/of_env/values/action/like.py +36 -0
- ofscraper/utils/of_env/values/action/metadata.py +31 -0
- ofscraper/utils/of_env/values/date.py +22 -0
- ofscraper/utils/of_env/values/dynamic.py +49 -0
- ofscraper/utils/of_env/values/general.py +122 -0
- ofscraper/utils/of_env/values/list.py +50 -0
- ofscraper/utils/of_env/values/live.py +56 -0
- ofscraper/utils/of_env/values/logger.py +30 -0
- ofscraper/utils/of_env/values/main.py +344 -0
- ofscraper/utils/of_env/values/path/bytes.py +38 -0
- ofscraper/utils/of_env/values/path/files.py +44 -0
- ofscraper/utils/of_env/values/path/general.py +34 -0
- ofscraper/utils/of_env/values/path/length.py +38 -0
- ofscraper/utils/of_env/values/prompts.py +87 -0
- ofscraper/utils/of_env/values/req/anon.py +21 -0
- ofscraper/utils/of_env/values/req/api.py +110 -0
- ofscraper/utils/of_env/values/req/auth.py +10 -0
- ofscraper/utils/of_env/values/req/cdm.py +42 -0
- ofscraper/utils/of_env/values/req/discord.py +42 -0
- ofscraper/utils/of_env/values/req/git.py +26 -0
- ofscraper/utils/of_env/values/req/mpd.py +57 -0
- ofscraper/utils/of_env/values/req/ratelimit.py +329 -0
- ofscraper/utils/of_env/values/req/req.py +209 -0
- ofscraper/utils/of_env/values/system.py +53 -0
- ofscraper/utils/of_env/values/test/test_constants.py +7355 -0
- ofscraper/utils/of_env/values/time.py +71 -0
- ofscraper/utils/of_env/values/url/dynamic.py +61 -0
- ofscraper/utils/of_env/values/url/other_url.py +33 -0
- ofscraper/utils/of_env/values/url/url.py +254 -0
- ofscraper/utils/paths/common.py +131 -0
- ofscraper/utils/paths/db.py +18 -0
- ofscraper/utils/paths/manage.py +89 -0
- ofscraper/utils/paths/paths.py +217 -0
- ofscraper/utils/profiles/data.py +50 -0
- ofscraper/utils/profiles/manage.py +77 -0
- ofscraper/utils/profiles/tools.py +49 -0
- ofscraper/utils/sems.py +1 -0
- ofscraper/utils/separate.py +36 -0
- ofscraper/utils/settings.py +257 -0
- ofscraper/utils/string.py +62 -0
- ofscraper/utils/system/ffmpeg.py +180 -0
- ofscraper/utils/system/ffprobe.py +124 -0
- ofscraper/utils/system/free.py +25 -0
- ofscraper/utils/system/network.py +71 -0
- ofscraper/utils/system/priority.py +19 -0
- ofscraper/utils/system/speed.py +51 -0
- ofscraper/utils/system/subprocess.py +195 -0
- ofscraper/utils/system/system.py +62 -0
- ofscraper/utils/text.py +69 -0
- ofscraper_community-3.16.2.dist-info/METADATA +245 -0
- ofscraper_community-3.16.2.dist-info/RECORD +370 -0
- ofscraper_community-3.16.2.dist-info/WHEEL +4 -0
- ofscraper_community-3.16.2.dist-info/entry_points.txt +2 -0
- ofscraper_community-3.16.2.dist-info/licenses/LICENSE +21 -0
ofscraper/__main__.py
ADDED
ofscraper/__version__.py
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
import importlib.metadata
|
|
3
|
+
|
|
4
|
+
# The version is now read from the installed package's metadata
|
|
5
|
+
try:
|
|
6
|
+
# The distribution is published as 'ofscraper-community'; the import
|
|
7
|
+
# package and the command are still 'ofscraper'. Keep the name a literal:
|
|
8
|
+
# PyInstaller looks for it to bundle the metadata into the binaries.
|
|
9
|
+
__version__ = importlib.metadata.version("ofscraper-community")
|
|
10
|
+
except importlib.metadata.PackageNotFoundError:
|
|
11
|
+
# This is a fallback for cases where the package is not installed at all,
|
|
12
|
+
# or you are in a situation where metadata is not available.
|
|
13
|
+
__version__ = "0.0.0" # A sensible fallback
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import ofscraper.classes.of.posts as posts_
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class Label:
|
|
5
|
+
def __init__(self, label, model_id, username):
|
|
6
|
+
self._label_id = label.get("id")
|
|
7
|
+
self._name = label.get("name")
|
|
8
|
+
self._type = label.get("type")
|
|
9
|
+
self._posts = list(
|
|
10
|
+
map(
|
|
11
|
+
lambda x: posts_.Post(x, model_id, username, label=self._name),
|
|
12
|
+
label.get("posts"),
|
|
13
|
+
)
|
|
14
|
+
)
|
|
15
|
+
self._model_id = int(model_id)
|
|
16
|
+
self._username = username
|
|
17
|
+
|
|
18
|
+
@property
|
|
19
|
+
def model_id(self):
|
|
20
|
+
return self._model_id
|
|
21
|
+
|
|
22
|
+
@property
|
|
23
|
+
def username(self):
|
|
24
|
+
return self._username
|
|
25
|
+
|
|
26
|
+
@property
|
|
27
|
+
def label_id(self):
|
|
28
|
+
return self._label_id
|
|
29
|
+
|
|
30
|
+
@property
|
|
31
|
+
def name(self):
|
|
32
|
+
return self._name
|
|
33
|
+
|
|
34
|
+
@property
|
|
35
|
+
def type(self):
|
|
36
|
+
return self._type
|
|
37
|
+
|
|
38
|
+
@property
|
|
39
|
+
def posts(self):
|
|
40
|
+
return self._posts
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import importlib
|
|
2
|
+
import re
|
|
3
|
+
|
|
4
|
+
from bs4 import BeautifulSoup
|
|
5
|
+
|
|
6
|
+
import ofscraper.utils.settings as settings
|
|
7
|
+
|
|
8
|
+
html_parser = "lxml" if importlib.util.find_spec("lxml") else "html.parser"
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class base:
|
|
12
|
+
def __init__(self):
|
|
13
|
+
None
|
|
14
|
+
|
|
15
|
+
def text_trunicate(self, text):
|
|
16
|
+
text = str(text)
|
|
17
|
+
if text is None:
|
|
18
|
+
return "None"
|
|
19
|
+
if len(text) == 0:
|
|
20
|
+
return text
|
|
21
|
+
length = int(settings.get_settings().text_length)
|
|
22
|
+
if length == 0:
|
|
23
|
+
return text
|
|
24
|
+
elif settings.get_settings().text_type == "letter":
|
|
25
|
+
return f"{''.join(list(text)[:length])}"
|
|
26
|
+
else:
|
|
27
|
+
# text has usually been through file_cleanup already, which swaps
|
|
28
|
+
# spaces for space_replacer, so words are split on that. If the
|
|
29
|
+
# original text already contained that character (e.g. "_" in a
|
|
30
|
+
# caption with "_" as the replacer), it also counts as a word
|
|
31
|
+
# break; the original spaces can't be told apart at this point.
|
|
32
|
+
sep = settings.get_settings().space_replacer or " "
|
|
33
|
+
if sep not in text:
|
|
34
|
+
sep = " "
|
|
35
|
+
words = [x for x in text.split(sep) if x]
|
|
36
|
+
text = sep.join(words[:length])
|
|
37
|
+
text = re.sub(" +$", "", text)
|
|
38
|
+
return text
|
|
39
|
+
|
|
40
|
+
def file_cleanup(self, text):
|
|
41
|
+
text = str(text)
|
|
42
|
+
text = re.sub("<[^>]*>", "", text)
|
|
43
|
+
text = re.sub(r'[\n<>:"/\|?*:;]+', "", text)
|
|
44
|
+
text = re.sub("-+", "_", text)
|
|
45
|
+
text = re.sub(" +", " ", text)
|
|
46
|
+
text = re.sub(" ", settings.get_settings().space_replacer, text)
|
|
47
|
+
return text
|
|
48
|
+
|
|
49
|
+
def db_cleanup(self, string):
|
|
50
|
+
string = string or ""
|
|
51
|
+
string = re.sub("<[^>]*>", "", string)
|
|
52
|
+
string = " ".join(string.split())
|
|
53
|
+
string = BeautifulSoup(string, html_parser).get_text()
|
|
54
|
+
return string
|