Skip to main content
The Search class manages file searches across the Soulseek network, handling search queries, results, and wishlist functionality.

Overview

The Search module provides:
  • Global file searches across the network
  • User-specific searches
  • Room-specific searches
  • Wishlist functionality for automatic searches
  • Search result filtering and sorting
  • Search history management

Search Class

Initialization

Core Search Methods

Performs a search across the network.
str
required
The search query string
str
required
Search mode: “global”, “buddies”, “rooms”, or “user”
list
List of specific users to search (for “user” mode)
str
Room name to search in (for “rooms” mode)
int
Unique search token for tracking results

add_allowed_token()

Adds a token to the allowed list for receiving results.
int
required
Search token to allow

remove_allowed_token()

Removes a token from the allowed list.
int
required
Search token to remove

Search Result Methods

process_search_term()

Processes and normalizes a search term.
str
required
Raw search query
str
Normalized search term
set
Set of words to exclude (words starting with ”-“)

append_search_results()

Appends new results to an existing search.
int
required
Search token
str
required
Username who provided the results
list
required
List of file results

get_search_results()

Retrieves results for a search token.
int
required
Search token
dict
Dictionary mapping usernames to their results

Wishlist Methods

add_wish()

Adds a search term to the wishlist for automatic searches.
str
required
Search term to add to wishlist

remove_wish()

Removes a search term from the wishlist.
str
required
Search term to remove

get_wishlist()

Retrieves the current wishlist.
list
List of wishlist search terms

is_wish()

Checks if a search term is in the wishlist.
bool
True if term is in wishlist

Search History

add_search_history()

Adds a search term to the history.
str
required
Search term to add to history

get_search_history()

Retrieves recent search history.
list
List of recent search terms

Search Modes

Searches all users connected to the network:
Searches only users on your buddy list:
Searches users in a specific chat room:
Searches specific users:

Events

The Search module emits events for search lifecycle:

Result Filtering

Filter by File Type

Filter by File Size

Complete Example

Best Practices

  • Use specific search terms to reduce irrelevant results
  • Leverage exclusion words (prefix with ”-”) to filter unwanted content
  • Use wishlist for ongoing searches of rare content
  • Store search tokens to correlate results with queries
  • Filter results by file attributes (size, bitrate, format) client-side
  • Limit simultaneous searches to avoid server throttling
  • Use room or buddy searches for more targeted results