From ade622d0dd29d315af2c4d27d98c451ee782e712 Mon Sep 17 00:00:00 2001 From: djib Date: Sat, 28 Sep 2019 23:45:49 +0200 Subject: [PATCH] Adapt the list of days to start with the current day --- FreeboxMoviePlanner.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/FreeboxMoviePlanner.py b/FreeboxMoviePlanner.py index e2b603f..2739c86 100755 --- a/FreeboxMoviePlanner.py +++ b/FreeboxMoviePlanner.py @@ -9,9 +9,11 @@ Todo : import json import logging import requests +import datetime import tmdbsimple import textwrap from bs4 import BeautifulSoup +from collections import deque class FreeboxMoviePlanner: TV_GUIDE_URL = 'https://www.programme-television.org/{}?bouquet=tnt' @@ -31,12 +33,18 @@ class FreeboxMoviePlanner: tag['data-nature']=='films-telefilms' ) + def getAllMovies(self): - days = ['', 'dimanche', 'lundi', 'mardi', 'mercredi', - 'jeudi', 'vendredi', 'samedi'] + days = deque(['lundi', 'mardi', 'mercredi', + 'jeudi', 'vendredi', 'samedi', 'dimanche']) + offset = datetime.datetime.today().weekday() + days.rotate(-1-offset) + days.appendleft('') + for day in days: - print('=== {}'.format(day.title())) + print('=== {}'.format(day.title())) self.getMovies(day) + def getMovies(self, day=''): logging.info('Connecting to {}'.format(self.TV_GUIDE_URL)) @@ -79,6 +87,7 @@ class FreeboxMoviePlanner: logging.warning('No TMDB match for {}'.format( movie_title )) + def _getMovieRating(self, movie): logging.info("Searching for '{}' on TMDB".format(movie)) @@ -89,6 +98,7 @@ class FreeboxMoviePlanner: return search.results[0] else: return [] + if __name__ == '__main__': logging.basicConfig(