Adapt the list of days to start with the current day
This commit is contained in:
@ -9,9 +9,11 @@ Todo :
|
|||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import requests
|
import requests
|
||||||
|
import datetime
|
||||||
import tmdbsimple
|
import tmdbsimple
|
||||||
import textwrap
|
import textwrap
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
|
from collections import deque
|
||||||
|
|
||||||
class FreeboxMoviePlanner:
|
class FreeboxMoviePlanner:
|
||||||
TV_GUIDE_URL = 'https://www.programme-television.org/{}?bouquet=tnt'
|
TV_GUIDE_URL = 'https://www.programme-television.org/{}?bouquet=tnt'
|
||||||
@ -31,13 +33,19 @@ class FreeboxMoviePlanner:
|
|||||||
tag['data-nature']=='films-telefilms'
|
tag['data-nature']=='films-telefilms'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def getAllMovies(self):
|
def getAllMovies(self):
|
||||||
days = ['', 'dimanche', 'lundi', 'mardi', 'mercredi',
|
days = deque(['lundi', 'mardi', 'mercredi',
|
||||||
'jeudi', 'vendredi', 'samedi']
|
'jeudi', 'vendredi', 'samedi', 'dimanche'])
|
||||||
|
offset = datetime.datetime.today().weekday()
|
||||||
|
days.rotate(-1-offset)
|
||||||
|
days.appendleft('')
|
||||||
|
|
||||||
for day in days:
|
for day in days:
|
||||||
print('=== {}'.format(day.title()))
|
print('=== {}'.format(day.title()))
|
||||||
self.getMovies(day)
|
self.getMovies(day)
|
||||||
|
|
||||||
|
|
||||||
def getMovies(self, day=''):
|
def getMovies(self, day=''):
|
||||||
logging.info('Connecting to {}'.format(self.TV_GUIDE_URL))
|
logging.info('Connecting to {}'.format(self.TV_GUIDE_URL))
|
||||||
r = requests.get(self.TV_GUIDE_URL.format(day))
|
r = requests.get(self.TV_GUIDE_URL.format(day))
|
||||||
@ -80,6 +88,7 @@ class FreeboxMoviePlanner:
|
|||||||
movie_title
|
movie_title
|
||||||
))
|
))
|
||||||
|
|
||||||
|
|
||||||
def _getMovieRating(self, movie):
|
def _getMovieRating(self, movie):
|
||||||
logging.info("Searching for '{}' on TMDB".format(movie))
|
logging.info("Searching for '{}' on TMDB".format(movie))
|
||||||
search = tmdbsimple.Search()
|
search = tmdbsimple.Search()
|
||||||
@ -90,6 +99,7 @@ class FreeboxMoviePlanner:
|
|||||||
else:
|
else:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
level=logging.ERROR,
|
level=logging.ERROR,
|
||||||
|
Reference in New Issue
Block a user