Detect conflicts

This commit is contained in:
2019-10-10 01:06:09 +02:00
parent 965d3e6c09
commit a12ffa58b0

View File

@ -2,10 +2,6 @@
""" """
Simple script that extracts information from Télé 7 jours and TMDB Simple script that extracts information from Télé 7 jours and TMDB
to help choosing the movies you want to record with your Freebox to help choosing the movies you want to record with your Freebox
Todo :
* Add a configuration setting for beginning and end margin
* Display conflicts if any
""" """
import argparse import argparse
import datetime import datetime
@ -155,6 +151,7 @@ class FreeboxMoviePlanner:
self.askForUserSelection() self.askForUserSelection()
self.excludeNotSelected() self.excludeNotSelected()
self.programMovies() self.programMovies()
self.checkForConflicts()
def __repr__(self): def __repr__(self):
result = 'FreeboxMoviePlanner <Movies:\n' result = 'FreeboxMoviePlanner <Movies:\n'
@ -247,17 +244,34 @@ class FreeboxMoviePlanner:
self.freebox.Pvr.Create_a_precord(data) self.freebox.Pvr.Create_a_precord(data)
print("Programmed '{}'".format(movie)) print("Programmed '{}'".format(movie))
def checkForConflicts(self):
programmed_movies = self.freebox.Pvr.Getting_the_list_of_precords()
conflicting_movies = [m for m in programmed_movies if m['conflict']]
if conflicting_movies:
print(
"!!!!!!!!!\n"
"!Warning!\n"
"!!!!!!!!!\n"
"Conflicting records detected, please "
"check your Freebox interface"
)
logging.info("Conflicting records detected '{}'".format(
conflicting_movies
))
if __name__ == '__main__': if __name__ == '__main__':
logging.basicConfig( logging.basicConfig(
level=logging.INFO, level=logging.WARNING,
format=' %(asctime)s - %(levelname)s - %(message)s' format=' %(asctime)s - %(levelname)s - %(message)s'
) )
parser = argparse.ArgumentParser(description='Plan movies on your Freebox') parser = argparse.ArgumentParser(
description='Schedule movie recordings on your Freebox'
)
parser.add_argument( parser.add_argument(
'-d', '--day', '-d', '--day',
action='store_true', action='store_true',
help='Search for a single day ahead' help='Search movies for current day only instead of a full week'
) )
args = parser.parse_args() args = parser.parse_args()