Merge pull request #1 from ibrahimalayah-Glooko/copilot/latest-m3u-arabic

Prioritize Arabic entries in the generated M3U
pull/1084/head
ibrahimalayah-Glooko 2026-06-19 17:00:36 +02:00 committed by GitHub
commit 5d098eae68
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 226 additions and 195 deletions

View File

@ -0,0 +1,15 @@
{
"files": ["playlist1.m3u", "playlist2.m3u"],
"rules": {
"no-empty-lines": true,
"require-header": true,
"attribute-quotes": true,
"require-info": true,
"no-trailing-spaces": true,
"no-whitespace-before-title": true,
"no-multi-spaces": false,
"no-extra-comma": true,
"space-before-paren": false,
"no-dash": true
}
}

View File

@ -90,6 +90,16 @@ COUNTRY_CODES = {
"venezuela": "VE",
}
ARABIC_PRIORITY_COUNTRIES = {
"chad",
"egypt",
"iraq",
"qatar",
"saudi_arabia",
"somalia",
"united_arab_emirates",
}
class Channel:
def __init__(self, group, md_line, country_code=""):
@ -120,6 +130,12 @@ class Channel:
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}')
def playlist_sort_key(filename):
country_key = filename[:-3]
arabic_priority = country_key.endswith("_ar") or country_key in ARABIC_PRIORITY_COUNTRIES
return (0 if arabic_priority else 1, filename)
def main():
base_dir = os.path.dirname(os.path.abspath(__file__))
lists_dir = os.path.join(base_dir, "lists")
@ -135,7 +151,7 @@ def main():
with open(os.path.join(base_dir, "playlist.m3u8"), "w", encoding='utf-8') as playlist:
playlist.write(head_playlist)
for filename in sorted(os.listdir(lists_dir)):
for filename in sorted(os.listdir(lists_dir), key=playlist_sort_key):
if filename == "README.md" or not filename.endswith(".md"):
continue
markup_path = os.path.join(lists_dir, filename)

File diff suppressed because one or more lines are too long