ThioJoe / YT-Spammer-Purge

Allows you easily scan for and delete scam comments using several methods.
GNU General Public License v3.0
4.58k stars 389 forks source link

[Bug]: NoneType AttributeError during authentication #676

Closed divinewind420 closed 2 years ago

divinewind420 commented 2 years ago

Duplicate Issues

What happened?

Run a scan manually and works; using config file and get error.

SpamPurgeConfig.ini

---------- Config file for YT Spammer Purge program ----------

INSTRUCTIONS:

• Lines with a hashtag are just comments / instructions

• If you set a setting in here, the program will not Ask you to enter/confirm when your run it

• If you leave the value as 'Ask', the program will Ask you for it as usual

• Some settings might not be necessary depending on which modes you select

#

• For 100% automatic usage of program, enter all values (or at least all for your scanning/filtering modes)

• NOTE: Human confirmation is required for most settings to actually remove comments

- If comment removal is automated, comments are marked as "held for review" and hidden

#

MORE NOTES:

• Current filter modes that support automated comment removal:

- Scanning for exact channel ID(s)

- Auto Smart-Mode

• If scanning someone elses channel, you can report spammers, but while in Auto-Smart Mode only

USING MULTIPLE CONFIG FILES:

• You can create additional config files through the same menu used to create the initial config file

- Then you can choose which config to use when starting the program

• You can also make another config by just copying one and renaming it, adding a number such as: "SpamPurgeConfig2.ini"

[config-meta]

---------------------------------------------------------------

# If 'True', program starts with all config settings immediately
# If 'False', program starts with default settings immediately, ignoring any config settings
# If 'Ask', program Asks to use config settings at start. And if you have multiple configs, will ask which to use
# NOTE: This setting only applies to the primary config file ("SpamPurgeConfig.ini"), not any other configs you make
# Default = Ask  --  Possible Values: True | False | Ask

use_this_config = True

# A short description to show for this config file when asking which config file to choose
#    > Examples: "Scan last 3 videos with auto smart", "Scan last video for [some phrase]"
# This ONLY matters if you have multiple config files (such as "SpamPurgeConfig2.ini", "SpamPurgeConfig3.ini", etc)
# Possible Values:  Anything

this_config_description = My Custom Config

# Set the full OR relative folder path where to look for secondary config files (not including file name itself). Ensure write permissions to path.
# Windows Users: Do NOT begin the path with a slash, or the location will be relative to the root of the disk!
# NOTE: If you change this from the default path, you MUST keep at least the main (not numbered) config in the same folder as the program, so it knows where to look for the others
#       > If you keep the default value, you can also put the main config file into there with the secondary configs. 
# Default = configs  --  Example Values:  any/relative/path/  |  C:\Users\wherever\  |  /home/user/configs

configs_path = configs

[general]

---------------------------------------------------------------

# Enter your channel ID, to bypass initial user confirmation - Example: 'UCK8sQmJBp8GCxrOtXWBpyEA'
# Default = Ask  --  Possible Values: Ask | UCx123-BlahBlahExampleID

your_channel_id = UCqI2LWjmQ2EbGjB1BNOR1Vg

# Enables or disables silent checking of newer version when program runs. Only displays message if update is available
# This will not display errors if it cannot get version. To see any issues, use program's manual update check
# NOTE: This DOES NOT download the updates automatically, it is only for auto-CHECKING for updates
# Default = True -- Possible Values: True | False

auto_check_update = True

# Choose whether to be notified only of stable releases, or all new releases (including pre-release / beta versions)
# Only matters when auto_check_update is enabled
# Default = All  --  Possible Values: All | Stable

release_channel = All

# Skips asking for user confirmation yes/no that the entered video link/ID is correct
# Setting is ignored if video_to_scan is set, which will make it skip anyway
# Default = False -- Possible Values: True | False

skip_confirm_video = True

# Overrides 'Not Your Channel' mode to allow holding comments for review in both Smart filter modes, even if you are not the video uploader
# Only set to True if you have moderator permissions on the channel you're scanning, or you'll just get errors
# Default = False -- Possible Values: True | False

moderator_mode = False

# When a full scanning & removal run completes, sets whether to automatically close the program after short delay, rather than prompting to return to main menu
# Useful if intending to run the program fully autonomously. This setting only applies after a scanning run, not necessarily for every single "return to main menu" prompt 
# Default = False -- Possible Values: True | False

auto_close = True

