Add an option to manually filter channels
This commit is contained in:
@ -135,7 +135,7 @@ class TVGuideScraper:
|
||||
|
||||
|
||||
class FreeboxMoviePlanner:
|
||||
def __init__(self, movies):
|
||||
def __init__(self, movies, excluded_channels=[]):
|
||||
logging.debug('Opening config file: config.json')
|
||||
with open('config.json') as config_file:
|
||||
self.config = json.load(config_file)
|
||||
@ -150,7 +150,7 @@ class FreeboxMoviePlanner:
|
||||
app_id='FreeboxMoviePlanner',
|
||||
token=self.config['freebox-session-token']
|
||||
)
|
||||
self.getListOfAvailableChannels()
|
||||
self.getListOfAvailableChannels(excluded_channels)
|
||||
self.excludeUnavailableChannels()
|
||||
self.excludeTelevisionFilm()
|
||||
self.findMoviesOnTMDB()
|
||||
@ -181,12 +181,17 @@ class FreeboxMoviePlanner:
|
||||
result += '>'
|
||||
return result
|
||||
|
||||
def getListOfAvailableChannels(self):
|
||||
def getListOfAvailableChannels(self, excluded_channels):
|
||||
logging.info('Getting the list of available channels')
|
||||
self.channels = {}
|
||||
for channel in self.freebox.Tv.Getting_the_list_of_channels().values():
|
||||
if channel['available']:
|
||||
self.channels[channel['name']] = channel['uuid']
|
||||
if channel['name'] in excluded_channels:
|
||||
logging.debug(
|
||||
"Excluding '{}'".format(channel['name'])
|
||||
)
|
||||
else:
|
||||
self.channels[channel['name']] = channel['uuid']
|
||||
else:
|
||||
logging.debug("Dropping '{}'".format(channel['name']))
|
||||
logging.debug('Got the following channels: {}'.format(self.channels))
|
||||
@ -315,6 +320,12 @@ if __name__ == '__main__':
|
||||
action='store_true',
|
||||
help='Display more log messages'
|
||||
)
|
||||
parser.add_argument(
|
||||
'-e', '--exclude',
|
||||
action='append',
|
||||
default=[],
|
||||
help='Exclude the following Channel'
|
||||
)
|
||||
args = parser.parse_args()
|
||||
|
||||
print("Working the magic, please wait…")
|
||||
@ -324,4 +335,4 @@ if __name__ == '__main__':
|
||||
movies = TVGuideScraper._getMovies()
|
||||
else:
|
||||
movies = TVGuideScraper.findAllMovies()
|
||||
fmp = FreeboxMoviePlanner(movies)
|
||||
fmp = FreeboxMoviePlanner(movies, excluded_channels=args.exclude)
|
||||
|
Reference in New Issue
Block a user