OF-Scraper icon indicating copy to clipboard operation
OF-Scraper copied to clipboard

Filtering is Broken

Open basketballhead6 opened this issue 5 months ago • 16 comments

Describe the bug

When using filters, this breaks the script. You do your filter criteria, return to the menu, choose who to scrape, hit enter and then the script does not progress any further.

This also seems to have an impact on swithcing profiles as well as when you get to the download section on a new profile, it just takes you back to the main menu.

To Reproduce

  1. Start Script
  2. Get to model selection screen
  3. Apply filter criteria
  4. Return to the model selection menu
  5. Choose who to scrape
  6. Hit enter

Expected behavior

Script will start to download the profiels of selected models.

Screenshots/Logs

Image

Config

{
    "main_profile": "main_profile",
    "metadata": "{configpath}/{profile}/.data/{model_username}_{model_id}",
    "discord": "",
    "file_options": {
        "save_location": "G:\\Personal\\Content-OF",
        "dir_format": "{model_username}/{responsetype}/{value}/{mediatype}/",
        "file_format": "{date}-{filename}.{ext}",
        "textlength": 0,
        "space_replacer": " ",
        "date": "YYYY-MM-DD",
        "text_type_default": "letter",
        "truncation_default": true
    },
    "download_options": {
        "filter": [
            "Images",
            "Audios",
            "Videos"
        ],
        "auto_resume": true,
        "system_free_min": 0,
        "max_post_count": 0
    },
    "binary_options": {
        "ffmpeg": "C:\\Users\\user\\.config\\ofscraper\\ffmpeg.exe"
    },
    "cdm_options": {
        "private-key": "C:\\Users\\user\\.config\\ofscraper\\private_keys\\private_key.pem",
        "client-id": "C:\\Users\\user\\.config\\ofscraper\\private_keys\\client_id.bin",
        "key-mode-default": "manual"
    },
    "performance_options": {
        "download_sems": 6,
        "download_limit": 0
    },
    "content_filter_options": {
        "block_ads": true,
        "file_size_max": 0,
        "file_size_min": 0,
        "length_max": null,
        "length_min": null
    },
    "advanced_options": {
        "dynamic-mode-default": "generic",
        "downloadbars": true,
        "cache-mode": "sqlite",
        "rotate_logs": false,
        "sanitize_text": false,
        "temp_dir": null,
        "remove_hash_match": false,
        "infinite_loop_action_mode": false,
        "enable_auto_after": true,
        "default_user_list": "main",
        "default_black_list": "",
        "logs_expire_time": null,
        "ssl_verify": false,
        "env_files": ""
    },
    "script_options": {
        "after_action_script": null,
        "post_script": null,
        "naming_script": null,
        "after_download_script": null,
        "skip_download_script": null
    },
    "responsetype": {
        "timeline": "posts",
        "message": "messages",
        "archived": "archived",
        "paid": "messages",
        "stories": "stories",
        "highlights": "stories",
        "profile": "profile",
        "pinned": "posts",
        "streams": "Streams"
    }
}

System Info

  • OS: Windows 11
  • Browser: Firefox
  • Version: 3.13.7
  • uv install

basketballhead6 avatar Jul 14 '25 06:07 basketballhead6

Can you send a log file

Trying your flow, but I can't trigger the script not running

datawhores avatar Jul 14 '25 11:07 datawhores

same here. the error that keeps popping is "UnicodeEncodeError: 'charmap' codec can't encode characters in position 142-143: character maps to *** You may need to add PYTHONIOENCODING=utf-8 to your environment *** "

toeblister avatar Jul 15 '25 02:07 toeblister

Can you send a log file

Trying your flow, but I can't trigger the script not running

@datawhores, the error I am having is the same as this comment:

same here. the error that keeps popping is "UnicodeEncodeError: 'charmap' codec can't encode characters in position 142-143: character maps to *** You may need to add PYTHONIOENCODING=utf-8 to your environment *** "