# If your system does not support console color codes, set this to False to disable them from being used.
# If you see "� [0m� [0m" in your console, setting this to False will help.
# Default = True -- Possible Values: True | False

colors_enabled = True

[scanning]

--------------------------------------------------------------------------------

# Scan Mode: Scan either a single video or your whole channel
# Default = Ask  --  Possible Values: Ask | ChosenVideos | RecentVideos | EntireChannel | CommunityPost | RecentCommunityPosts

scan_mode = RecentVideos

# Only necessary if scanning entire channel or a community post. Must be either 'Ask' or a number.
# Default = Ask  --  Possible Values: Ask | [number]

max_comments = Ask

# Video link(s) or video ID(s) to scan, in the specific videos scanning mode
# If scanning multiple videos, they must be comma separated
# Default = Ask  --  Possible Values: Ask | xyzVidIDExample

videos_to_scan = Ask

# The channel ID or channel link to scan in 'Recent Videos' mode. For your own channel, enter 'Mine'
# Default = Ask -- Posible Values: Ask | Mine | UCx123-BlahBlahExampleID

channel_to_scan = https://www.youtube.com/c/GamersNexus

# For Recent Video (and Recent Community Post) scanning modes, how many recent videos/posts to scan.
# For videos, up to 500 (the YouTube API Limit). For community posts, it varies by channel, but usually ~5-10 tops
# Default = Ask -- Possible Values: Ask | 1 - 500

recent_videos_amount = 2

[filtering]

--------------------------------------------------------------------------------

# Mode that determines what to scan
# Default = Ask  --  Possible Values: Ask | ID | Username | Text | NameAndText | AutoASCII | AutoSmart | SensitiveSmart

filter_mode = Ask

# Used for modes 'Username', 'Text' or 'NameAndText' - Determines what criteria to actually scan for
# Default = Ask  --  Possible Values: Ask | characters | strings | regex

filter_subMode = Ask

---- Filter Mode Specific Settings ----

# For Filter Mode 'ID' -  Enter comma separated list of IDs or channel links
# Default = Ask  --  Possible Values: Ask | UCx123-BlahBlahExampleID

channel_ids_to_filter = Ask

# For Filter Mode 'AutoASCII' - Choose sensitivity
# 1 = Allow Standard + Extended ASCII,  2 = Standard ASCII Only,  3 = NUKE Mode (only letters/numbers/spaces)
# Default = Ask  --  Possible Values: Ask | 1 | 2 | 3

autoASCII_sensitivity = Ask

---- Filter Sub-Mode Specific Settings ----

# Put individual characters to scan for, with no spaces or commas or anything - Example: 👆☑➡
# Default = Ask  --  Possible Values: Ask | [characters]

characters_to_filter = Ask

# Comma separated list of strings - Example:  whatsapp, something else, investment
# Default = Ask  --  Possible Values: Ask | [strings]

strings_to_filter = Ask

# A regex expression to filter - Example: [^\x00-\xFF]
# Default = Ask  --  Possible Values: Ask | [regex]

regex_to_filter = Ask

[autosmart-customization]

--------------------------------------------------------------------------------

# In Auto-Smart and Sensitive-Smart modes, sets whether it will flag comments that contain nothing but a youtube video/channel link
# I consider this spam but some have disagreed, so I've made it optional
# Default = True -- Possible Values: True | False

detect_link_spam = True

# In Auto-Smart and Sensitive-Smart modes, sets whether to flag comments by users with usernames such as "100k subs without any videos"
# These accounts usually just spam and are typically against YouTube's guidelines, but some apparently don't consider it spam
# Default = False  --  Possible: True | False

detect_sub_challenge_spam = True

# In Auto-Smart and Sensitive-Smart modes, whether to check for 'spam threads' where many fake bots reply to eachother to promote scams
# Default = True  --  Possible: True | False

detect_spam_threads = True

[advanced-filtering]

--------------------------------------------------------------------------------

# This will check for multiple similar comments by the same author in the specified filtering modes.
# If a commenter has already been marked as a match, all their comments will be removed and won't show here
# For multiple, must be comma separated list. To disable duplicate scanning altogether, enter only 'None'
# NOTE: Currently does not work for Community Posts and Entire Channel Mode
# Default = AutoSmart, SensitiveSmart  --  Possible Values:  None | ID | Username | Text | NameAndText | AutoASCII | AutoSmart | SensitiveSmart

duplicate_check_modes = AutoSmart, SensitiveSmart

