Files
DemonEditor/app/eparser/__init__.py

80 lines
3.1 KiB
Python
Raw Normal View History

# -*- coding: utf-8 -*-
#
# The MIT License (MIT)
#
# Copyright (c) 2018-2025 Dmitriy Yefremov
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
# Author: Dmitriy Yefremov
#
2018-01-04 20:58:22 +03:00
from app.commons import run_task
2019-12-22 20:42:29 +03:00
from app.settings import SettingsType
2018-05-12 11:47:19 +03:00
from .ecommons import Service, Satellite, Transponder, Bouquet, Bouquets, is_transponder_valid
2018-01-01 17:28:19 +03:00
from .enigma.blacklist import get_blacklist, write_blacklist
from .enigma.bouquets import BouquetsWriter, BouquetsReader
2018-01-01 23:42:40 +03:00
from .enigma.lamedb import get_services as get_enigma_services, write_services as write_enigma_services
2017-12-08 18:32:28 +03:00
from .iptv import parse_m3u
2018-01-02 17:38:01 +03:00
from .neutrino.bouquets import get_bouquets as get_neutrino_bouquets, write_bouquets as write_neutrino_bouquets
from .neutrino.services import get_services as get_neutrino_services, write_services as write_neutrino_services
2018-01-01 17:28:19 +03:00
from .satxml import get_satellites, write_satellites
2019-12-22 20:42:29 +03:00
def get_services(data_path, s_type, format_version):
if s_type is SettingsType.NEUTRINO_MP:
2018-01-01 23:42:40 +03:00
return get_neutrino_services(data_path)
return get_enigma_services(data_path, format_version)
2018-01-01 17:28:19 +03:00
2018-01-04 20:58:22 +03:00
@run_task
2019-12-22 20:42:29 +03:00
def write_services(path, channels, s_type, format_version):
if s_type is SettingsType.ENIGMA_2:
2018-06-01 17:45:26 +03:00
write_enigma_services(path, channels, format_version)
2019-12-22 20:42:29 +03:00
elif s_type is SettingsType.NEUTRINO_MP:
2018-01-01 23:42:40 +03:00
write_neutrino_services(path, channels)
2019-12-22 20:42:29 +03:00
def get_bouquets(path, s_type):
if s_type is SettingsType.NEUTRINO_MP:
return get_neutrino_bouquets(path), 0
reader = BouquetsReader(path)
return reader.get(), reader.errors
2018-01-01 23:42:40 +03:00
def write_bouquet(path, bq, s_type):
if s_type is SettingsType.ENIGMA_2:
writer = BouquetsWriter(path, None)
2021-12-01 11:37:23 +03:00
writer.write_bouquet(f"{path}userbouquet.{bq.name}.{bq.type}", bq.name, bq.services)
elif s_type is SettingsType.NEUTRINO_MP:
from .neutrino.bouquets import write_bouquet
write_bouquet(path, bq)
2023-02-15 14:17:25 +03:00
def write_bouquets(path, bouquets, s_type, force_bq_names=False, blacklist=None):
2019-12-22 20:42:29 +03:00
if s_type is SettingsType.ENIGMA_2:
2023-02-15 14:17:25 +03:00
BouquetsWriter(path, bouquets, force_bq_names, blacklist).write()
2019-12-22 20:42:29 +03:00
elif s_type is SettingsType.NEUTRINO_MP:
2018-01-01 23:42:40 +03:00
write_neutrino_bouquets(path, bouquets)
2017-10-09 22:19:51 +03:00
if __name__ == "__main__":
pass