Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Fazzani committed Dec 3, 2024
1 parent 49d1d52 commit c842666
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 21 deletions.
14 changes: 9 additions & 5 deletions data/config_playlist.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ vodfilter:
regex:
- "\\.(mkv|avi|mp4)$"
hidden_groups:
- "\\b(منوعات)|(برامج)|(ليبيا)|(مغربية)|(أجنبية)|(آسيوية)|(هندية)|(مدبلجة)|(رعب)|(ألمانيه)|(مترجمة)|(تركية)|(اغاني)|(أغاني)|(طرب)|(رياضه\\sمتنوعه)\\b"
- "\\b(HANDBALL)|(F1)|(MOTO)|(FOOTBALL)|(wwe)|(CYCLISME)|(GOLF)|(BASKETBALL)|(WRC)\\b"
- "\\b(خليجية)|(جزائرية)|(مسيحية)|(يعرض)|(انمي)|(آسيوي)|(بودكاست)|(أجنبي)|(مدبلج)|(مترجم)|(منوعات)|(برامج)|(ليبيا)|(مغربية)|(أجنبية)|(آسيوية)|(هندية)|(مدبلجة)|(رعب)|(ألمانيه)|(مترجمة)|(تركية)|(اغاني)|(أغاني)|(طرب)|(رياضه\\sمتنوعه)\\b"
- "\\b(HANDBALL)|(F1)|(MOTO)|(FOOTBALL)|(wwe)|(CYCLISME)|(GOLF)|(BASKETBALL)|(WRC)|(Subs)|(Dub)\\b"

displaynamefilter:
priority: 2
Expand Down Expand Up @@ -45,9 +45,13 @@ shiftfilter:
cleannamefilter:
priority: 19
regex:
- "\\b(hevc)|(h265)|(XTRA)|(film)|(اغاني)||(طرب)|(مسلسل(?:ات)?(?:ال)?)|(الفلم|فلم|الفيلم|الفیلم|فيلم)|(بودكاست?(ال)?)|(برنامج?(ال)?)|(مسرحية)\\b"
- "\\b(عادل\\sإمام)|(اسماعيل\\sياسين)|(محمد\\sسعد)|(أحمد\\sزكي)\\b"
- "[!$%&«»°'\"()\\*\\+,\\.:/;<=>?@\\[\\]\\^_`{|}~◉\\-]"
- "\\b(hevc)|(h265)|(XTRA)|(Subs)|(film)|(مسلسل)|(اغاني)|(طرب)|(مسلسلات)|(الفلم)|(فلم)|(الفيلم)|(الفیلم)|(فيلم)|(بودكاست)|(برنامج)|(مسرحية)\\b"
- "[!$%&«»°\"\\(\\)\\*\\+,\\.:/;<=>?@\\[\\]\\^_`{|}~◉\\-]"
replacements:
- "عادل إمام"
- "اسماعيل ياسين"
- "محمد سعد"
- "أحمد زكي"

groupingfilter:
priority: 21
Expand Down
20 changes: 12 additions & 8 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
ENCODING_UTF8,
apply_filters,
download_file,
export_playlist,
get_filter_pool,
get_lines,
load_filters,
save_pl,
save_pl_to_path,
)
from pliptv.models.streams import M3u, Stream
Expand Down Expand Up @@ -139,24 +139,28 @@ def main(auto: bool, export: bool, is_generation_vod_enabled: bool, is_cache_ena
[res.get() for res in tqdm(multiple_results, desc="Live Tv processing")],
)

log(f"Saving {m3u.name.capitalize()}", "white")
file_result = save_pl_to_path(m3u, str(pl_info.get("playlist_output_path")))
channels_list = M3u(m3u.name, list(filter(lambda x: not x.meta.is_vod and not x.meta.hidden, m3u)))
log(f"Saving {m3u.name.capitalize()} with {len(channels_list.streams)} channels", "yellow")
file_result = save_pl_to_path(channels_list, str(pl_info.get("playlist_output_path")))

log(f"Generated playlist for {m3u.name.capitalize()}: {file_result}", "white")

if is_cache_enabled:
cache_playlist_generation(m3u)

if export:
url: str = save_pl(m3u)
url: str = export_playlist(channels_list)
LOG.debug(f"Playlist Exported to: {url}", "white")

