Skip to content

Commit

Permalink
fetching title containing comma #12
Browse files Browse the repository at this point in the history
  • Loading branch information
pawanpaudel93 committed Jul 21, 2021
1 parent 4a414ad commit eadadf6
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h1 align="center">Welcome to m3u_parser</h1>
<p>
<img alt="Version" src="https://img.shields.io/badge/version-0.1.5-blue.svg?cacheSeconds=2592000" />
<img alt="Version" src="https://img.shields.io/badge/version-0.1.6-blue.svg?cacheSeconds=2592000" />
</p>

> A parser for m3u files.
Expand Down
2 changes: 1 addition & 1 deletion m3u_parser/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@


# get matching regex from content
def get_by_regex(regex: re.Pattern, content: str) -> Union[str, None]:

This comment has been minimized.

Copy link
@dineiar

dineiar Jul 21, 2021

Contributor

Why did you remove this type hint @pawanpaudel93? It seems that this function always receive a compiled regex anyway, so the type hint seems correct to me.

This comment has been minimized.

Copy link
@pawanpaudel93

pawanpaudel93 Jul 21, 2021

Author Owner

@dineiar Yes it is correct but in python 3.6 it is not present.

This comment has been minimized.

Copy link
@dineiar

dineiar Jul 21, 2021

Contributor

Oh, that's right then.

def get_by_regex(regex, content: str) -> Union[str, None]:
"""Matches content by regex and returns the value captured by the first group, or None if there was no match
:param regex: A compiled regex to match
Expand Down
6 changes: 3 additions & 3 deletions m3u_parser/m3u_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def __init__(self, useragent: str = None, timeout: int = 5):
self._tvg_id_regex = re.compile(r"tvg-id=\"(.*?)\"", flags=re.IGNORECASE)
self._logo_regex = re.compile(r"tvg-logo=\"(.*?)\"", flags=re.IGNORECASE)
self._category_regex = re.compile(r"group-title=\"(.*?)\"", flags=re.IGNORECASE)
self._title_regex = re.compile("[,](?!.*[,])(.*?)$", flags=re.IGNORECASE)
self._title_regex = re.compile(r"(?!.*=\",?.*\")[,](.*?)$", flags=re.IGNORECASE)
self._country_regex = re.compile(r"tvg-country=\"(.*?)\"", flags=re.IGNORECASE)
self._language_regex = re.compile(
r"tvg-language=\"(.*?)\"", flags=re.IGNORECASE
Expand Down Expand Up @@ -463,7 +463,7 @@ def _get_m3u_content(self) -> str:
if stream_info.get("category"):
line += ' group-title="{}"'.format(stream_info["category"])
if stream_info.get("name"):
line += ", " + stream_info["name"]
line += "," + stream_info["name"]

This comment has been minimized.

Copy link
@dineiar

dineiar Jul 22, 2021

Contributor

Hey @pawanpaudel93, all the M3U files I have use this space following the comma before the item name. Can we keep it, or do you think it was wrong putting a space after the comma?

This comment has been minimized.

Copy link
@pawanpaudel93

pawanpaudel93 Jul 22, 2021

Author Owner

I started m3u_parser following this repo https://github.com/iptv-org/iptv/tree/master/channels and the JSON format they provide and I thought there was space after comma but on checking some m3u files there was no space. So removed the space after comma. So I checked with the VLC player on what name it gets when I opened the m3u file, so it got the title with space when space was there. So removing space is better I think.

This comment has been minimized.

Copy link
@dineiar

dineiar Jul 22, 2021

Contributor

I didn't know VLC don't trim the name. So other players may also keep the space, I agree with you that we shouldn't generate the space.

content.append(line)
content.append(stream_info["url"])
return "\n".join(content)
Expand Down Expand Up @@ -506,7 +506,7 @@ def with_extension(name, ext):
ndict_to_csv(self._streams_info, filename)
logging.info("Saved to file: %s" % filename)
else:
logging.info("Saving to csv file not supported in trim mode")
logging.info("Saving to csv file not supported in trim mode !!!")

elif format == "m3u":
content = self._get_m3u_content()
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

# Package meta-data.
NAME = "m3u_parser"
DESCRIPTION = "A useful module for parsing m3u files or links"
DESCRIPTION = "A useful package for parsing m3u files or links"
URL = "https://github.com/pawanpaudel93/m3u_parser"
EMAIL = "[email protected]"
AUTHOR = "Pawan Paudel"
REQUIRES_PYTHON = ">=3.0"
VERSION = "0.1.5"
VERSION = "0.1.6"

REQUIRED = ["requests", "asyncio", "aiohttp", "pycountry"]

Expand Down

0 comments on commit eadadf6

Please sign in to comment.