Пример #1
0
 def add_blacklist_user(self, new_user):
     if new_user != '' and ' ' not in new_user:
         if any(new_user.lower() == name.lower()
                for name in self.user_blacklist):
             Message.name_in_list(self)
         else:
             self.user_blacklist.append(new_user)
             self.blacklist_users_listview.addItem(new_user)
             self.blacklist_users_listview.sortItems()
     else:
         Message.not_valid_name(self)
Пример #2
0
 def add_subreddit(self, new_sub):
     """Adds the subreddit entered into the dialog to the subreddit list"""
     if new_sub != '' and ' ' not in new_sub:
         if any(new_sub.lower() == name.lower()
                for name in self.subreddit_watchlist):
             Message.name_in_list(self)
         else:
             self.subreddit_watchlist.append(new_sub)
             self.sub_watchlist_listview.addItem(new_sub)
             self.sub_watchlist_listview.sortItems()
     else:
         Message.not_valid_name(self)
Пример #3
0
    def accept(self):
        if self._restore_defaults:
            ret = Message.restore_defaults_warning(self)
        else:
            ret = True

        if ret:
            self.save_settings()
            self.save_display_settings()
            self.save_dialog_geom()
            super().accept()
 def open_item_download_folder(self, position):
     """Opens the selected items download folder."""
     selected_object = self.object_list[position]
     path = self.get_download_folder_path(selected_object)
     try:
         SystemUtil.open_in_system(path)
     except AttributeError:
         self.logger.error(
             'Failed to open reddit object download folder: Attribute Error',
             extra={
                 'folder_path': path,
                 'reddit_object': self.current_object.json
             },
             exc_info=True)
     except FileNotFoundError:
         self.logger.error(
             'Failed to open reddit object download folder: Folder cannot be found',
             extra={
                 'folder_path': path,
                 'reddit_object': self.current_object.json
             },
             exc_info=True)
         Message.no_download_folder(self, self.object_type)
Пример #5
0
 def validate_subreddits(self):
     """
     Validates each subreddit in the subreddit list, creates a UserFinderSubreddit object if valid, extracts the
     subreddits top posts based on the user finder settings, then adds the subreddit to the valid subreddit list.
     """
     for item in self.subreddit_list:
         try:
             subreddit = self._r.subreddit(item)
             sub = UserFinderSubreddit(
                 None, item, None,
                 self.settings_manager.user_finder_post_limit, True,
                 self.settings_manager.download_videos,
                 self.settings_manager.download_images,
                 self.settings_manager.nsfw_filter, None,
                 self.settings_manager.name_downloads_by, None)
             sub.new_submissions = [
                 x for x in self.extract_subreddit_posts(subreddit)
                 if self.filter_post(x)
             ]
             sub.consolidate_posts()
             self.valid_subreddit_list.append(sub)
         except (prawcore.exceptions.Redirect, prawcore.exceptions.NotFound,
                 AttributeError):
             Message.subreddit_not_valid(self, item)
Пример #6
0
 def closeEvent(self, QCloseEvent):
     if self.running:
         if Message.downloader_running_warning(self):
             try:
                 self.thread.terminate()
             except AttributeError:
                 pass
             try:
                 self.user_finder_download_thread.terminate()
             except AttributeError:
                 pass
             self.close_finder()
         else:
             QCloseEvent.ignore()
     else:
         self.close_finder()
Пример #7
0
 def remove_invalid_subreddits(self, sub):
     """If a subreddit in the list is found to not be valid, this removes the subreddit if the user wants to do so"""
     if Message.subreddit_not_valid(self, sub):
         current_row = self.subreddit_watchlist.index(sub)
         self.subreddit_watchlist.remove(sub)
         self.sub_watchlist_listview.takeItem(current_row)