# The minimum number of duplicate/similar comments a single user must leave before they are flagged / counted as a match
# The threshold is 'greater than or equal to' the number entered
# NOTE 1: At this time, if the threshold is reached for a user, all of their comments will be flagged, even if all of them aren't necessarily similar
# NOTE 2: Duplicates are measured per-video. Comments on different videos are not compared
# Default = 8  --  Possible Values: [Any integer above 2]

minimum_duplicates = 8

# Minimum number of characters a comment must have to be considered when checking duplicates
# The threshold is 'greater than or equal to' the number entered
# Note: In some special circumstances (such as a comment containing a domain name), this number may be overridden

minimum_duplicate_length = 14

# Determines at least how similar two comments must be to be considered a duplicate
# 1.0 is 100% the same, 0.5 is 50% similar, and so on. Read more here: https://en.wikipedia.org/wiki/Levenshtein_distance
# If you enter 0.0, it will simply flag all comments from users who left more comments than the minimum_duplicate threshold
# Using values of 0.0 or 1.0 will be many times faster, because the computation is much simpler
# Default = 0.9 | Possible Values: 0.00 to 1.00

levenshtein_distance = 0.9

# This will check if a comment was posted previously by someone else in the specified filtering mode.
# If a commenter has already been marked as a match, all their comments will be removed and won't show here
# For multiple, must be comma separated list. To disable duplicate scanning altogether, enter only 'None'
# NOTE: Currently does not work for Community Posts and Entire Channel Mode
# Default = AutoSmart, SensitiveSmart  --  Possible Values:  None | ID | Username | Text | NameAndText | AutoASCII | AutoSmart | SensitiveSmart

stolen_comments_check_modes = SensitiveSmart

# The minimum length a comment must be before it is checked against other comments for similarity.
# SETTING THIS VALUE TOO LOW IS NOT RECOMMENED - Common messages like "Hi", "first" will be flagged
# The threshold is 'greater than or equal to' the number entered.
# Default = 25  --  Possible Values: [Any integer above 0] 

stolen_minimum_text_length = 25

# Whether to also detect similar comments when scanning for stolen comments
# Uses the same 'levenshtein_distance' value as the duplicate comments setting
# WARNING: When you get into the 1000s of comments, this will take a large amount of time
# Default = False -- Possible Values: True | False

fuzzy_stolen_comment_detection = False

[removal]

--------------------------------------------------------------------------------

# If 'False', behaves as normal. If 'True', simply skips deletion altogether and exits program, Good if you just want to collect logs.
# See 'delete_without_reviewing' option for actual deletion behavior
# NOTE: This also skips the 'exclude' option
# Default = False  --  Possible Values: True | False

skip_deletion = False

# If True, program will NOT require approval before deleting comments, and will just do so immediately (effective only for certain settings, see instructions at top)
# If 'skip_deletion' setting is 'True', this setting makes no difference and no comments will be deleted
# Default = False  --  Possible Values: True | False

delete_without_reviewing = False

# NOTE: Only other possible option is 'False' - Only change this if going fully automated, or you never want to ban users
#   > The YouTube API doesn't allow banning when using "held for review" option, which currently is the only automated deletion option for this program
# Leaving as 'Ask' asks to ban like normal. Setting it to 'True' will make NO DIFFERENCE and may only produce errors
# Default = Ask  --  Possible Values: Ask | False

enable_ban = Ask

# Whether to remove all comments by a user, not just the exact comments that were matched
# Will remove any comments by the author across all videos scanned
# Note: Also does not work when reporting
# Default = Ask  --  Possible Values: Ask | True | False    

remove_all_author_comments = Ask

# Choose the default method of comment removal the program will use. 'rejected' means normal removal/deletion. 'heldForReview' moves comment to Held For Review section. 'reportSpam' means just report for spam.
# Note 1: If delete_without_renewing is true, this removal_type must be either reportSpam or heldForReview
# Note 2: You can only ban users while removing their comment using 'rejected'
# Note 3: If in 'Not Your Channel' mode, this setting has no effect, and you will always only report spam
# Default = rejected -- Possible Values: rejected | heldForReview | reportSpam

removal_type = reportSpam

# Whether to whitelist any authors that were excluded from deletion (using 'exclude' or 'only' options)
# Default = Ask  --  Possible Values: Ask | True | False

whitelist_excluded = Ask

# Allows you to skip the process of checking that each comment is deleted. Good to reduce API quota usage, and time spent using the app.
# Because checking each comment individually costs 1 API unit, and there is a daily API quota of 10,000, if you're deleting thousands of comments, checking for success can quickly eat up your entire quota
# Default = True  --  Possible Values: True | False

