Switched from Télé 7 Jours to NouvelObs as Télé 7 Jours drastically changed its interface
This commit is contained in:
@ -59,15 +59,14 @@ class Movie:
|
|||||||
|
|
||||||
|
|
||||||
class TVGuideScraper:
|
class TVGuideScraper:
|
||||||
TV_GUIDE_URL = 'https://www.programme-television.org/{}?bouquet=free'
|
TV_GUIDE_URL = 'https://programme-tv.nouvelobs.com/programme-free/categorie-film/{}/'
|
||||||
|
|
||||||
def findAllMovies():
|
def findAllMovies():
|
||||||
movies = []
|
movies = []
|
||||||
days = deque(['lundi', 'mardi', 'mercredi',
|
days = deque(['lundi', 'mardi', 'mercredi',
|
||||||
'jeudi', 'vendredi', 'samedi', 'dimanche'])
|
'jeudi', 'vendredi', 'samedi', 'dimanche'])
|
||||||
offset = datetime.datetime.today().weekday()
|
offset = datetime.datetime.today().weekday()
|
||||||
days.rotate(-1-offset)
|
days.rotate(-offset)
|
||||||
days.appendleft('')
|
|
||||||
date = datetime.date.today()
|
date = datetime.date.today()
|
||||||
for day in days:
|
for day in days:
|
||||||
movies += TVGuideScraper._getMovies(day, date)
|
movies += TVGuideScraper._getMovies(day, date)
|
||||||
@ -83,32 +82,32 @@ class TVGuideScraper:
|
|||||||
r.raise_for_status()
|
r.raise_for_status()
|
||||||
html = BeautifulSoup(r.text, 'html.parser')
|
html = BeautifulSoup(r.text, 'html.parser')
|
||||||
movies = []
|
movies = []
|
||||||
for channel in html.select('.bloc_cnt'):
|
for channel in html.select('.tab_grille'):
|
||||||
if len(channel.select('em')):
|
for movietag in channel.select('.cat-film'):
|
||||||
for movietag in channel.find_all(TVGuideScraper._tag_is_movie):
|
try:
|
||||||
movie = Movie()
|
movie = Movie()
|
||||||
movie.title = \
|
movie.title = movietag.select('a.titre')[0].string
|
||||||
movietag.select('.texte_titre a')[0]['title']
|
movie.genre = 'Film' # Genre is not available
|
||||||
movie.genre = movietag.select('.texte_cat a')[0].string
|
movie.channel = channel.select('.logo_chaine_g img')[0]\
|
||||||
movie.channel = channel.select('em')[0]\
|
['alt'].replace('Programme ','')
|
||||||
.string.replace('Programme ', '')
|
|
||||||
movie.day = day.title()
|
movie.day = day.title()
|
||||||
movie.date = datetime.date.strftime(date, '%Y-%m-%d')
|
movie.date = datetime.date.strftime(date, '%Y-%m-%d')
|
||||||
movie.start_time = datetime.datetime.strptime(
|
movie.start_time = datetime.datetime.strptime(
|
||||||
'{} {}'.format(
|
'{} {}'.format(
|
||||||
movie.date,
|
movie.date,
|
||||||
movietag.select('.horaire')[0].string
|
movietag.select('span.t16')[0].string
|
||||||
),
|
),
|
||||||
'%Y-%m-%d %H:%M'
|
'%Y-%m-%d %H.%M'
|
||||||
)
|
)
|
||||||
duration = TVGuideScraper._parse_duration(
|
duration = TVGuideScraper._parse_duration(
|
||||||
movietag.select('.texte_cat')[0]
|
re.search(r'\((.*) mn\)',movietag.text).group(1)
|
||||||
.contents[1].strip(' \n\t()')
|
|
||||||
)
|
)
|
||||||
movie.end_time = movie.start_time + duration
|
movie.end_time = movie.start_time + duration
|
||||||
|
|
||||||
logging.debug('Found movie: {0!r}'.format(movie))
|
logging.debug('Found movie: {0!r}'.format(movie))
|
||||||
movies.append(movie)
|
movies.append(movie)
|
||||||
|
except:
|
||||||
|
logging.warning('Error parsing movie from tag: {0!r}'.format(movietag))
|
||||||
|
|
||||||
return movies
|
return movies
|
||||||
|
|
||||||
@ -125,14 +124,8 @@ class TVGuideScraper:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _parse_duration(text):
|
def _parse_duration(text):
|
||||||
match = re.match(r"((?P<hours>\d+)h)?(?P<minutes>\d+)mn", text)
|
minutes = int(text)
|
||||||
if not match:
|
return datetime.timedelta(minutes=minutes)
|
||||||
error = "Could not parse duration '{}'".format(text)
|
|
||||||
logging.error(error)
|
|
||||||
raise ValueError(error)
|
|
||||||
hours = int(match.group('hours')) if match.group('hours') else 0
|
|
||||||
minutes = int(match.group('minutes'))
|
|
||||||
return datetime.timedelta(hours=hours, minutes=minutes)
|
|
||||||
|
|
||||||
|
|
||||||
class FreeboxMoviePlanner:
|
class FreeboxMoviePlanner:
|
||||||
@ -195,7 +188,7 @@ class FreeboxMoviePlanner:
|
|||||||
"Excluding '{}'".format(channel['name'])
|
"Excluding '{}'".format(channel['name'])
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
self.channels[channel['name']] = channel['uuid']
|
self.channels[channel['name'].lower()] = channel['uuid']
|
||||||
else:
|
else:
|
||||||
logging.debug("Dropping '{}'".format(channel['name']))
|
logging.debug("Dropping '{}'".format(channel['name']))
|
||||||
logging.debug('Got the following channels: {}'.format(self.channels))
|
logging.debug('Got the following channels: {}'.format(self.channels))
|
||||||
@ -267,7 +260,7 @@ class FreeboxMoviePlanner:
|
|||||||
logging.info('Dropping movies on unavailable channels: {}'.format(
|
logging.info('Dropping movies on unavailable channels: {}'.format(
|
||||||
[m for m in self.movies if m.channel not in self.channels]
|
[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]
|
self.movies = [m for m in self.movies if m.channel.lower() in self.channels]
|
||||||
logging.debug('Kept {}'.format(self.movies))
|
logging.debug('Kept {}'.format(self.movies))
|
||||||
|
|
||||||
def excludeTelevisionMovie(self):
|
def excludeTelevisionMovie(self):
|
||||||
@ -340,6 +333,11 @@ if __name__ == '__main__':
|
|||||||
action='store_true',
|
action='store_true',
|
||||||
help='Display more log messages'
|
help='Display more log messages'
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'-b', '--debug',
|
||||||
|
action='store_true',
|
||||||
|
help='Display even more log messages'
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'-e', '--exclude',
|
'-e', '--exclude',
|
||||||
action='append',
|
action='append',
|
||||||
@ -357,7 +355,9 @@ if __name__ == '__main__':
|
|||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
print("Working the magic, please wait…")
|
print("Working the magic, please wait…")
|
||||||
if args.log:
|
if args.debug:
|
||||||
|
logging.getLogger().setLevel(logging.DEBUG)
|
||||||
|
elif args.log:
|
||||||
logging.getLogger().setLevel(logging.INFO)
|
logging.getLogger().setLevel(logging.INFO)
|
||||||
if args.day:
|
if args.day:
|
||||||
movies = TVGuideScraper._getMovies()
|
movies = TVGuideScraper._getMovies()
|
||||||
|
@ -7,16 +7,12 @@ A Python script to help you select the movies you want to record with your Freeb
|
|||||||
|
|
||||||
Introduction
|
Introduction
|
||||||
---
|
---
|
||||||
**Note du 11 janvier 2025 :** après 6 ans de bons et loyaux services, ce programme ne fonctionne plus. Le site que j’utilisais à totalement changé sont interface graphique et le programme ne fonctionne plus. Je ne regarde plus assez de films et je n’ai donc pas l’intention de l’adapter à court terme. Merci.
|
|
||||||
|
|
||||||
----
|
|
||||||
|
|
||||||
**FreeMoviePlanner** est un outil qui vous facilite la plannification
|
**FreeMoviePlanner** est un outil qui vous facilite la plannification
|
||||||
d'enregistrements avec votre *Freebox*.
|
d'enregistrements avec votre *Freebox*.
|
||||||
|
|
||||||
Concrètement, l'outil effectue les opérations suivantes :
|
Concrètement, l'outil effectue les opérations suivantes :
|
||||||
|
|
||||||
* Récupérer les film de la semaine à partir du [planning *Télé 7 Jours*](https://www.programme-television.org/?bouquet=free)
|
* Récupérer les film de la semaine à partir du [planning *NouvelObs*](https://programme-tv.nouvelobs.com/programme-free/categorie-film/)
|
||||||
* Retirer les chaînes auxquelles vous n'avez pas accès
|
* Retirer les chaînes auxquelles vous n'avez pas accès
|
||||||
* Trouver les notes des films sur [*TMDb*](https://www.themoviedb.org/) (*The Movie Database*)
|
* Trouver les notes des films sur [*TMDb*](https://www.themoviedb.org/) (*The Movie Database*)
|
||||||
* Exclure les films en dessous d'une certaine note (paramétrable)
|
* Exclure les films en dessous d'une certaine note (paramétrable)
|
||||||
@ -74,6 +70,7 @@ optional arguments:
|
|||||||
-h, --help show this help message and exit
|
-h, --help show this help message and exit
|
||||||
-d, --day Search movies for current day only instead of a full week
|
-d, --day Search movies for current day only instead of a full week
|
||||||
-l, --log Display more log messages
|
-l, --log Display more log messages
|
||||||
|
-b, --debug Display even more log messages
|
||||||
-e EXCLUDE, --exclude EXCLUDE
|
-e EXCLUDE, --exclude EXCLUDE
|
||||||
Exclude the following Channel
|
Exclude the following Channel
|
||||||
-x EXCLUDE_DIRECTORY, --exclude-directory EXCLUDE_DIRECTORY
|
-x EXCLUDE_DIRECTORY, --exclude-directory EXCLUDE_DIRECTORY
|
||||||
|
Reference in New Issue
Block a user