aliparlakci / bulk-downloader-for-reddit

Downloads and archives content from reddit
https://pypi.org/project/bdfr
GNU General Public License v3.0
2.26k stars 211 forks source link

[BUG] Subreddits with only integers crash the program when specified in --opts #946

Open ymgenesis opened 5 months ago

ymgenesis commented 5 months ago

Description

When a subreddit which has only integers is specified in --opts yaml.yaml under subreddit:, the program crashes with: TypeError: expected string or bytes-like object, got 'int'

Both subreddits 1776 & 18_19 cause the crash. Wrapping them in double quotes seemed to fix the crash.

Command

bdfr download ./ --opts subreddits.yaml

subreddits.yaml:

verbose: true
authenticate: true
search_existing: true
no_dupes: true
sort: top
limit: 20
time: week
subreddit:
  - 1776

Environment (please complete the following information)

Logs

[2024-02-19 16:52:53,464 - bdfr.connector - DEBUG] - Disabling the following modules: 
[2024-02-19 16:52:53,464 - bdfr.connector - Level 9] - Created download filter
[2024-02-19 16:52:53,464 - bdfr.connector - Level 9] - Created time filter
[2024-02-19 16:52:53,465 - bdfr.connector - Level 9] - Created sort filter
[2024-02-19 16:52:53,468 - bdfr.connector - Level 9] - Create file name formatter
[2024-02-19 16:52:53,470 - bdfr.connector - DEBUG] - Using authenticated Reddit instance
[2024-02-19 16:52:53,471 - bdfr.connector - Level 9] - Created site authenticator
[2024-02-19 16:52:53,472 - root - ERROR] - Downloader exited unexpectedly - BDFR Downloader v2.7.0
Traceback (most recent call last):
  File "/Users/me/Documents/GitHub/bulk-downloader-for-reddit/bdfr/__main__.py", line 122, in cli_download
    reddit_downloader = RedditDownloader(config, [stream])
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/me/Documents/GitHub/bulk-downloader-for-reddit/bdfr/downloader.py", line 42, in __init__
    super().__init__(args, logging_handlers)
  File "/Users/me/Documents/GitHub/bulk-downloader-for-reddit/bdfr/connector.py", line 66, in __init__
    self.reddit_lists = self.retrieve_reddit_lists()
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/me/Documents/GitHub/bulk-downloader-for-reddit/bdfr/connector.py", line 188, in retrieve_reddit_lists
    master_list.extend(self.get_subreddits())
                       ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/me/Documents/GitHub/bulk-downloader-for-reddit/bdfr/connector.py", line 289, in get_subreddits
    for reddit in self.split_args_input(self.args.subreddit) | subscribed_subreddits:
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/me/Documents/GitHub/bulk-downloader-for-reddit/bdfr/connector.py", line 272, in split_args_input
    results = re.split(split_pattern, entry)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Library/Frameworks/Python.framework/Versions/3.11/lib/python3.11/re/__init__.py", line 206, in split
    return _compile(pattern, flags).split(string, maxsplit)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: expected string or bytes-like object, got 'int'