check_deletion_success = True

[logging]

--------------------------------------------------------------------------------

# Enable log file generation: 'True' or 'False'
# Default = Ask  --  Possible Values: Ask | True | False

enable_logging = True

# Set the full OR relative folder path where log files will go (not including file name itself). Ensure write permissions to path.
# Note for windows users: Do NOT begin the path with a slash, or the location will be relative to the root of the disk!
# Default = logs  --  Example Values:  any/relative/path/  |  C:\Users\wherever\  |  /home/user/logfiles

log_path = logs

# Set whether to create log files as plain text, or Rich Text Format with colors
# Default = plaintext  |  Possible Values: rtf | plaintext

log_mode = plaintext

# Allows you to ALSO create a json version of the logged match data (in addition to normal log file)
# Note: If enable_logging is False, that also disables json logging regardless of this setting
# Default = False  --  Possible Values: True | False

json_log = False

# Sets the encoding method to be used in the json file, if you want to change it for some reason
# Just be sure to pick one that supports all unicode characters
# Default = utf-8  --  Possible Values: Theoretically any python supported encoding found here: https://docs.python.org/3/library/codecs.html#standard-encodings

json_encoding = utf-8

# Whether to add extra information about each comment to the json log file. Currently: Video Uploader's Name, Video Title
# Default = True  --  Possible Values: True | False

json_extra_data = True

# Whether to log all comments scanned, whether flagged as spam or not. Flagged comments will have a label in the json object
# Default = False -- Possible Values: True | False

json_log_all_comments = False

# Whether to also fetch profile pictures for matched commeters when in json logging mode, and the video uploader's too
# Images will be stored in the log_path, then in a folder with the same naming scheme (date/time) as the log accompanying log file
# Each profile picture file will be named as the channel ID of the respective user + .jpg
# To enable, set the resolution of the image ('default' = 88x88, 'medium' = 240x240, 'high' = 800x800)
# Default = False  --  Possible Values: False | default | medium | high

json_profile_picture = False

[api]

--------------------------------------------------------------------------------

# DO NOT change this unless Google has granted you an increased API quota
# You would have to specifically request this. Read more here: TJoe.io/api-limit-info

quota_limit = 10000

Don't change anything below here!

--------------------------------------------------------------------------------

[info] config_version = 31

Release version

2.16.0

Steps to reproduce

  1. Start program
  2. Create config
  3. Edit config
  4. Run program
  5. Get error

What platform are you seeing this problem on?

Windows (.exe file)

Relevant log output

Validating Config Settings...
-----------------------------------------------------

Traceback (most recent call last):
  File "D:\Users\Joe\Documents\GitHub ThioJoe\YouTube-Spammer-Purge\YTSpammerPurge.py", line 1668, in <module>
  File "D:\Users\Joe\Documents\GitHub ThioJoe\YouTube-Spammer-Purge\YTSpammerPurge.py", line 190, in main
  File "Scripts\validation.py", line 472, in validate_config_settings
  File "Scripts\validation.py", line 310, in validate_channel_to_scan
  File "Scripts\validation.py", line 139, in validate_channel_id
AttributeError: 'NoneType' object has no attribute 'search'
------------------------------------------------
Error Message: 'NoneType' object has no attribute 'search'

Unknown Error - Code: Z-3 occurred. If this keeps happening, consider posting a bug report
on the GitHub issues page, and include the above error info.
Short Link: TJoe.io/bug-report

 Press Enter to Exit...

Screenshots

No response

Firecul commented 2 years ago

It would have been nice if you hadn't pasted the whole config into there, you could simply have attached the file.

Firecul commented 2 years ago

If you change channel_to_scan = https://www.youtube.com/c/GamersNexus to https://www.youtube.com/channel/UChIs72whgZI9w6d6FhwGGHA or UChIs72whgZI9w6d6FhwGGHA it should work as intended, however, the crash is still something that should be worked on though as I'm not able to get it to work atm either

divinewind420 commented 2 years ago

Sorry about copy-pasting file. I tried using link https://www.youtube.com/channel/UChIs72whgZI9w6d6FhwGGHA & just as UChIs72whgZI9w6d6FhwGGHA but still got same Z-3 error.

ThioJoe commented 2 years ago

I suspect i know the issue, i'll have a look

ThioJoe commented 2 years ago

It wasn't caused by what I thought, but should be fixed in the new release 2.16.1