### List Supported Domains Source: https://github.com/5hojib/truelink/blob/main/docs/getting-started.md Shows how to retrieve a list of all domains that TrueLink currently supports using the static method `TrueLinkResolver.get_supported_domains()`. ```python from truelink import TrueLinkResolver supported_domains = TrueLinkResolver.get_supported_domains() print(supported_domains) ``` -------------------------------- ### Using TrueLink Caching Source: https://github.com/5hojib/truelink/blob/main/docs/getting-started.md Shows how to leverage TrueLink's built-in caching mechanism by passing `use_cache=True` to the `resolve()` method. The first call resolves and caches the result, while subsequent calls retrieve it from the cache. ```python import asyncio from truelink import TrueLinkResolver async def main(): resolver = TrueLinkResolver() url = "https://buzzheavier.com/rnk4ut0lci9y" # The first time, the URL will be resolved and the result will be cached result1 = await resolver.resolve(url, use_cache=True) print(f"First result: {result1}") # The second time, the result will be loaded from the cache result2 = await resolver.resolve(url, use_cache=True) print(f"Second result: {result2}") asyncio.run(main()) ``` -------------------------------- ### Install TrueLink using pip Source: https://github.com/5hojib/truelink/blob/main/docs/installation.md The standard method to install the TrueLink package from the Python Package Index (PyPI). This command ensures you get the latest stable release. ```bash pip install truelink ``` -------------------------------- ### Check if a URL is Supported Source: https://github.com/5hojib/truelink/blob/main/docs/getting-started.md Demonstrates how to use the static method `TrueLinkResolver.is_supported()` to check if a given URL is compatible with TrueLink without needing to instantiate the resolver. ```python from truelink import TrueLinkResolver if TrueLinkResolver.is_supported("https://www.mediafire.com/file/somefile"): print("This URL is supported!") else: print("This URL is not supported.") ``` -------------------------------- ### Resolve a URL with TrueLink Source: https://github.com/5hojib/truelink/blob/main/docs/getting-started.md Demonstrates how to use the `TrueLinkResolver` class to resolve a single URL. It includes checking if the URL is supported and handling potential exceptions during resolution. The `resolve()` method returns a `LinkResult` or `FolderResult`. ```python import asyncio from truelink import TrueLinkResolver async def main(): resolver = TrueLinkResolver() url = "https://buzzheavier.com/rnk4ut0lci9y" try: if resolver.is_supported(url): result = await resolver.resolve(url) print(result) else: print(f"URL not supported: {url}") except Exception as e: print(f"Error processing {url}: {e}") asyncio.run(main()) ``` -------------------------------- ### TrueLink Quick Start Example Source: https://github.com/5hojib/truelink/blob/main/README.md Demonstrates how to use the TrueLink library to resolve a media URL. It shows how to check if a URL is supported, create a resolver instance, and asynchronously resolve a URL to its direct download link. Includes basic error handling. ```python import asyncio from truelink import TrueLinkResolver async def main(): # Check if a URL is supported without creating an instance if TrueLinkResolver.is_supported("https://buzzheavier.com/rnk4ut0lci9y"): print("BuzzHeavier is supported!") resolver = TrueLinkResolver() url = "https://buzzheavier.com/rnk4ut0lci9y" try: result = await resolver.resolve(url) print(type(result)) print(result) except Exception as e: print(f"Error processing {url}: {e}") asyncio.run(main()) ``` -------------------------------- ### Install Documentation Dependencies and Serve Source: https://github.com/5hojib/truelink/blob/main/docs/contributing.md Installs necessary packages for documentation and serves the documentation locally. ```bash # Install docs dependencies pip install mkdocs mkdocs-material mkdocstrings[python] # Serve docs locally mkdocs serve ``` -------------------------------- ### Verify TrueLink Installation Source: https://github.com/5hojib/truelink/blob/main/docs/installation.md A Python command to confirm that TrueLink has been installed correctly. It imports the library and prints its version number to the console. ```python import truelink print(truelink.__version__) ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/5hojib/truelink/blob/main/docs/contributing.md Installs the project dependencies in editable mode using pip. ```python pip install -e . ``` -------------------------------- ### Install TrueLink Source: https://github.com/5hojib/truelink/blob/main/README.md Installs the TrueLink Python library using pip. This command is essential for setting up the library in your Python environment. ```bash pip install truelink ``` -------------------------------- ### Build Documentation Source: https://github.com/5hojib/truelink/blob/main/docs/contributing.md Builds the project documentation for deployment. ```bash mkdocs build ``` -------------------------------- ### Create and Activate Virtual Environment Source: https://github.com/5hojib/truelink/blob/main/docs/contributing.md Instructions for creating a Python virtual environment and activating it for development. ```bash python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate ``` -------------------------------- ### Clone TrueLink Repository Source: https://github.com/5hojib/truelink/blob/main/docs/contributing.md Steps to clone the TrueLink repository and navigate into the project directory. ```text git clone https://github.com/yourusername/truelink.git cd truelink ``` -------------------------------- ### TrueLinkResolver Initialization Source: https://github.com/5hojib/truelink/blob/main/docs/configuration.md Demonstrates how to initialize the TrueLinkResolver with custom timeout and max_retries parameters. ```python import asyncio from truelink import TrueLinkResolver async def main(): resolver = TrueLinkResolver(timeout=20, max_retries=5) url = "https://buzzheavier.com/rnk4ut0lci9y" result = await resolver.resolve(url) print(result) asyncio.run(main()) ``` -------------------------------- ### Adding Resolver to __init__.py Source: https://github.com/5hojib/truelink/blob/main/docs/adding-resolvers.md Shows how to register a newly created resolver by importing it and adding it to the `__all__` list in the `src/truelink/resolvers/__init__.py` file. ```python # src/truelink/resolvers/__init__.py # ... other imports from .myresolver import MyResolver # ... __all__ = [ # ... other resolvers "MyResolver", ] ``` -------------------------------- ### TrueLinkResolver Configuration Parameters Source: https://github.com/5hojib/truelink/blob/main/docs/configuration.md Lists the configurable parameters for the TrueLinkResolver constructor, including their types and default values. ```APIDOC TrueLinkResolver: __init__(timeout: Optional[int] = 10, max_retries: Optional[int] = 3) timeout: The timeout in seconds for HTTP requests. Defaults to 10. max_retries: The maximum number of retries for failed HTTP requests. Defaults to 3. ``` -------------------------------- ### Batch URL Resolution with Asyncio Source: https://github.com/5hojib/truelink/blob/main/docs/advanced-usage.md Demonstrates how to process multiple URLs concurrently using `asyncio.gather` for maximum efficiency. This method is ideal for handling large volumes of URLs. It includes error handling for individual resolutions. ```python import asyncio from truelink import TrueLinkResolver async def main(): resolver = TrueLinkResolver() urls = [ "https://buzzheavier.com/rnk4ut0lci9y", "https://www.mediafire.com/file/somefile", "https://www.terabox.com/sharing/link?surl=...", ] tasks = [resolver.resolve(url) for url in urls] results = await asyncio.gather(*tasks, return_exceptions=True) for url, result in zip(urls, results): if isinstance(result, Exception): print(f"Error resolving {url}: {result}") else: print(f"Successfully resolved {url}: {result}") asyncio.run(main()) ``` -------------------------------- ### TrueLinkResolver Class Reference Source: https://github.com/5hojib/truelink/blob/main/docs/core.md Provides a comprehensive reference for the TrueLinkResolver class, detailing its methods, parameters, and usage within the TrueLink library. ```APIDOC truelink.TrueLinkResolver: # Represents the core resolver for TrueLink functionalities. # This class is responsible for managing and resolving various links and data structures. # # Methods: # __init__(...): Initializes the TrueLinkResolver with specified configurations. # resolve_link(link_id: str, ...): Resolves a given link ID to its associated data. # create_link(...): Creates a new link with provided attributes. # update_link(link_id: str, ...): Updates an existing link. # delete_link(link_id: str, ...): Deletes a link. # get_all_links(...): Retrieves all links managed by the resolver. # # Parameters and return types will vary per method. Refer to specific method documentation for details. ``` -------------------------------- ### Returning a LinkResult Source: https://github.com/5hojib/truelink/blob/main/docs/adding-resolvers.md Demonstrates how to return a `LinkResult` object from the `resolve` method when a URL points to a single file. It includes fetching file details using a helper method. ```python download_url = "..." # Extracted download link filename, size, mime_type = await self._fetch_file_details(download_url) return LinkResult( url=download_url, filename=filename, size=size, mime_type=mime_type, ) ``` -------------------------------- ### Push Changes to Fork Source: https://github.com/5hojib/truelink/blob/main/docs/contributing.md Pushes the local feature branch to the remote repository fork. ```bash git push origin feature/your-feature-name ``` -------------------------------- ### Create a New Feature Branch Source: https://github.com/5hojib/truelink/blob/main/docs/contributing.md Creates a new Git branch for developing a new feature. ```bash git checkout -b feature/your-feature-name ``` -------------------------------- ### Returning a FolderResult Source: https://github.com/5hojib/truelink/blob/main/docs/adding-resolvers.md Illustrates how to return a `FolderResult` object for URLs that represent folders. It shows the structure for `FileItem` objects within the `contents` list. ```python from truelink.types import FileItem contents = [ FileItem( url="", filename="", size=, mime_type="", path="", ), # ... more files ] return FolderResult( title="", contents=contents, total_size=, ) ``` -------------------------------- ### Basic Resolver Structure Source: https://github.com/5hojib/truelink/blob/main/docs/adding-resolvers.md Provides the fundamental structure for a new resolver class in TrueLink. It inherits from `BaseResolver` and defines essential attributes and methods like `DOMAINS` and `resolve`. ```python # src/truelink/resolvers/myresolver.py from __future__ import annotations from typing import TYPE_CHECKING, ClassVar from truelink.exceptions import ExtractionFailedException from truelink.types import LinkResult, FolderResult from .base import BaseResolver if TYPE_CHECKING: # Import any other necessary types here pass class MyResolver(BaseResolver): """Resolver for MyService URLs.""" DOMAINS: ClassVar[list[str]] = ["myservice.com"] async def resolve(self, url: str) -> LinkResult | FolderResult: """ Resolve a MyService URL to a direct download link or folder. """ # Your implementation here raise ExtractionFailedException("Not yet implemented.") ``` -------------------------------- ### Commit Changes Source: https://github.com/5hojib/truelink/blob/main/docs/contributing.md Commits staged changes with a descriptive message. ```bash git commit -m "Add: description of your changes" ``` -------------------------------- ### TrueLink Custom Exceptions Source: https://github.com/5hojib/truelink/blob/main/docs/exceptions.md This section details the custom exceptions defined in the TrueLink library. These exceptions are used to signal specific error conditions during the library's operation, such as unsupported providers, invalid URLs, or failures during data extraction. ```APIDOC TrueLinkException: Description: Base exception for all TrueLink-related errors. UnsupportedProviderException: Inherits from: TrueLinkException Description: Raised when an attempt is made to use a service provider that is not supported by the library. InvalidURLException: Inherits from: TrueLinkException Description: Raised when a provided URL does not meet the expected format or is otherwise invalid. ExtractionFailedException: Inherits from: TrueLinkException Description: Raised when the library fails to extract the required information from a given source, typically due to unexpected content or structure. ``` -------------------------------- ### Truelink Return Types Source: https://github.com/5hojib/truelink/blob/main/docs/types.md Defines the structure and fields for LinkResult, FolderResult, and FileItem, which are used to represent data returned by Truelink operations. ```APIDOC LinkResult: # Represents the result of a link operation. # Fields: # id (str): The unique identifier for the link. # url (str): The URL of the link. # name (str): The name or title of the link. # description (str, optional): A description for the link. # created_at (str): The timestamp when the link was created. # updated_at (str): The timestamp when the link was last updated. FolderResult: # Represents the result of a folder operation. # Fields: # id (str): The unique identifier for the folder. # name (str): The name of the folder. # parent_id (str, optional): The ID of the parent folder. # created_at (str): The timestamp when the folder was created. # updated_at (str): The timestamp when the folder was last updated. FileItem: # Represents a file within a folder structure. # Fields: # id (str): The unique identifier for the file. # name (str): The name of the file. # folder_id (str): The ID of the folder containing the file. # created_at (str): The timestamp when the file was created. # updated_at (str): The timestamp when the file was last updated. # size (int): The size of the file in bytes. # mime_type (str): The MIME type of the file. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.