mirror of https://github.com/Free-TV/IPTV
Fix pylint errors in make_playlist.py
Resolves trailing whitespace, line-too-long, unnecessary parens, missing docstrings, and no-else-return findings from the Pylint workflow job.pull/1131/head
parent
2f95cf3785
commit
51bbec5b22
|
|
@ -1,4 +1,5 @@
|
||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
|
"""Generate M3U playlists from the markdown channel lists in lists/."""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
|
@ -91,7 +92,9 @@ COUNTRY_CODES = {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class Channel:
|
class Channel: # pylint: disable=too-few-public-methods,too-many-instance-attributes
|
||||||
|
"""A single channel entry parsed from a markdown list line."""
|
||||||
|
|
||||||
def __init__(self, group, md_line, country_code=""):
|
def __init__(self, group, md_line, country_code=""):
|
||||||
self.group = group
|
self.group = group
|
||||||
self.country_code = country_code
|
self.country_code = country_code
|
||||||
|
|
@ -105,22 +108,25 @@ class Channel:
|
||||||
self.logo = self.logo[self.logo.find('src="')+5:self.logo.rfind('"')]
|
self.logo = self.logo[self.logo.find('src="')+5:self.logo.rfind('"')]
|
||||||
|
|
||||||
self.chno = self.number if self.number and self.number != "0" else None
|
self.chno = self.number if self.number and self.number != "0" else None
|
||||||
|
|
||||||
if len(parts) > 6:
|
if len(parts) > 6:
|
||||||
self.epg = parts[5].strip()
|
self.epg = parts[5].strip()
|
||||||
else:
|
else:
|
||||||
self.epg = None
|
self.epg = None
|
||||||
|
|
||||||
def to_m3u_line(self):
|
def to_m3u_line(self):
|
||||||
|
"""Render this channel as a #EXTINF entry followed by its URL."""
|
||||||
country = f' tvg-country="{self.country_code}"' if self.country_code else ""
|
country = f' tvg-country="{self.country_code}"' if self.country_code else ""
|
||||||
chno = f' tvg-chno="{self.chno}"' if self.chno else ""
|
chno = f' tvg-chno="{self.chno}"' if self.chno else ""
|
||||||
if self.epg is None:
|
epg = f' tvg-id="{self.epg}"' if self.epg is not None else ""
|
||||||
return (f'#EXTINF:-1 tvg-name="{self.name}" tvg-logo="{self.logo}"{chno}{country} group-title="{self.group}",{self.name}\n{self.url}')
|
return (
|
||||||
else:
|
f'#EXTINF:-1 tvg-name="{self.name}" tvg-logo="{self.logo}"{epg}{chno}{country}'
|
||||||
return (f'#EXTINF:-1 tvg-name="{self.name}" tvg-logo="{self.logo}" tvg-id="{self.epg}"{chno}{country} group-title="{self.group}",{self.name}\n{self.url}')
|
f' group-title="{self.group}",{self.name}\n{self.url}'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main(): # pylint: disable=too-many-locals
|
||||||
|
"""Build the combined playlist.m3u8 and one per-country playlist."""
|
||||||
base_dir = os.path.dirname(os.path.abspath(__file__))
|
base_dir = os.path.dirname(os.path.abspath(__file__))
|
||||||
lists_dir = os.path.join(base_dir, "lists")
|
lists_dir = os.path.join(base_dir, "lists")
|
||||||
dir_playlists = os.path.join(base_dir, "playlists")
|
dir_playlists = os.path.join(base_dir, "playlists")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue