tribler.core.libtorrent.trackers ================================ .. py:module:: tribler.core.libtorrent.trackers Attributes ---------- .. autoapisummary:: tribler.core.libtorrent.trackers.UDP tribler.core.libtorrent.trackers.HTTP tribler.core.libtorrent.trackers.HTTPS tribler.core.libtorrent.trackers.SUPPORTED_SCHEMES tribler.core.libtorrent.trackers.DEFAULT_PORTS tribler.core.libtorrent.trackers.delimiters_regex tribler.core.libtorrent.trackers.url_regex tribler.core.libtorrent.trackers.remove_trailing_junk tribler.core.libtorrent.trackers.truncated_url_detector Exceptions ---------- .. autoapisummary:: tribler.core.libtorrent.trackers.MalformedTrackerURLException Functions --------- .. autoapisummary:: tribler.core.libtorrent.trackers.get_uniformed_tracker_url tribler.core.libtorrent.trackers.parse_tracker_url tribler.core.libtorrent.trackers._parse_tracker_url tribler.core.libtorrent.trackers.add_url_params tribler.core.libtorrent.trackers.is_valid_url Module Contents --------------- .. py:data:: UDP :value: 'udp' .. py:data:: HTTP :value: 'http' .. py:data:: HTTPS :value: 'https' .. py:data:: SUPPORTED_SCHEMES .. py:data:: DEFAULT_PORTS .. py:exception:: MalformedTrackerURLException Bases: :py:obj:`Exception` The tracker URL is not valid. .. py:data:: delimiters_regex .. py:data:: url_regex .. py:data:: remove_trailing_junk .. py:data:: truncated_url_detector .. py:function:: get_uniformed_tracker_url(tracker_url: str) -> str | None Parses the given tracker URL and returns in a uniform URL format. It uses regex to sanitize the URL. :param tracker_url: Tracker URL :return: the tracker in a uniform format ://:/ .. py:function:: parse_tracker_url(tracker_url: str) -> tuple[str, tuple[str, int], str] Parses the tracker URL and checks whether it satisfies tracker URL constraints. Additionally, it also checks if the tracker URL is a uniform and valid URL. :param tracker_url the URL of the tracker :returns: Tuple (scheme, (host, port), announce_path) .. py:function:: _parse_tracker_url(tracker_url: str) -> tuple[str, tuple[str, int], str] Parses the tracker URL and check whether it satisfies certain constraints. - The tracker type must be one of the supported types (udp, http, https). - UDP trackers requires a port. - HTTP(s) trackers requires an announce path. - HTTP(S) trackers default to HTTP(S)_PORT if port is not present on the URL. :param tracker_url the URL of the tracker :returns: Tuple (scheme, (host, port), announce_path) .. py:function:: add_url_params(url: str, params: dict) -> str Add GET params to provided URL being aware of existing. >> url = 'http://stackoverflow.com/test?answers=true' >> new_params = {'answers': False, 'data': ['some','values']} >> add_url_params(url, new_params) 'http://stackoverflow.com/test?data=some&data=values&answers=false' :param url: string of target URL :param params: dict containing requested params to be added :return: string with updated URL .. py:function:: is_valid_url(url: str) -> bool | None Checks whether the given URL is a valid URL. Both UDP and HTTP URLs will be validated correctly. :param url: an object representing the URL :return: Boolean specifying whether the URL is valid