But to add a bit more context:

 2025-07-15 16:34:49:[menu.main_menu_action:82]  Traceback (most recent call last):
  File "C:\Users\{home_directory}\AppData\Roaming\uv\tools\ofscraper\Lib\site-packages\ofscraper\utils\menu.py", line 38, in main_menu_action
    result_main_prompt = prompts.main_prompt()
                         ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\{home_directory}\AppData\Roaming\uv\tools\ofscraper\Lib\site-packages\ofscraper\prompts\prompt_groups\menu.py", line 25, in main_prompt
    answer = promptClasses.getChecklistSelection(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\{home_directory}\AppData\Roaming\uv\tools\ofscraper\Lib\site-packages\ofscraper\prompts\promptConvert.py", line 47, in inner
    with prompt_live():
  File "C:\Python311\Lib\contextlib.py", line 137, in __enter__
    return next(self.gen)
           ^^^^^^^^^^^^^^
  File "C:\Users\{home_directory}\AppData\Roaming\uv\tools\ofscraper\Lib\site-packages\ofscraper\utils\live\empty.py", line 13, in prompt_live
    clear()
  File "C:\Users\{home_directory}\AppData\Roaming\uv\tools\ofscraper\Lib\site-packages\ofscraper\utils\live\clear.py", line 19, in clear
    console.get_shared_console().line(2)
  File "C:\Users\{home_directory}\AppData\Roaming\uv\tools\ofscraper\Lib\site-packages\rich\console.py", line 1137, in line
    self.print(NewLine(count))
  File "C:\Users\{home_directory}\AppData\Roaming\uv\tools\ofscraper\Lib\site-packages\rich\console.py", line 1673, in print
    with self:
  File "C:\Users\{home_directory}\AppData\Roaming\uv\tools\ofscraper\Lib\site-packages\rich\console.py", line 865, in __exit__
    self._exit_buffer()
  File "C:\Users\{home_directory}\AppData\Roaming\uv\tools\ofscraper\Lib\site-packages\rich\console.py", line 823, in _exit_buffer
    self._check_buffer()
  File "C:\Users\{home_directory}\AppData\Roaming\uv\tools\ofscraper\Lib\site-packages\rich\console.py", line 2046, in _check_buffer
    write("".join(batch))
  File "C:\Python311\Lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeEncodeError: 'charmap' codec can't encode character '\u280b' in position 4440: character maps to <undefined>
*** You may need to add PYTHONIOENCODING=utf-8 to your environment ***

basketballhead6 avatar Jul 15 '25 06:07 basketballhead6

Same issue here. I did changed PYTHONIOENCODING and chcp but no luck.

(ofscraper) PS [REDACTED]> $env:PYTHONIOENCODING
utf-8
(ofscraper) PS [REDACTED]> chcp
活动代码页: 65001
 2025-07-14 23:49:34:[level.inner:10]  Traceback (most recent call last):
  File "[REDACTED]\ofscraper\Lib\site-packages\rich\logging.py", line 170, in emit
    self.console.print(log_renderable)
  File "[REDACTED]\ofscraper\Lib\site-packages\rich\console.py", line 1673, in print
    with self:
  File "[REDACTED]\ofscraper\Lib\site-packages\rich\console.py", line 865, in __exit__
    self._exit_buffer()
  File "[REDACTED]\ofscraper\Lib\site-packages\rich\console.py", line 823, in _exit_buffer
    self._check_buffer()
  File "[REDACTED]\ofscraper\Lib\site-packages\rich\console.py", line 2046, in _check_buffer
    write("".join(batch))
UnicodeEncodeError: 'gbk' codec can't encode character '\u280b' in position 1818: illegal multibyte sequence
*** You may need to add PYTHONIOENCODING=utf-8 to your environment ***

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "[REDACTED]\ofscraper\Lib\site-packages\ofscraper\data\posts\post.py", line 184, in process_archived_posts
    archived_posts = await archive.get_archived_posts(
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "[REDACTED]\ofscraper\Lib\site-packages\ofscraper\data\api\archive.py", line 54, in get_archived_posts
    time_log(username, after)
  File "[REDACTED]\ofscraper\Lib\site-packages\ofscraper\data\api\archive.py", line 353, in time_log
    log.info(
  File "C:\Program Files\Python311\Lib\logging\__init__.py", line 1489, in info
    self._log(INFO, msg, args, **kwargs)
  File "C:\Program Files\Python311\Lib\logging\__init__.py", line 1634, in _log
    self.handle(record)
  File "C:\Program Files\Python311\Lib\logging\__init__.py", line 1644, in handle
    self.callHandlers(record)
  File "C:\Program Files\Python311\Lib\logging\__init__.py", line 1706, in callHandlers
    hdlr.handle(record)
  File "C:\Program Files\Python311\Lib\logging\__init__.py", line 978, in handle
    self.emit(record)
  File "[REDACTED]\ofscraper\Lib\site-packages\rich\logging.py", line 172, in emit
    self.handleError(record)
  File "C:\Program Files\Python311\Lib\logging\__init__.py", line 1031, in handleError
    sys.stderr.write('--- Logging error ---\n')
  File "[REDACTED]\ofscraper\Lib\site-packages\rich\file_proxy.py", line 43, in write
    with console:
  File "[REDACTED]\ofscraper\Lib\site-packages\rich\console.py", line 865, in __exit__
    self._exit_buffer()
  File "[REDACTED]\ofscraper\Lib\site-packages\rich\console.py", line 823, in _exit_buffer
    self._check_buffer()
  File "[REDACTED]\ofscraper\Lib\site-packages\rich\console.py", line 2046, in _check_buffer
    write("".join(batch))
UnicodeEncodeError: 'gbk' codec can't encode character '\u280b' in position 1818: illegal multibyte sequence
*** You may need to add PYTHONIOENCODING=utf-8 to your environment ***

I also did some tests with all release versions since 3.13, but non of them have a functioning filter. The error messages differs from version to version, so I can't tell where does the regression really came from. If OP want to reproduce this, the best call is to install a non-English Windows environment.

kotori2 avatar Jul 15 '25 07:07 kotori2

I am having the same issue. Windows 11 24H2 English US Python 3.11.6 (64-Bit) Browser: Firefox

I tried a few things with chcp 65001 and adding the User System Variable name PYTHONIOENCODING variable value: utf-8 to the system, no go.

I may have gotten it to work by creating a batch file with this as its contents:

@echo off
chcp 65001
set PYTHONIOENCODING=utf-8
python -X utf8 -m ofscraper

But, I'll have to do more testing tomorrow

4rockings avatar Jul 15 '25 22:07 4rockings

Same issue here. Ofscraper 3.13.8 Windows 11 Pro Build 22631 Python 3.11.5

I set my dynamic-mode-default to rafa based on prior instructions from upgrading to a recent version, and removed the custom URL piece. Not sure if that matters, but that was a recent change for me.

mbiasetti avatar Jul 26 '25 18:07 mbiasetti

For those still having this issue please test if the issue persists on older version of ofscraper.

cjb900 avatar Jul 27 '25 12:07 cjb900

For those still having this issue please test if the issue persists on older version of ofscraper.

Filtering works fine on older versions of the script. I updated from an older version to 13.3.7 and since updating, filtering is broken.

basketballhead6 avatar Jul 27 '25 12:07 basketballhead6

Is anyone able to mention a specific older version that works

Also @basketballhead6 did you use uv or pipx or something else or something else install

datawhores avatar Jul 27 '25 19:07 datawhores

Is anyone able to mention a specific older version that works

3.12.9 works for me

kotori2 avatar Jul 27 '25 19:07 kotori2

@kotori2 Have you tried installing the new version with pipx

datawhores avatar Jul 27 '25 19:07 datawhores

Is anyone able to mention a specific older version that works

Also @basketballhead6 did you use uv or pipx or something else or something else install

@datawhores I upgraded from 13.3 and filtering was fine in that version. I am also using the uv installation method.

basketballhead6 avatar Jul 27 '25 21:07 basketballhead6

@datawhores

Have you tried installing the new version with pipx

No I was installing with venv & pip install -U ofscraper==1.x.x If you are asking about versions, I've tested all pypi release versions from 3.13 to 3.13.7.

kotori2 avatar Jul 28 '25 17:07 kotori2

@datawhores can confirm this is still broken with the latest 3.13.8 release.

basketballhead6 avatar Aug 01 '25 05:08 basketballhead6

It seems to only affect creators with Emojis like this 🍒 in their name (Not username) to fail downloading. I tried another creator with ofscraper --action download --posts timeline,purchased,messages --username __REDACTED__ and it worked the other with emoji fails.

 2025-09-03 10:52:44:[logs.print_system_log:44]  Log Level: DEBUG
 2025-09-03 10:52:44:[logs.print_system_log:45]  version: 3.13.8
 2025-09-03 10:52:44:[logs.print_system_log:46]  Windows-10-10.0.26100-SP0
 2025-09-03 10:52:44:[logs.print_system_log:51]  python version 3.11.7

2025-09-03 10:57:24:[state.clear_scrape_queues:241]  Cleared all Scrape activity queues.
 2025-09-03 10:57:24:[model.prepare_scraper_activity:182]  Final selection contains 7 models. Queuing for all activities.
 2025-09-03 10:57:24:[state.set_queue:66]  Queued 7 users for the DOWNLOAD activity in their original order.
 2025-09-03 10:57:24:[command._data_helper:109]  Progress 1/7
 2025-09-03 10:57:24:[command._data_helper:112]  Data Retrival on __REDACTED__
 2025-09-03 10:57:24:[command._data_helper:114]  Avatar : __REDACTED__
 2025-09-03 10:57:24:[command._data_helper:121]  Getting [Purchased,Messages,Timeline,Profile] for __REDACTED__
Subscription Active: True
 2025-09-03 10:57:24:[backup.create_backup_transition:44]  creating a backup before transition
 2025-09-03 10:57:24:[backup.create_backup_transition:53]  transition backup created at C:\Users\{home_directory}\.config\ofscraper\main_profile\.data\__REDACTED__
 2025-09-03 10:57:25:[postcollection.__init__:32]  Initialized PostCollection for __REDACTED__
 2025-09-03 10:57:25:[sessionmanager.do_sleep:137]  SessionSleep: Waiting [2.00 seconds] due to SESSION_RATE_LIMIT min sleep value
 2025-09-03 10:57:28:[level.inner:10]  'charmap' codec can't encode character '\U0001f352' in position 142: character maps to <undefined>
*** You may need to add PYTHONIOENCODING=utf-8 to your environment ***
 2025-09-03 10:57:28:[level.inner:10]  Traceback (most recent call last):
  File "C:\Users\{home_directory}\pipx\venvs\ofscraper\Lib\site-packages\rich\logging.py", line 170, in emit
    self.console.print(log_renderable)
  File "C:\Users\{home_directory}\pipx\venvs\ofscraper\Lib\site-packages\rich\console.py", line 1673, in print
    with self:
  File "C:\Users\{home_directory}\pipx\venvs\ofscraper\Lib\site-packages\rich\console.py", line 865, in __exit__
    self._exit_buffer()
  File "C:\Users\{home_directory}\pipx\venvs\ofscraper\Lib\site-packages\rich\console.py", line 823, in _exit_buffer
    self._check_buffer()
  File "C:\Users\{home_directory}\pipx\venvs\ofscraper\Lib\site-packages\rich\console.py", line 2039, in _check_buffer
    write(text)
  File "C:\Python311\Lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
UnicodeEncodeError: 'charmap' codec can't encode character '\U0001f352' in position 142: character maps to <undefined>
*** You may need to add PYTHONIOENCODING=utf-8 to your environment ***

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\{home_directory}\pipx\venvs\ofscraper\Lib\site-packages\ofscraper\data\posts\post.py", line 259, in process_profile
    profile.print_profile_info(info)
  File "C:\Users\{home_directory}\pipx\venvs\ofscraper\Lib\site-packages\ofscraper\data\api\profile.py", line 142, in print_profile_info
    log.info(final_fmt.format(*info))
  File "C:\Python311\Lib\logging\__init__.py", line 1489, in info
    self._log(INFO, msg, args, **kwargs)
  File "C:\Python311\Lib\logging\__init__.py", line 1634, in _log
    self.handle(record)
  File "C:\Python311\Lib\logging\__init__.py", line 1644, in handle
    self.callHandlers(record)
  File "C:\Python311\Lib\logging\__init__.py", line 1706, in callHandlers
    hdlr.handle(record)
  File "C:\Python311\Lib\logging\__init__.py", line 978, in handle
    self.emit(record)
  File "C:\Users\{home_directory}\pipx\venvs\ofscraper\Lib\site-packages\rich\logging.py", line 172, in emit
    self.handleError(record)
  File "C:\Python311\Lib\logging\__init__.py", line 1031, in handleError
    sys.stderr.write('--- Logging error ---\n')
  File "C:\Users\{home_directory}\pipx\venvs\ofscraper\Lib\site-packages\rich\file_proxy.py", line 43, in write
    with console:
  File "C:\Users\{home_directory}\pipx\venvs\ofscraper\Lib\site-packages\rich\console.py", line 865, in __exit__
    self._exit_buffer()
  File "C:\Users\{home_directory}\pipx\venvs\ofscraper\Lib\site-packages\rich\console.py", line 823, in _exit_buffer
    self._check_buffer()
  File "C:\Users\{home_directory}\pipx\venvs\ofscraper\Lib\site-packages\rich\console.py", line 2039, in _check_buffer
    write(text)
  File "C:\Python311\Lib\encodings\cp1252.py", line 19, in encode
    return codecs.charmap_encode(input,self.errors,encoding_table)[0]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

KasumiDev avatar Sep 03 '25 09:09 KasumiDev

looks like it's still broken on 3.13.9

firestk avatar Oct 24 '25 01:10 firestk