Skip to content

Commit

Permalink
Update extension and category function and its comment & readme
Browse files Browse the repository at this point in the history
  • Loading branch information
pawanpaudel93 committed Nov 5, 2023
1 parent ee3ade1 commit 7595daf
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 36 deletions.
32 changes: 16 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
40 changes: 20 additions & 20 deletions m3u_parser/m3u_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,65 +554,65 @@ 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).
Removes stream information from the internal streams information list based on the provided file extension(s).
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).
Retrieves stream information from the internal streams information list based on the provided file extension(s).
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()):
"""
Expand Down

0 comments on commit 7595daf

Please sign in to comment.