Adapt the list of days to start with the current day

This commit is contained in:
2019-09-28 23:45:49 +02:00
parent 60b1ba262a
commit ade622d0dd

View File

@ -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,13 +33,19 @@ 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()))
self.getMovies(day)
def getMovies(self, day=''):
logging.info('Connecting to {}'.format(self.TV_GUIDE_URL))
r = requests.get(self.TV_GUIDE_URL.format(day))
@ -80,6 +88,7 @@ class FreeboxMoviePlanner:
movie_title
))
def _getMovieRating(self, movie):
logging.info("Searching for '{}' on TMDB".format(movie))
search = tmdbsimple.Search()
@ -90,6 +99,7 @@ class FreeboxMoviePlanner:
else:
return []
if __name__ == '__main__':
logging.basicConfig(
level=logging.ERROR,