From 7595daf546e2aee50381fc0c1cbfd65c6bcd5b58 Mon Sep 17 00:00:00 2001 From: Pawan Paudel Date: Sun, 5 Nov 2023 23:59:43 +0545 Subject: [PATCH] Update extension and category function and its comment & readme --- README.md | 32 ++++++++++++++++---------------- m3u_parser/m3u_parser.py | 40 ++++++++++++++++++++-------------------- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/README.md b/README.md index c42349c..a9f0286 100644 --- a/README.md +++ b/README.md @@ -128,50 +128,50 @@ parser.reset_operations() #### remove_by_extension -`remove_by_extension(extension: Union[str, list]) -> None` +`remove_by_extension(extensions: Union[str, list[str]]) -> None` -Removes stream information with a certain extension or extensions. +Removes stream information with a certain extension(s). -- `extension`: The name of the extension(s) to remove, e.g., "mp4" or ["mp4", "m3u8"]. +- `extensions`: The name of the extension(s) to remove, e.g., "mp4" or ["mp4", "m3u8"]. ```python -parser.remove_by_extension(extension) +parser.remove_by_extension(extensions) ``` #### retrieve_by_extension -`retrieve_by_extension(extension: Union[str, list]) -> None` +`retrieve_by_extension(extension: Union[str, list[str]]) -> None` -Retrieves only stream information with a certain extension or extensions. +Retrieves only stream information with a certain extension(s). -- `extension`: The name of the extension(s) to retrieve, e.g., "mp4" or ["mp4", "m3u8"]. +- `extensions`: The name of the extension(s) to retrieve, e.g., "mp4" or ["mp4", "m3u8"]. ```python -parser.retrieve_by_extension(extension) +parser.retrieve_by_extension(extensions) ``` #### remove_by_category -`remove_by_category(filter_word: Union[str, list]) -> None` +`remove_by_category(categories: Union[str, list[str]]) -> None` -Removes stream information with a category containing certain filter word/s. +Removes stream information containing certain categories. -- `filter_word`: The filter word/s to match against the category. It can be a string or a list of filter word/s. +- `categories`: Category or list of categories to be removed from the streams information ```python -parser.remove_by_category(filter_word) +parser.remove_by_category(categories) ``` #### retrieve_by_category -`retrieve_by_category(filter_word: Union[str, list]) -> None` +`retrieve_by_category(categories: Union[str, list[str]]) -> None` -Selects only stream information with a category containing certain filter word/s. +Selects only stream information containing certain categories. -- `filter_word`: The filter word/s to match against the category. It can be a string or a list of filter word/s. +- `categories`: Category or list of categories to be retrieved from the streams information. ```python -parser.retrieve_by_category(filter_word) +parser.retrieve_by_category(categories) ``` #### sort_by diff --git a/m3u_parser/m3u_parser.py b/m3u_parser/m3u_parser.py index e3dd9f9..35325a6 100755 --- a/m3u_parser/m3u_parser.py +++ b/m3u_parser/m3u_parser.py @@ -554,7 +554,7 @@ def reset_operations(self): """ self._streams_info = self._streams_info_backup.copy() - def remove_by_extension(self, extension: Union[str, list]): + def remove_by_extension(self, extensions: Union[str, list[str]]): """ Remove stream information with specific file extension(s). @@ -562,14 +562,14 @@ def remove_by_extension(self, extension: Union[str, list]): If the stream URL ends with the specified extension(s), it will be removed from the list. Args: - - `extension` (Union[str, list]): File extension or list of file extensions to be removed from the streams information. + - `extensions` (Union[str, list[str]]): File extension or list of file extensions to be removed from the streams information. Returns: None: The internal streams information list is updated, removing streams with the specified extension(s). """ - self.filter_by("url", extension, FilterConfig(retrieve=False)) + self.filter_by("url", extensions, FilterConfig(retrieve=False)) - def retrieve_by_extension(self, extension: Union[str, list]): + def retrieve_by_extension(self, extensions: Union[str, list[str]]): """ Retrieve streams information with specific file extension(s). @@ -577,42 +577,42 @@ def retrieve_by_extension(self, extension: Union[str, list]): Only streams with URLs ending with the specified extension(s) will be retained in the list. Args: - - `extension` (Union[str, list]): File extension or list of file extensions to be retrieved from the streams information. + - `extensions` (Union[str, list[str]]): File extension or list of file extensions to be retrieved from the streams information. Returns: None: The internal streams information list is updated, retaining only streams with the specified extension(s). """ - self.filter_by("url", extension) + self.filter_by("url", extensions) - def remove_by_category(self, filter_word: Union[str, list]): + def remove_by_category(self, categories: Union[str, list[str]]): """ - Remove streams information with specific category containing certain filter word(s). + Remove streams information with specific categories. - Removes stream information from the internal streams information list based on the specified category filter word(s). - If the category of a stream contains the provided filter word(s), that stream will be removed from the list. + Removes stream information from the internal streams information list based on the provided categories. + If the category of a stream contains the provided categories, that stream will be removed from the list. Args: - - `filter_word` (Union[str, list]): Filter word or list of filter words to match against stream categories. + - `categories` (Union[str, list[str]]): Category or list of categories to be removed from the streams information. Returns: - None: The internal streams information list is updated, removing streams with specified category filter word(s). + None: The internal streams information list is updated, removing streams with specified categories. """ - self.filter_by("category", filter_word, FilterConfig(retrieve=False)) + self.filter_by("category", categories, FilterConfig(retrieve=False)) - def retrieve_by_category(self, filter_word: Union[str, list]): + def retrieve_by_category(self, categories: Union[str, list[str]]): """ - Retrieve streams information with specific category containing certain filter word(s). + Retrieve streams information with specific categories. - Retrieves stream information from the internal streams information list based on the specified category filter word(s). - Only streams with categories containing the provided filter word(s) will be retained in the list. + Retrieves stream information from the internal streams information list based on the provided categories. + Only streams containing the provided categories will be retained in the list. Args: - - `filter_word` (Union[str, list]): Filter word or list of filter words to match against stream categories. + - `categories` (Union[str, list[str]]): Category or list of categories to be retrieved from the streams information. Returns: - None: The internal streams information list is updated, retaining only streams with specified category filter word(s). + None: The internal streams information list is updated, retaining only streams with specified categories. """ - self.filter_by("category", filter_word) + self.filter_by("category", categories) def sort_by(self, key: str, config: SortConfig = SortConfig()): """