Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import modules by registering them in the providers init file #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 9 additions & 0 deletions providers/__init__.py
Original file line number Diff line number Diff line change
@@ -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
17 changes: 7 additions & 10 deletions tvEPG.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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:
Expand Down