created_streams = vod_processing(is_generation_vod_enabled, pl_info, playlist_config, m3u)
vod_created_streams = vod_processing(is_generation_vod_enabled, pl_info, playlist_config, m3u)
if vod_created_streams:
log(f"Processed {m3u.name.capitalize()} with {len(vod_created_streams)} channels", "yellow")

if is_cache_enabled:
cache_playlist_generation(m3u, "_final")

if created_streams:
cleanup(created_streams, str(pl_info.get("strm_output_path")))
if vod_created_streams:
cleanup(vod_created_streams, str(pl_info.get("strm_output_path")))

# Display report
# get_report(m3u)
Expand Down Expand Up @@ -199,7 +203,7 @@ def vod_processing(vod: bool, pl_info: dict[str, Any], playlist_config: Playlist

accepted_cultures = AcceptedFilter(playlist_config).filter_config.language
vod_list: list[Stream] = list(
filter(lambda x: x.meta.isVod and not x.meta.hidden and str.lower(x.meta.culture) in accepted_cultures, m3u.streams)
filter(lambda x: x.meta.is_vod and not x.meta.hidden and str.lower(x.meta.culture) in accepted_cultures, m3u.streams)
)

created_streams: list[str] = []
Expand Down
2 changes: 1 addition & 1 deletion pliptv/m3u_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def shorten_url(url: str, access_token: str) -> str:
return Shortener(api_key=access_token).bitly.short(url)


def save_pl(pl: M3u) -> str:
def export_playlist(pl: M3u) -> str:
"""Save playlist file on azure and return shorten url from bit"""
url = upload_bytes_to_azure(f"{pl.name}.m3u", str(pl))
at = os.getenv("BITLY_ACCESS_TOKEN")
Expand Down
4 changes: 2 additions & 2 deletions pliptv/models/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ class StreamMeta:
def __init__(self, display_name: str, tvg: Tvg | None = None):
self.tvg = tvg if tvg else Tvg()
self.display_name = display_name
self.isVod = False
self.isHeader = False
self.is_vod = False
self.is_header = False
self.hidden = False

def __str__(self):
Expand Down
2 changes: 2 additions & 0 deletions pliptv/pl_filters/clean_name_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,6 @@ def apply(self, value: Stream) -> Stream:
for reg in self.filter_config.regex:
regex = re.compile(reg, re.IGNORECASE | re.DOTALL)
value.meta.display_name = regex.sub("", value.meta.display_name).strip()
for replacement in self.filter_config.replacements:
value.meta.display_name.replace(replacement, "")
return value
2 changes: 1 addition & 1 deletion pliptv/pl_filters/grouping_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def apply(self, value: Stream) -> Stream:
Returns:
Tuple[Optional[str], str] -- culture, group moving filter
"""
if not value.meta.isVod and not value.meta.isHeader:
if not value.meta.is_vod and not value.meta.is_header:
value.meta.hidden = True
for group, regex in self.filter_config.map.__dict__.items():
match = re.search(regex, value.meta.tvg.group_title, re.IGNORECASE)
Expand Down
4 changes: 2 additions & 2 deletions pliptv/pl_filters/remove_headers_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ def apply(self, value: Stream) -> Stream:
match = re.search(r, value.meta.display_name, re.IGNORECASE)
if match:
value.meta.hidden = True
value.meta.isHeader = True
value.meta.is_header = True
break
else:
match = re.search(r, value.meta.tvg.tvg_name, re.IGNORECASE)
if match:
value.meta.hidden = True
value.meta.isHeader = True
value.meta.is_header = True
break
return value
2 changes: 1 addition & 1 deletion pliptv/pl_filters/vod_filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def apply(self, value: Stream) -> Stream:
for r in self.filter_config.regex:
match = re.search(r, value.url, re.IGNORECASE)
if match:
value.meta.isVod = True
value.meta.is_vod = True
if not value.meta.hidden:
for reg in self.filter_config.hidden_groups:
match_group = re.search(reg, value.meta.tvg.group_title, re.IGNORECASE)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="xpl",
version="0.1.3",
version="0.1.4",
author="Heni Fazzani",
author_email="[email protected]",
description="Simple extensible m3u playlist manager cli",
Expand Down

0 comments on commit c842666

Please sign in to comment.