The app functions module provides core functionality for initializing the TorBox Media Center application, managing folders, fetching downloads, and checking versions.
Initialization functions
initializeFolders
Initializes the mount path folders for the media center. Creates the main mount directory and, if not in raw mode, creates separate movies and series subdirectories. Clears any existing content in these folders.
This function takes no parameters.
This function does not return a value.
Behavior:
- Creates the main
MOUNT_PATH directory
- In non-raw mode, also creates
movies and series subdirectories
- Removes all existing files and directories from these folders
Example:
from functions.appFunctions import initializeFolders
initializeFolders()
# Folders are now initialized and empty
bootUp
Performs the initial boot sequence for the application. Logs configuration details, checks for version updates, and initializes folders.
Always returns True on successful boot.
Logs the following configuration:
- Mount method (FUSE or STRM)
- Mount path location
- TorBox API key (for verification)
- Mount refresh time in hours
- Version update warnings if a new version is available
Example:
from functions.appFunctions import bootUp
bootUp()
# Logs configuration and initializes the application
Download management
getAllUserDownloadsFresh
def getAllUserDownloadsFresh()
Fetches all user downloads fresh from the TorBox API across all download types (torrents, usenet, webdl). Clears the local database before fetching to ensure fresh data.
A list of all downloads across all types. Each download is a dictionary containing file metadata, download links, and media information.
Process:
- Iterates through all download types (torrents, usenet, webdl)
- Clears the database for each type
- Fetches downloads from the TorBox API
- Combines all downloads into a single list
Example:
from functions.appFunctions import getAllUserDownloadsFresh
all_downloads = getAllUserDownloadsFresh()
print(f"Total downloads: {len(all_downloads)}")
getAllUserDownloads
def getAllUserDownloads()
Retrieves all user downloads from the local database cache. This is faster than getAllUserDownloadsFresh as it reads from the local database instead of making API calls.
A list of all cached downloads across all types.
Example:
from functions.appFunctions import getAllUserDownloads
all_downloads = getAllUserDownloads()
for download in all_downloads:
print(download.get('metadata_title'))
Configuration getters
getMountMethod
Returns the currently configured mount method.
The mount method: either "fuse" or "strm".
Example:
from functions.appFunctions import getMountMethod
method = getMountMethod()
print(f"Using mount method: {method}")
getMountPath
Returns the configured mount path where media files are exposed.
The absolute path to the mount directory.
Example:
from functions.appFunctions import getMountPath
path = getMountPath()
print(f"Media mounted at: {path}")
getMountRefreshTime
def getMountRefreshTime()
Returns the configured mount refresh time in hours.
The refresh interval in hours.
Example:
from functions.appFunctions import getMountRefreshTime
refresh_time = getMountRefreshTime()
print(f"Mount refreshes every {refresh_time} hours")
Version management
getLatestVersion
Fetches the latest version tag from the TorBox Media Center GitHub repository.
The latest version tag (e.g., "v1.2.3"), or None if an error occurs.
Process:
- Queries the GitHub repository for all tags
- Filters out tag references
- Sorts tags by semantic version
- Returns the latest tag
Error handling:
Returns None and logs an error if:
- Unable to connect to GitHub
- Invalid repository URL
- No tags found
Example:
from functions.appFunctions import getLatestVersion
from library.app import getCurrentVersion
latest = getLatestVersion()
current = getCurrentVersion()
if latest and latest != current:
print(f"Update available: {current} → {latest}")
else:
print("You're running the latest version")