Update make_playlist.py

using f-strings
pull/76/head
Axel Schneider 2021-08-09 17:52:59 +02:00 committed by GitHub
parent 2a0b5275f7
commit edf033d2e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 7 deletions

View File

@ -17,19 +17,17 @@ class Channel():
self.logo = self.logo[self.logo.find('src="')+5:self.logo.rfind('"')]
def to_m3u_line(self):
return('#EXTINF:-1 tvg-name="%(name)s" tvg-logo="%(logo)s" group-title="%(group)s",%(name)s\n%(url)s' \
% {'name':self.name, 'logo':self.logo, 'group':self.group, 'url':self.url})
return (f'#EXTINF:-1 tvg-name="{self.name}" tvg-logo="{self.logo}" group-title="{self.group}",{self.name}\n{self.url}')
if __name__ == "__main__":
with open("playlist.m3u8", "w") as playlist:
with open("playlist.m3u8", "w", encoding='utf-8') as playlist:
print("#EXTM3U", file=playlist)
for filename in sorted(os.listdir(".")):
if filename == "README.md" or not filename.endswith(".md"):
continue
with open(filename) as markup_file:
with open(filename, encoding='utf-8') as markup_file:
group = filename.replace(".md", "").title()
print("Generating %s" % group)
print(f"Generating {group}")
for line in markup_file:
if "<h1>" in line.lower() and "</h1>" in line.lower():
group = re.sub('<[^<>]+>', '', line.strip())