### Device Access - get_device() Source: https://context7.com/mmarquezs/my.jdownloader-api-python-library/llms.txt Explains how to retrieve a device instance to interact with a specific JDownloader installation. Shows methods to get a device by name, ID, or the first available device, and lists the available subsystems for device interaction. ```APIDOC ## Device Access - get_device() ### Description Retrieve a device instance to interact with a specific JDownloader installation. ### Method ```python import myjdapi jd = myjdapi.Myjdapi() jd.set_app_key("MyApp") jd.connect("email@example.com", "password") # Get device by name device = jd.get_device("HomeServer") # Or get device by ID device = jd.get_device(device_id="af9d03a21ddb917492dc1af8a6427f11") # Or get the first available device device = jd.get_device() # Device has access to all subsystems: # device.linkgrabber - Link collection management # device.downloads - Download list management # device.downloadcontroller - Download control (start/stop/pause) # device.accounts - Premium account management # device.config - JDownloader configuration # device.system - System controls # device.captcha - Captcha handling # device.toolbar - Toolbar status and controls # device.extensions - Extension management # device.dialogs - Dialog handling # device.reconnect - Internet reconnection # device.update - Update management ``` ``` -------------------------------- ### Install My.Jdownloader API Library Source: https://github.com/mmarquezs/my.jdownloader-api-python-library/blob/master/README.md Install the library using pip. This command fetches and installs the latest version from the Python Package Index. ```bash pip install myjdapi ``` -------------------------------- ### List and Manage Extensions Source: https://context7.com/mmarquezs/my.jdownloader-api-python-library/llms.txt Lists all available extensions with specified details and provides methods to check installation status, enable/disable, and install extensions. ```python extensions = device.extensions.list([ { "configInterface": True, "description": True, "enabled": True, "iconKey": True, "name": True, "pattern": "", # Filter pattern "installed": True } ]) for ext in extensions: print(f"Extension: {ext.get('name')}") print(f" Description: {ext.get('description')}") print(f" Enabled: {ext.get('enabled')}") print(f" Installed: {ext.get('installed')}") print(f" ID: {ext.get('id')}") ``` ```python ext_id = "org.jdownloader.extensions.extraction.ExtractionExtension" is_installed = device.extensions.isInstalled(ext_id) print(f"Extraction extension installed: {is_installed}") ``` ```python is_enabled = device.extensions.isEnabled(ext_id) print(f"Extraction extension enabled: {is_enabled}") ``` ```python device.extensions.setEnabled(ext_id, True) # Enable device.extensions.setEnabled(ext_id, False) # Disable ``` ```python device.extensions.install(ext_id) ``` -------------------------------- ### Control Downloads with DownloadController Source: https://context7.com/mmarquezs/my.jdownloader-api-python-library/llms.txt Manage the overall download process, including starting, stopping, pausing, and checking download speed and state. Use force_download to immediately start specific downloads. ```python # Start all downloads device.downloadcontroller.start_downloads() # Stop all downloads device.downloadcontroller.stop_downloads() # Pause/unpause downloads device.downloadcontroller.pause_downloads(True) # Pause device.downloadcontroller.pause_downloads(False) # Unpause # Get current download speed in bytes per second speed = device.downloadcontroller.get_speed_in_bytes() print(f"Current speed: {speed / 1024 / 1024:.2f} MB/s") # Get current download state # Returns: RUNNING, PAUSE, STOPPED, etc. state = device.downloadcontroller.get_current_state() print(f"Download state: {state}") # Force specific downloads to start immediately downloads = device.downloads.query_links() packages = device.downloads.query_packages() link_ids = [dl['uuid'] for dl in downloads[:3]] package_ids = [pkg['uuid'] for pkg in packages[:1]] device.downloadcontroller.force_download(link_ids, package_ids) ``` -------------------------------- ### Connect and Add Links to My.Jdownloader Device Source: https://github.com/mmarquezs/my.jdownloader-api-python-library/blob/master/README.rst This example demonstrates connecting to My.Jdownloader, retrieving devices, and adding links to a specific device's linkgrabber. Ensure you have valid credentials and a package name. ```python import myjdapi jd=myjdapi.myjdapi() jd.connect("example@example.com","password") jd.getDevices() jd.getDevice(name="DeviceName").linkgrabber.addLinks([{"autostart" : False, "links" : "https://mega.nz/#!xxxxxxxxxxxxxxxxxxxxxxxxxxxx,http://mediafire.com/download/xxxxxxxxxxxxxxxx/","packageName" : TEST" }]) ``` -------------------------------- ### Extensions - Manage JDownloader Extensions API Source: https://context7.com/mmarquezs/my.jdownloader-api-python-library/llms.txt List, install, enable/disable JDownloader extensions and plugins. ```APIDOC ## Extensions - Manage JDownloader Extensions API ### Description This API allows you to manage JDownloader extensions and plugins, including listing, installing, enabling, and disabling them. ### Methods - `list()`: Lists all installed extensions. - `install(url)`: Installs an extension from a given URL. - `enable(extension_id)`: Enables a disabled extension. - `disable(extension_id)`: Disables an enabled extension. ### Parameters for `list` #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example for `list` ```python extensions = device.extensions.list() ``` ### Response for `list` - **extensions** (array of objects) - A list of installed extensions, each with details like ID, name, enabled status, etc. ### Parameters for `install` #### Path Parameters None #### Query Parameters None #### Request Body - **url** (string) - Required - The URL from which to install the extension. ### Request Example for `install` ```python device.extensions.install("http://example.com/my_extension.zip") ``` ### Response for `install` None ### Parameters for `enable` #### Path Parameters None #### Query Parameters None #### Request Body - **extension_id** (string) - Required - The ID of the extension to enable. ### Request Example for `enable` ```python device.extensions.enable("com.example.myextension") ``` ### Response for `enable` None ### Parameters for `disable` #### Path Parameters None #### Query Parameters None #### Request Body - **extension_id** (string) - Required - The ID of the extension to disable. ### Request Example for `disable` ```python device.extensions.disable("com.example.myextension") ``` ### Response for `disable` None ``` -------------------------------- ### Extensions API Source: https://context7.com/mmarquezs/my.jdownloader-api-python-library/llms.txt Manage and query JDownloader extensions. This includes listing all extensions with detailed configuration, checking installation status, and enabling/disabling them. ```APIDOC ## Extensions API ### Description Manage and query JDownloader extensions. This includes listing all extensions with detailed configuration, checking installation status, and enabling/disabling them. ### List all extensions #### Method GET (Implicitly through library call) #### Endpoint `/device/extensions/list` (Conceptual) #### Parameters ##### Query Parameters - **configInterface** (boolean) - Optional - If true, includes interface configuration details. - **description** (boolean) - Optional - If true, includes extension descriptions. - **enabled** (boolean) - Optional - If true, includes the enabled status. - **iconKey** (boolean) - Optional - If true, includes the icon key. - **name** (boolean) - Optional - If true, includes the extension name. - **pattern** (string) - Optional - A filter pattern to match extension names. - **installed** (boolean) - Optional - If true, includes the installed status. ### Request Example ```python # Assuming 'device' is an authenticated device object extensions = device.extensions.list({ "configInterface": True, "description": True, "enabled": True, "iconKey": True, "name": True, "pattern": "", # Filter pattern "installed": True }) for ext in extensions: print(f"Extension: {ext.get('name')}") print(f" Description: {ext.get('description')}") print(f" Enabled: {ext.get('enabled')}") print(f" Installed: {ext.get('installed')}") print(f" ID: {ext.get('id')}") ``` ### Check if an extension is installed #### Method GET (Implicitly through library call) #### Endpoint `/device/extensions/isInstalled` (Conceptual) #### Parameters ##### Query Parameters - **ext_id** (string) - Required - The unique identifier of the extension. ### Request Example ```python ext_id = "org.jdownloader.extensions.extraction.ExtractionExtension" is_installed = device.extensions.isInstalled(ext_id) print(f"Extraction extension installed: {is_installed}") ``` ### Check if an extension is enabled #### Method GET (Implicitly through library call) #### Endpoint `/device/extensions/isEnabled` (Conceptual) #### Parameters ##### Query Parameters - **ext_id** (string) - Required - The unique identifier of the extension. ### Request Example ```python is_enabled = device.extensions.isEnabled(ext_id) print(f"Extraction extension enabled: {is_enabled}") ``` ### Enable/disable an extension #### Method POST (Implicitly through library call) #### Endpoint `/device/extensions/setEnabled` (Conceptual) #### Parameters ##### Query Parameters - **ext_id** (string) - Required - The unique identifier of the extension. - **enable** (boolean) - Required - True to enable, False to disable. ### Request Example ```python device.extensions.setEnabled(ext_id, True) # Enable device.extensions.setEnabled(ext_id, False) # Disable ``` ### Install an extension #### Method POST (Implicitly through library call) #### Endpoint `/device/extensions/install` (Conceptual) #### Parameters ##### Query Parameters - **ext_id** (string) - Required - The unique identifier of the extension. ### Request Example ```python device.extensions.install(ext_id) ``` ``` -------------------------------- ### Get JDownloader Storage Information Source: https://context7.com/mmarquezs/my.jdownloader-api-python-library/llms.txt Retrieves information about JDownloader's storage, including free space and total size for each path. Displays sizes in GB. ```python import myjdapi jd = myjdapi.Myjdapi() jd.set_app_key("MyApp") jd.connect("email@example.com", "password") device = jd.get_device("MyDevice") # Get storage information storage_info = device.system.get_storage_info() for storage in storage_info: print(f"Path: {storage.get('path')}") print(f" Free: {storage.get('free', 0) / 1024 / 1024 / 1024:.2f} GB") print(f" Total: {storage.get('size', 0) / 1024 / 1024 / 1024:.2f} GB") ``` -------------------------------- ### Get JDownloader Core Information Source: https://context7.com/mmarquezs/my.jdownloader-api-python-library/llms.txt Retrieves the JDownloader core version and revision information. ```python import myjdapi jd = myjdapi.Myjdapi() jd.set_app_key("MyApp") jd.connect("email@example.com", "password") device = jd.get_device("MyDevice") # Get JDownloader core revision revision = device.jd.get_core_revision() print(f"JDownloader core revision: {revision}") ``` -------------------------------- ### Access JDownloader Device Source: https://context7.com/mmarquezs/my.jdownloader-api-python-library/llms.txt Retrieves a device instance to interact with a specific JDownloader installation. Can fetch a device by name, ID, or simply the first available device. Provides access to various subsystems like linkgrabber, downloads, and configuration. ```python import myjdapi jd = myjdapi.Myjdapi() jd.set_app_key("MyApp") jd.connect("email@example.com", "password") # Get device by name device = jd.get_device("HomeServer") # Or get device by ID device = jd.get_device(device_id="af9d03a21ddb917492dc1af8a6427f11") # Or get the first available device device = jd.get_device() # Device has access to all subsystems: # device.linkgrabber - Link collection management # device.downloads - Download list management # device.downloadcontroller - Download control (start/stop/pause) # device.accounts - Premium account management # device.config - JDownloader configuration # device.system - System controls # device.captcha - Captcha handling # device.toolbar - Toolbar status and controls # device.extensions - Extension management # device.dialogs - Dialog handling # device.reconnect - Internet reconnection # device.update - Update management ``` -------------------------------- ### Update and Get JDownloader Devices Source: https://github.com/mmarquezs/my.jdownloader-api-python-library/blob/master/README.md After connecting, update the list of available JDownloader devices and retrieve a specific device by its name or ID. This allows you to interact with your JDownloader instances. ```python jd.update_devices() device=jd.get_device("TEST") # The parameter by default is the device name, but you can also use the device_id. device=jd.get_device(device_id="43434") ``` -------------------------------- ### DownloadController - Control Downloads Source: https://context7.com/mmarquezs/my.jdownloader-api-python-library/llms.txt Start, stop, pause downloads and monitor download speed and state. ```APIDOC ## DownloadController - Control Downloads ### Description Start, stop, pause downloads and monitor download speed and state. ### Method POST ### Endpoint /downloadcontroller ### Parameters #### Query Parameters - **action** (string) - Required - The action to perform (e.g., `start_downloads`, `stop_downloads`, `pause_downloads`, `get_speed_in_bytes`, `get_current_state`, `force_download`). #### Request Body - **link_ids** (array of strings) - Optional - List of download link UUIDs for `force_download`. - **package_ids** (array of strings) - Optional - List of package UUIDs for `force_download`. - **pause** (boolean) - Optional - For `pause_downloads` action, `true` to pause, `false` to unpause. ### Request Example ```json { "action": "pause_downloads", "pause": true } ``` ### Response #### Success Response (200) - **result** (string/number/boolean) - The result of the action (e.g., speed in bytes, state string, or success boolean). #### Response Example ```json { "result": 1024000 } ``` ``` -------------------------------- ### Get Default JDownloader Config Value Source: https://context7.com/mmarquezs/my.jdownloader-api-python-library/llms.txt Retrieves the default value for a specific JDownloader configuration setting. Requires the interface name, storage type ('null' for default), and the configuration key. ```python default = device.config.getDefault( "org.jdownloader.settings.GeneralSettings", "null", "DefaultDownloadFolder" ) print(f"Default download folder: {default}") ``` -------------------------------- ### Get Specific JDownloader Config Value Source: https://context7.com/mmarquezs/my.jdownloader-api-python-library/llms.txt Retrieves the current value of a specific JDownloader configuration setting. Requires the interface name, storage type ('null' for default), and the configuration key. ```python value = device.config.get( "org.jdownloader.settings.GeneralSettings", "null", "DefaultDownloadFolder" ) print(f"Download folder: {value}") ``` -------------------------------- ### Get Download Variants Source: https://context7.com/mmarquezs/my.jdownloader-api-python-library/llms.txt Retrieves available download variants for specific links, often used for media files like YouTube videos to select different quality or format options. ```python # Get download variants (for YouTube, etc.) variants = device.linkgrabber.get_variants([link_ids[0]]) # Returns: [{'id': 'M4A_256', 'name': '256kbit/s M4A-Audio'}, ...] ``` -------------------------------- ### Core API - Myjdapi Class Initialization and Connection Source: https://context7.com/mmarquezs/my.jdownloader-api-python-library/llms.txt Demonstrates how to initialize the Myjdapi client, set an application key, and connect to the My.JDownloader service using email and password. Includes error handling for connection and authentication failures, and lists available devices. ```APIDOC ## Core API - Myjdapi Class ### Description The main entry point for connecting to the My.JDownloader service. Handles authentication, session management, and device discovery. ### Method ```python import myjdapi # Initialize the API client jd = myjdapi.Myjdapi() # Set your application key (required for API access) jd.set_app_key("MyApplicationKey") # Connect with your My.JDownloader credentials try: jd.connect("your-email@example.com", "your-password") print("Connected successfully!") print(f"Session established: {jd.is_connected()}") except myjdapi.MYJDConnectionException as e: print(f"Connection failed: {e}") except myjdapi.MYJDAuthFailedException as e: print(f"Authentication failed: {e}") # List all available devices devices = jd.list_devices() for device in devices: print(f"Device: {device['name']} (ID: {device['id']}, Type: {device['type']})") # Output example: # Device: HomeServer (ID: af9d03a21ddb917492dc1af8a6427f11, Type: jd) # Disconnect when done jd.disconnect() ``` ``` -------------------------------- ### Linkgrabber - Get Package Count Source: https://context7.com/mmarquezs/my.jdownloader-api-python-library/llms.txt Get the total number of packages currently in the linkgrabber. ```APIDOC ## Get package count ### Description Retrieves the total count of packages within the linkgrabber. ### Method GET (Conceptual) ### Endpoint `/linkgrabber/package_count` (Conceptual) ### Parameters None ### Request Example ```python count = device.linkgrabber.get_package_count() print(f"Packages in linkgrabber: {count}") ``` ### Response #### Success Response (200) - **count** (integer) - The total number of packages. ``` -------------------------------- ### Initialize and Connect to My.Jdownloader API Source: https://github.com/mmarquezs/my.jdownloader-api-python-library/blob/master/README.md Initialize the Myjdapi class, set your application key, and connect using your email and password. This establishes a connection to the My.Jdownloader service. ```python import myjdapi jd=myjdapi.Myjdapi() jd.set_app_key("EXAMPLE") jd.connect("email","password") ``` -------------------------------- ### Initialize and Connect to JDownloader API Source: https://context7.com/mmarquezs/my.jdownloader-api-python-library/llms.txt Initializes the Myjdapi client, sets an application key, and connects to the JDownloader device using email and password. This is the first step for any API interaction. ```python import myjdapi jd = myjdapi.Myjdapi() jd.set_app_key("MyApp") jd.connect("email@example.com", "password") device = jd.get_device("MyDevice") ``` -------------------------------- ### Connect Directly to a JDownloader Device Source: https://github.com/mmarquezs/my.jdownloader-api-python-library/blob/master/DIRECT.md Use this method to establish a direct connection to a JDownloader device. Ensure myjdapi is imported and an instance is created. The host and port are required; timeout is optional. This connection bypasses My.JDownloader. ```python import myjdapi host = 'localhost' port = 3128 # Optional, by default is 3128 # We need an instance of Myjdapi() but no application key is required jd = myjdapi.Myjdapi() # connect directly to the device jd.connect_device(host,port,timeout=10) # Timeout is optional. ``` -------------------------------- ### Query Links in Linkgrabber Source: https://context7.com/mmarquezs/my.jdownloader-api-python-library/llms.txt Retrieves all links currently present in the linkgrabber. Use this to get a list of links for further management. ```python links = device.linkgrabber.query_links() ``` -------------------------------- ### Connect to My.JDownloader Cloud API Source: https://context7.com/mmarquezs/my.jdownloader-api-python-library/llms.txt Initializes the Myjdapi client, sets an application key, and connects using My.JDownloader credentials. Handles potential connection and authentication errors. Lists available devices after successful connection. ```python import myjdapi # Initialize the API client jd = myjdapi.Myjdapi() # Set your application key (required for API access) jd.set_app_key("MyApplicationKey") # Connect with your My.JDownloader credentials try: jd.connect("your-email@example.com", "your-password") print("Connected successfully!") print(f"Session established: {jd.is_connected()}") except myjdapi.MYJDConnectionException as e: print(f"Connection failed: {e}") except myjdapi.MYJDAuthFailedException as e: print(f"Authentication failed: {e}") # List all available devices devices = jd.list_devices() for device in devices: print(f"Device: {device['name']} (ID: {device['id']}, Type: {device['type']})") # Output example: # Device: HomeServer (ID: af9d03a21ddb917492dc1af8a6427f11, Type: jd) # Disconnect when done jd.disconnect() ``` -------------------------------- ### Manage Premium Hoster Accounts Source: https://context7.com/mmarquezs/my.jdownloader-api-python-library/llms.txt List supported premium hosters, add new accounts with credentials, and manage existing accounts by enabling, disabling, refreshing, updating, or removing them. Ensure correct hoster names and credentials are used. ```python # List all premium hosters supported hosters = device.accounts.list_premium_hoster() print("Supported premium hosters:") for hoster in hosters: print(f" - {hoster}") # Add a premium account device.accounts.add_account( premium_hoster="uploaded.net", username="premium_user", password="premium_pass" ) # List all configured accounts accounts = device.accounts.list_accounts([ { "startAt": 0, "maxResults": -1, "userName": True, "validUntil": True, "trafficLeft": True, "trafficMax": True, "enabled": True, "valid": True, "error": False, "UUIDList": [] } ]) for account in accounts: print(f"Account: {account.get('hostname')}") print(f" Username: {account.get('userName')}") print(f" Valid until: {account.get('validUntil')}") print(f" Traffic left: {account.get('trafficLeft')}") print(f" Enabled: {account.get('enabled')}") print(f" Valid: {account.get('valid')}") # Enable/disable accounts account_ids = [acc['uuid'] for acc in accounts] device.accounts.enable_accounts(account_ids) device.accounts.disable_accounts(account_ids) # Refresh account info device.accounts.refresh_accounts(account_ids) # Update account credentials device.accounts.set_user_name_and_password( account_id=account_ids[0], username="new_username", password="new_password" ) # Remove accounts device.accounts.remove_accounts(account_ids) ``` -------------------------------- ### Get Package Count in Linkgrabber Source: https://context7.com/mmarquezs/my.jdownloader-api-python-library/llms.txt Retrieves the total number of packages currently in the linkgrabber. Provides a quick overview of the linkgrabber's contents. ```python count = device.linkgrabber.get_package_count() print(f"Packages in linkgrabber: {count}") ``` -------------------------------- ### Complete Download Workflow with myjdapi Source: https://context7.com/mmarquezs/my.jdownloader-api-python-library/llms.txt This function automates a typical download workflow: connecting to My.JDownloader, adding links to the linkgrabber, processing collected links, moving online links to the download list, and starting/monitoring downloads. It includes error handling for authentication, device not found, and connection issues. Ensure your JDownloader is running and accessible. ```python import myjdapi import time def download_files(email, password, urls, destination, package_name="My Downloads"): """ Complete workflow to add links and download files. """ jd = myjdapi.Myjdapi() jd.set_app_key("DownloadAutomation") try: # Connect to My.JDownloader print("Connecting to My.JDownloader...") jd.connect(email, password) # Get the first available device device = jd.get_device() print(f"Connected to device: {device.name}") # Add links to linkgrabber print(f"Adding {len(urls.split())} links...") device.linkgrabber.add_links([ { "autostart": False, "links": urls, "packageName": package_name, "destinationFolder": destination, "priority": "DEFAULT", "overwritePackagizerRules": True } ]) # Wait for link collector to process print("Waiting for link processing...") while device.linkgrabber.is_collecting(): time.sleep(1) # Query collected packages packages = device.linkgrabber.query_packages() links = device.linkgrabber.query_links() print(f"Collected {len(packages)} packages with {len(links)} links") # Check link availability online = [l for l in links if l.get('availability') == 'ONLINE'] offline = [l for l in links if l.get('availability') == 'OFFLINE'] if offline: print(f"Warning: {len(offline)} links are offline") # Remove offline links offline_ids = [l['uuid'] for l in offline] device.linkgrabber.remove_links(link_ids=offline_ids) if online: # Move online links to download list link_ids = [l['uuid'] for l in online] package_ids = [p['uuid'] for p in packages] device.linkgrabber.move_to_downloadlist(link_ids, package_ids) # Start downloads print("Starting downloads...") device.downloadcontroller.start_downloads() # Monitor progress while True: downloads = device.downloads.query_packages([ { "bytesLoaded": True, "bytesTotal": True, "finished": True, "speed": True, "status": True, "childCount": True } ]) if not downloads: print("All downloads completed!") break for pkg in downloads: if pkg.get('bytesTotal', 0) > 0: progress = (pkg.get('bytesLoaded', 0) / pkg['bytesTotal']) * 100 speed = pkg.get('speed', 0) / 1024 / 1024 print(f" {pkg.get('name')}: {progress:.1f}% @ {speed:.2f} MB/s") finished = all(pkg.get('finished', False) for pkg in downloads) if finished: print("All downloads completed!") break time.sleep(5) return True except myjdapi.MYJDAuthFailedException: print("Authentication failed - check credentials") return False except myjdapi.MYJDDeviceNotFoundException: print("No JDownloader device found - ensure JDownloader is running") return False except myjdapi.MYJDConnectionException as e: print(f"Connection error: {e}") return False finally: if jd.is_connected(): jd.disconnect() print("Disconnected") # Usage urls = """ https://example.com/file1.zip https://example.com/file2.zip https://example.com/file3.zip """ success = download_files( email="your-email@example.com", password="your-password", urls=urls, destination="/downloads/my-files", package_name="Example Downloads" ) ``` -------------------------------- ### Query JDownloader Configuration Entries Source: https://context7.com/mmarquezs/my.jdownloader-api-python-library/llms.txt Fetches JDownloader configuration entries, optionally including default values, descriptions, enum information, and extensions. Filters can be applied using a pattern. ```python import myjdapi jd = myjdapi.Myjdapi() jd.set_app_key("MyApp") jd.connect("email@example.com", "password") device = jd.get_device("MyDevice") # Query all configuration entries config_entries = device.config.query([ { "configInterface": "", "defaultValues": True, "description": True, "enumInfo": True, "includeExtensions": True, "pattern": "", # Filter by pattern "values": True } ]) for entry in config_entries[:5]: # Show first 5 print(f"Config: {entry.get('key')}") print(f" Interface: {entry.get('interfaceName')}") print(f" Value: {entry.get('value')}") print(f" Default: {entry.get('defaultValue')}") print(f" Description: {entry.get('docs')}") ``` -------------------------------- ### List Enum Options for JDownloader Config Source: https://context7.com/mmarquezs/my.jdownloader-api-python-library/llms.txt Retrieves a list of available enumeration options for a given JDownloader configuration type. Useful for understanding valid choices for settings. ```python enum_options = device.config.listEnum("org.jdownloader.gui.views.downloads.View") for option in enum_options: print(f"Option: {option}") ``` -------------------------------- ### Query All Download Links with Full Details Source: https://context7.com/mmarquezs/my.jdownloader-api-python-library/llms.txt Retrieves all download links with a comprehensive set of details, including progress, speed, status, and timestamps. Useful for monitoring active downloads. ```python downloads = device.downloads.query_links([{ "addedDate": True, "bytesLoaded": True, "bytesTotal": True, "comment": True, "enabled": True, "eta": True, "extractionStatus": True, "finished": True, "finishedDate": True, "host": True, "jobUUIDs": [], "maxResults": -1, "packageUUIDs": [], "password": True, "priority": True, "running": True, "skipped": True, "speed": True, "startAt": 0, "status": True, "url": True }]) for dl in downloads: progress = 0 if dl.get('bytesTotal', 0) > 0: progress = (dl.get('bytesLoaded', 0) / dl['bytesTotal']) * 100 print(f"File: {dl.get('name')}") print(f" Progress: {progress:.1f}%") print(f" Speed: {dl.get('speed', 0) / 1024:.1f} KB/s") print(f" ETA: {dl.get('eta', 'N/A')} seconds") print(f" Status: {dl.get('status')}") print(f" Running: {dl.get('running')}") print(f" Finished: {dl.get('finished')}") ``` -------------------------------- ### Query and Manage Downloads Source: https://context7.com/mmarquezs/my.jdownloader-api-python-library/llms.txt Retrieve download IDs and package IDs, then use them to enable/disable, force, reset, change directory, move, remove, or cleanup downloads. ```python downloads = device.downloads.query_links() packages = device.downloads.query_packages() link_ids = [dl['uuid'] for dl in downloads[:5]] package_ids = [pkg['uuid'] for pkg in packages[:2]] # Enable/disable downloads device.downloads.set_enabled(True, link_ids, package_ids) device.downloads.set_enabled(False, link_ids, []) # Force download (bypass waiting time) device.downloads.force_download(link_ids=link_ids, package_ids=package_ids) # Reset failed downloads to retry device.downloads.reset_links(link_ids, package_ids) # Change download directory for packages device.downloads.set_dl_location("/new/download/path", package_ids) # Move links to a new package device.downloads.move_to_new_package( link_ids, package_ids, "Reorganized Package", "/downloads/organized" ) # Remove downloads from list device.downloads.remove_links(link_ids=link_ids, package_ids=[]) # Cleanup downloads # Actions: DELETE_ALL, DELETE_DISABLED, DELETE_FAILED, DELETE_FINISHED, DELETE_OFFLINE, DELETE_DUPE # Modes: REMOVE_LINKS_AND_DELETE_FILES, REMOVE_LINKS_AND_RECYCLE_FILES, REMOVE_LINKS_ONLY # Selection: SELECTED, UNSELECTED, ALL, NONE device.downloads.cleanup( action="DELETE_FINISHED", mode="REMOVE_LINKS_ONLY", selection_type="ALL", link_ids=[], package_ids=[] ) ``` -------------------------------- ### Run JDownloader Update Check Source: https://context7.com/mmarquezs/my.jdownloader-api-python-library/llms.txt Initiates a check for available JDownloader updates. ```python import myjdapi jd = myjdapi.Myjdapi() jd.set_app_key("MyApp") jd.connect("email@example.com", "password") device = jd.get_device("MyDevice") # Run update check device.update.run_update_check() ``` -------------------------------- ### System - System Control Operations API Source: https://context7.com/mmarquezs/my.jdownloader-api-python-library/llms.txt Control the JDownloader application and the host operating system. ```APIDOC ## System - System Control Operations API ### Description This API provides methods to get system storage information, restart JDownloader, exit JDownloader, and control OS power states. ### Methods - `get_storage_info()`: Retrieves information about available storage devices. - `restart_jd()`: Restarts the JDownloader application. - `exit_jd()`: Closes the JDownloader application. - `standby_os()`: Puts the operating system into standby mode. - `hibernate_os()`: Hibernates the operating system. - `shutdown_os(force)`: Shuts down the operating system. ### Parameters for `get_storage_info` #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example for `get_storage_info` ```python storage_info = device.system.get_storage_info() ``` ### Response for `get_storage_info` - **storage_info** (array of objects) - Information about storage devices, including `path`, `free` space, and `size`. ### Request Example for `restart_jd` ```python device.system.restart_jd() ``` ### Response for `restart_jd` None ### Request Example for `exit_jd` ```python device.system.exit_jd() ``` ### Response for `exit_jd` None ### Request Example for `standby_os` ```python device.system.standby_os() ``` ### Response for `standby_os` None ### Request Example for `hibernate_os` ```python device.system.hibernate_os() ``` ### Response for `hibernate_os` None ### Parameters for `shutdown_os` #### Path Parameters None #### Query Parameters None #### Request Body - **force** (boolean) - Optional - Set to `True` to force shutdown. ``` -------------------------------- ### Handle MyJDownloader API Exceptions Source: https://context7.com/mmarquezs/my.jdownloader-api-python-library/llms.txt Demonstrates how to handle various MyJDownloader API exceptions, including connection errors, authentication failures, device not found, rate limiting, session expiration, and maintenance. ```python import myjdapi from myjdapi import ( MYJDException, MYJDConnectionException, MYJDDeviceNotFoundException, MYJDDecodeException, MYJDApiException, MYJDAuthFailedException, MYJDTooManyRequestsException, MYJDSessionException, MYJDMaintenanceException ) jd = myjdapi.Myjdapi() jd.set_app_key("MyApp") try: jd.connect("email@example.com", "password") device = jd.get_device("NonExistentDevice") except MYJDAuthFailedException as e: print(f"Authentication failed: {e}") except MYJDDeviceNotFoundException as e: print(f"Device not found: {e}") # List available devices devices = jd.list_devices() print(f"Available devices: {[d['name'] for d in devices]}") except MYJDConnectionException as e: print(f"Connection error: {e}") # Try to reconnect try: jd.reconnect() except MYJDException: print("Reconnection also failed") except MYJDTooManyRequestsException as e: print(f"Rate limited, wait and retry: {e}") except MYJDSessionException as e: print(f"Session expired, reconnecting: {e}") jd.reconnect() except MYJDMaintenanceException as e: print(f"API is under maintenance: {e}") except MYJDApiException as e: print(f"API error from {e.source}: {e}") except MYJDException as e: print(f"General MyJDownloader error: {e}") finally: if jd.is_connected(): jd.disconnect() ``` -------------------------------- ### Direct Connection (RemoteAPI) Source: https://context7.com/mmarquezs/my.jdownloader-api-python-library/llms.txt Provides an alternative method for establishing a direct connection to JDownloader over a local network using RemoteAPI. This method bypasses the cloud service and is suitable for trusted networks. ```APIDOC ## Direct Connection (RemoteAPI) ### Description Alternative connection method for direct LAN access without cloud routing. Requires enabling RemoteAPI in JDownloader settings. ### Method ```python import myjdapi jd = myjdapi.Myjdapi() # Direct connection to JDownloader on local network # No authentication/encryption - use only on trusted networks try: success = jd.direct_connect("192.168.1.100", port=3128, timeout=5) if success: print("Direct connection established!") device = jd.get_device() # Gets the only available device # Now you can use all device features except myjdapi.MYJDConnectionException as e: print(f"Direct connection failed: {e}") ``` ``` -------------------------------- ### Query Packages in Linkgrabber (Basic) Source: https://context7.com/mmarquezs/my.jdownloader-api-python-library/llms.txt Retrieves packages from the linkgrabber without specifying detailed fields. Use for a general overview of packages. ```python packages = device.linkgrabber.query_packages() ``` -------------------------------- ### Handle JDownloader Dialogs Source: https://context7.com/mmarquezs/my.jdownloader-api-python-library/llms.txt Interacts with JDownloader dialogs by listing pending dialogs, retrieving their details, and answering them with appropriate response data. Ensure the response data format matches the dialog type. ```python import myjdapi jd = myjdapi.Myjdapi() jd.set_app_key("MyApp") jd.connect("email@example.com", "password") device = jd.get_device("MyDevice") # List pending dialogs dialogs = device.dialogs.list() for dialog in dialogs: dialog_id = dialog.get('id') print(f"Dialog ID: {dialog_id}") # Get dialog details dialog_info = device.dialogs.get(dialog_id, icon=True, properties=True) print(f" Title: {dialog_info.get('title')}") print(f" Message: {dialog_info.get('message')}") print(f" Type: {dialog_info.get('type')}") # Get type information type_info = device.dialogs.getTypeInfo(dialog_info.get('type')) print(f" Type info: {type_info}") # Answer the dialog # The data format depends on the dialog type response_data = {"response": "OK"} # Example response device.dialogs.answer(dialog_id, response_data) ``` -------------------------------- ### Linkgrabber - Adding and Managing Links Source: https://context7.com/mmarquezs/my.jdownloader-api-python-library/llms.txt Details how to use the Linkgrabber subsystem to add new links to JDownloader, set package properties like name, extraction password, and destination folder, and query existing links with various filter options. ```APIDOC ## Linkgrabber - Adding and Managing Links ### Description The Linkgrabber handles URL parsing and prepares links for downloading. Add links, query collected packages, and move them to the download list. ### Method ```python import myjdapi jd = myjdapi.Myjdapi() jd.set_app_key("MyApp") jd.connect("email@example.com", "password") device = jd.get_device("MyDevice") # Add links to the linkgrabber result = device.linkgrabber.add_links([ { "autostart": False, "links": "https://example.com/file1.zip\nhttps://example.com/file2.zip", "packageName": "My Downloads", "extractPassword": "secret123", "priority": "DEFAULT", # HIGHEST, HIGHER, HIGH, DEFAULT, LOWER "downloadPassword": None, "destinationFolder": "/downloads/my-folder", "overwritePackagizerRules": False } ]) # Query links in the linkgrabber links = device.linkgrabber.query_links([ { "bytesTotal": True, "comment": True, "status": True, "enabled": True, "maxResults": -1, "startAt": 0, "hosts": True, "url": True, "availability": True, "variantIcon": True, "variantName": True, "variantID": True, "variants": True, "priority": True } ]) for link in links: print(f"Link: {link.get('name')}") print(f" Status: {link.get('availability')}") print(f" Size: {link.get('bytesTotal', 0) / 1024 / 1024:.2f} MB") ``` ``` -------------------------------- ### Restart JDownloader and Apply Updates Source: https://context7.com/mmarquezs/my.jdownloader-api-python-library/llms.txt Restarts JDownloader and applies any available updates. This should typically be called after confirming an update is available. ```python # Restart and apply updates if has_update: device.update.restart_and_update() ``` -------------------------------- ### Query Download Packages Source: https://context7.com/mmarquezs/my.jdownloader-api-python-library/llms.txt Retrieves download packages with details such as loaded bytes, total bytes, child count, and status. Useful for monitoring package-level download progress. ```python # Query download packages packages = device.downloads.query_packages([{ "bytesLoaded": True, "bytesTotal": True, "childCount": True, "comment": True, "enabled": True, "eta": True, "finished": True, "hosts": True, "maxResults": -1, "packageUUIDs": [], "priority": True, "running": True, "saveTo": True, "speed": True, "startAt": 0, "status": True }]) for pkg in packages: print(f"Package: {pkg.get('name')}") print(f" Files: {pkg.get('childCount')}") print(f" Save to: {pkg.get('saveTo')}") print(f" Finished: {pkg.get('finished')}") ``` -------------------------------- ### Restart JDownloader Source: https://context7.com/mmarquezs/my.jdownloader-api-python-library/llms.txt Initiates a restart of the JDownloader application. ```python device.system.restart_jd() ``` -------------------------------- ### Direct Connection to RemoteAPI Source: https://context7.com/mmarquezs/my.jdownloader-api-python-library/llms.txt Establishes a direct connection to JDownloader on the local network using its RemoteAPI. This method bypasses cloud routing and is intended for use on trusted networks only, as it does not use authentication or encryption. ```python import myjdapi jd = myjdapi.Myjdapi() # Direct connection to JDownloader on local network # No authentication/encryption - use only on trusted networks try: success = jd.direct_connect("192.168.1.100", port=3128, timeout=5) if success: print("Direct connection established!") device = jd.get_device() # Gets the only available device # Now you can use all device features except myjdapi.MYJDConnectionException as e: print(f"Direct connection failed: {e}") ``` -------------------------------- ### Downloads - Query Packages Source: https://context7.com/mmarquezs/my.jdownloader-api-python-library/llms.txt Query download packages with details on progress, status, and save location. ```APIDOC ## Query download packages ### Description Retrieves information about download packages, including their status and contents. ### Method GET (Conceptual) ### Endpoint `/downloads/packages` (Conceptual) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **bytesLoaded** (boolean) - Optional - Include bytes loaded for the package. - **bytesTotal** (boolean) - Optional - Include total bytes for the package. - **childCount** (boolean) - Optional - Include the number of files in the package. - **comment** (boolean) - Optional - Include package comment. - **enabled** (boolean) - Optional - Include enabled status. - **eta** (boolean) - Optional - Include estimated time of arrival for the package. - **finished** (boolean) - Optional - Include finished status. - **hosts** (boolean) - Optional - Include host information for the package. - **maxResults** (integer) - Optional - Maximum number of results. -1 for all. - **packageUUIDs** (array) - Optional - Filter by package UUIDs. - **priority** (boolean) - Optional - Include package priority. - **running** (boolean) - Optional - Include running status. - **saveTo** (boolean) - Optional - Include the save location. - **speed** (boolean) - Optional - Include current speed for the package. - **startAt** (integer) - Optional - Starting index for pagination. - **status** (boolean) - Optional - Include package status. ### Request Example ```python packages = device.downloads.query_packages([ "bytesLoaded", "bytesTotal", "childCount", "comment", "enabled", "eta", "finished", "hosts", "maxResults": -1, "packageUUIDs": [], "priority", "running", "saveTo", "speed", "startAt": 0, "status" ]) for pkg in packages: print(f"Package: {pkg.get('name')}") print(f" Files: {pkg.get('childCount')}") print(f" Save to: {pkg.get('saveTo')}") print(f" Finished: {pkg.get('finished')}") ``` ### Response #### Success Response (200) - **packages** (array) - List of download package objects with requested details. ```