diff --git a/README.md b/README.md index af3458a..989087c 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,7 @@ Feedback, improvements or suggestions are always welcome. ## Roadmap In no specific order: -- Find a way to dynamically register providers without the need to change `tvEPG.py` +- ~Find a way to dynamically register providers without the need to change `tvEPG.py`~ DONE - Move all the date format and handling outside of the providers, or pass the format to the providers. - Be more resilient, in case any provider breaks, we don't stop the EPG generation. - Support for more than one provider for each channel, so that if one provider fails we can fall back to another. diff --git a/providers/__init__.py b/providers/__init__.py index e69de29..ec46c7a 100644 --- a/providers/__init__.py +++ b/providers/__init__.py @@ -0,0 +1,9 @@ +import os +import glob + +all_list = list() +for f in glob.glob(os.path.dirname(__file__)+"/*.py"): + if os.path.isfile(f) and not os.path.basename(f).startswith('_'): + all_list.append(os.path.basename(f)[:-3]) + +__all__ = all_list \ No newline at end of file diff --git a/tvEPG.py b/tvEPG.py index 7b896eb..58e2b5f 100644 --- a/tvEPG.py +++ b/tvEPG.py @@ -9,17 +9,14 @@ ######################################### import utils.XMLChannelList as XMLChannelList -import providers.pt_meo -import providers.pt_meo_go -import providers.pt_vodafone -import providers.pt_elevensports -import providers.pt_nos import sys import time import argparse import logging from classes.xmltv.Channel import Channel from classes.xmltv.XMLTV import XMLTV +from providers import * + parser = argparse.ArgumentParser() parser.add_argument("-i", "--input", help="Specify the input channel list file", default="channelList.xml") @@ -60,23 +57,23 @@ start = time.time() if provCode == "MEO": logging.info("Getting info for MEO: " + str(len(xmlChannels))) - provXMLTV = providers.pt_meo.getEPG(xmlChannels, nrDays) + provXMLTV = pt_meo.getEPG(xmlChannels, nrDays) elif provCode == "MEOGO": logging.info("Getting info for MEOGO: " + str(len(xmlChannels))) - provXMLTV = providers.pt_meo_go.getEPG(xmlChannels, nrDays) + provXMLTV = pt_meo_go.getEPG(xmlChannels, nrDays) elif provCode == "VODAFONE": logging.info("Getting info for VODAFONE: " + str(len(xmlChannels))) - provXMLTV = providers.pt_vodafone.getEPG(xmlChannels, nrDays) + provXMLTV = pt_vodafone.getEPG(xmlChannels, nrDays) elif provCode == "ES": logging.info("Getting info for ES: " + str(len(xmlChannels))) - provXMLTV = providers.pt_elevensports.getEPG(xmlChannels, nrDays) + provXMLTV = pt_elevensports.getEPG(xmlChannels, nrDays) elif provCode == "NOS": logging.info("Getting info for NOS: " + str(len(xmlChannels))) - provXMLTV = providers.pt_nos.getEPG(xmlChannels, nrDays) + provXMLTV = pt_nos.getEPG(xmlChannels, nrDays) else: logging.info("No provider found for: ") for item in xmlChannels: