Browse Source

Exclude television films

master
djib 2 years ago
parent
commit
23838437bc
  1. 27
      FreeboxMoviePlanner.py

27
FreeboxMoviePlanner.py

@ -68,7 +68,7 @@ class TVGuideScraper:
for day in days:
movies += TVGuideScraper._getMovies(day, date)
date += datetime.timedelta(days=1)
logging.info('Found the following movies: {}'.format(movies))
logging.debug('Found the following movies: {}'.format(movies))
return movies
@staticmethod
@ -102,7 +102,7 @@ class TVGuideScraper:
)
movie.end_time = movie.start_time + duration
logging.info('Found movie: {0!r}'.format(movie))
logging.debug('Found movie: {0!r}'.format(movie))
movies.append(movie)
return movies
@ -132,7 +132,7 @@ class TVGuideScraper:
class FreeboxMoviePlanner:
def __init__(self, movies):
logging.info('Opening config file: config.json')
logging.debug('Opening config file: config.json')
with open('config.json') as config_file:
self.config = json.load(config_file)
tmdbsimple.API_KEY = self.config['tmdb-api']
@ -146,6 +146,7 @@ class FreeboxMoviePlanner:
)
self.getListOfAvailableChannels()
self.excludeUnavailableChannels()
self.excludeTelevisionFilm()
self.findMoviesOnTMDB()
self.excludeBadRatings()
self.askForUserSelection()
@ -167,8 +168,8 @@ class FreeboxMoviePlanner:
if channel['available']:
self.channels[channel['name']] = channel['uuid']
else:
logging.info("Dropping '{}'".format(channel['name']))
logging.info('Got the following channels: {}'.format(self.channels))
logging.debug("Dropping '{}'".format(channel['name']))
logging.debug('Got the following channels: {}'.format(self.channels))
def printAllMovies(self):
for movie in self.movies:
@ -214,25 +215,31 @@ class FreeboxMoviePlanner:
return []
def excludeBadRatings(self):
logging.info('Dropping novies with bad ratings: {}'.format(
logging.info('Dropping movies with bad ratings: {}'.format(
[m for m in self.movies if not m.good]
))
self.movies = [m for m in self.movies if m.good]
logging.info('Kept {}'.format(self.movies))
logging.debug('Kept {}'.format(self.movies))
def excludeUnavailableChannels(self):
logging.info('Dropping movies on unavailable channels: {}'.format(
[m for m in self.movies if m.channel not in self.channels]
))
self.movies = [m for m in self.movies if m.channel in self.channels]
logging.info('Kept {}'.format(self.movies))
logging.debug('Kept {}'.format(self.movies))
def excludeTelevisionFilm(self):
logging.info('Dropping television films')
self.movies = [
m for m in self.movies if not m.genre.startswith("Téléfilm")
]
def excludeNotSelected(self):
self.movies = [m for m in self.movies if m.user_selected]
def programMovies(self):
for movie in self.movies:
logging.info("Programming '{}'".format(movie))
logging.debug("Programming '{}'".format(movie))
data = {
'channel_uuid': self.channels[movie.channel],
'start': int(movie.start_time.timestamp()),
@ -255,7 +262,7 @@ class FreeboxMoviePlanner:
"Conflicting records detected, please "
"check your Freebox interface"
)
logging.info("Conflicting records detected '{}'".format(
logging.warning("Conflicting records detected '{}'".format(
conflicting_movies
))

Loading…
Cancel
Save