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